Commit graph

1436 commits

Author SHA1 Message Date
Yuya Nishihara
0b1a6cd9e0 cli: allow any number of trailing dashes in "JJ: describe" line
Because a line without " -------" is allowed, it makes sense to strip other
variants like " --".
2024-08-06 10:15:32 +09:00
Yuya Nishihara
fb3e120092 cli: minor style cleanup in parse_bulk_edit_message() 2024-08-06 10:15:32 +09:00
Yuya Nishihara
f7b8a22c66 cli: remove redundant string concatenation from parse_bulk_edit_message() 2024-08-06 10:15:32 +09:00
Yuya Nishihara
f4dd856f9f ui: do not write() to channel if builtin pager has terminated 2024-08-05 10:34:33 +09:00
Yuya Nishihara
ce2bc8d6b6 ui: include error sources in pager warning
An error in builtin pager can be nested.
2024-08-05 10:21:23 +09:00
Benjamin Tan
35b04f45dc describe: allow updating the description of multiple commits
If multiple commits are provided, the description of each commit
will be combined into a single file for editing.
2024-08-05 02:06:40 +08:00
Ilya Grigoriev
37ccfd5acc built-in pager: write a message to the user if pager failed to start
The message is printed at the end, any text sent to the pager before
then is lost. See
https://github.com/martinvonz/jj/pull/4197#discussion_r1701799135
for a discussion about why that seems OK.
2024-08-03 17:45:18 -07:00
Yuya Nishihara
9ec617534c cli: merge op heads and snapshot working copy by "op log" by default
This partially reverts 543036c753 "cli: run 'op log' without loading repo or
merging concurrent ops." User can now get around the issue by --at-op=@
--ignore-working-copy.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
5bfb3742e8 cli: migrate trivial uses of op_walk::resolve_op_for_load()
Now heads merging can be turned off by --at-op=@.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
2008991749 cli: do not attempt to merge op heads if --at-op=@ is specified
The idea is that --at-op specifies a certain operation, so --at-op=@ can be
interpreted as the option to select _the_ known head operation. This helps
eliminate special cases from "op log" which doesn't snapshot nor merge
concurrent ops.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
b290af8e29 op_walk: include operation ids in multiple match error 2024-08-03 09:22:26 +09:00
Yuya Nishihara
e9d744db32 tests: add crash recovery test from bad GC
The current "op abandon" and "op log" have workarounds to recover from this
situation. Let's make sure they work as expected.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
cf053b7e09 ui: print :builtin pager suggestion as a hint 2024-08-03 09:14:29 +09:00
Yuya Nishihara
b503ecb071 ui: rewrite request_pager() to return early and use stdout instance 2024-08-03 09:14:29 +09:00
Yuya Nishihara
47a4406f4d ui: extract finalize_pager() as UiOutput method 2024-08-03 09:14:29 +09:00
Stephen Jennings
6c41b1bef8 revset: add author_date and committer_date revset functions
Author dates and committer dates can be filtered like so:

    committer_date(before:"1 hour ago") # more than 1 hour ago
    committer_date(after:"1 hour ago")  # 1 hour ago or less

A date range can be created by combining revsets. For example, to see any
revisions committed yesterday:

    committer_date(after:"yesterday") & committer_date(before:"today")
2024-08-01 09:04:07 -07:00
Essien Ita Essien
7c4185cd41 Change conflict hint depending on state of working commit.
To avoid always printing the rebase instructions to fix a conflict
even when a child commit to fix the conflict already exists, implement
the following:

* If working commit has conflicts:
  * Continue printing the same message we print today.

* If working commit has no conflicts:
  * If any parent has conflicts, we print: "Conflict in parent is resolved in working copy".
    Also explicitly not printing the "conflicting parent" here, since a merge commit
    could have conflict in multiple parents.
  * If no parent has any conflicts: exit quietly.
* Update unittests for conflict hinting update.
* Update CHANGELOG
2024-08-01 16:21:24 +01:00
Yuya Nishihara
d0f6f429e1 diff: add "diff" label globally by outer show_diff/patch() functions
It's not so important, but this removes duplicated "diff" labels from template
output. Perhaps, this also fixes "diff access-denied" label in file-by-file
external diffs.

The inner show_*() functions no longer add "diff" labels, but that's okay
because all CLI callers (except for the templater) use DiffRenderer.
2024-08-01 22:56:36 +09:00
Yuya Nishihara
07b0b0676d tests: rerun commit.diff() template test with --color=debug
The added test shows the "diff" label is repeated because of auto-labeling of
templater. The original "--color=always" test is also kept to ensure that color
sequences are unchanged even if we remove one of the "diff" labels.
2024-08-01 22:56:36 +09:00
Yuya Nishihara
052f022479 formatter: make error type of with_label() callback generic
This will help eliminate push/pop_label() calls from show_diff_*().
2024-08-01 22:56:36 +09:00
Yuya Nishihara
f57a7e5eba cli: move cmd_config_list() entry point next to Args struct 2024-08-01 09:54:12 +09:00
Yuya Nishihara
9168500341 cli: split commands/config.rs into sub modules 2024-08-01 09:54:12 +09:00
Yuya Nishihara
dc2b5500ff diff: specify available terminal width by caller, subtract graph width
The width parameter is mandatory so it wouldn't fall back to ui.term_width() by
mistake. The API is getting messy and we might want to extract some parameters
to separate struct.

Fixes #4158
2024-08-01 02:03:03 +09:00
Yuya Nishihara
1977748642 ui: fill in default term width globally and return as usize
I'm going to add more ui.term_width() callers, and it's unlikely we'll have to
set different defaults or error out.
2024-08-01 02:03:03 +09:00
Yuya Nishihara
b2b86825cb cli: move cmd_workspace_update_stale() entry point next to Args struct 2024-07-31 10:21:34 +09:00
Yuya Nishihara
21e1ce4f50 cli: split commands/workspace.rs into sub modules 2024-07-31 10:21:34 +09:00
Yuya Nishihara
a39dd0f176 cli: duplicate cmd_workspace_root() to cmd_root()
Suppose cmd_root() will gain options to print other kind of root paths, it's
probably simpler to inline path handling there instead of turning cmd_root()
into a dispatcher function. If cmd_root() remains with the current form, maybe
we can add aliases.root = ["workspace", "root"] instead.
2024-07-31 10:21:34 +09:00
Danny Hooper
51e11ff7e3 cli: fix: replace obsolete todo with a new one 2024-07-29 14:23:26 -05:00
Scott Taylor
304f6dfc3f workspace: warn if destination doesn't contain path separator
Users may try to run `jj workspace add <name>` without specifying a
path, which results in the workspace being created in the current
directory. This can be confusing, since the workspace contents will also
be snapshotted in the original workspace if it is not sparse. Adding a
warning should reduce confusion in this case.
2024-07-26 18:37:11 -05:00
Scott Taylor
4d8eee3416 test: update workspace path in test case
This test case was creating "workspace1" as a sub-directory of the
default workspace, which seems like a mistake.
2024-07-26 18:37:11 -05:00
Danny Hooper
89f5d16dc0 cli jj fix: add ability to configure multiple tools for different filesets
The high level changes include:
 - Reworking `fix_file_ids()` to loop over multiple candidate tools per file,
   piping file content between them. Only the final file content is written to
   the store, and content is no longer read for changed files that don't match
   any of the configured patterns.
 - New struct `ToolsConfig` to represent the parsed/validated configuration.
 - New function `get_tools_config()` to create a `ToolsConfig` from a `Config`.
 - New tests; the only old behavior that has changed is that we don't require
   `fix.tool-command` if `fix.tools` defines one or more tools. The general
   approach to validating the config is to fail early if anything is weird.

Co-Authored-By: Josh Steadmon <steadmon@google.com>
2024-07-25 13:40:18 -05:00
Danny Hooper
8fe2274584 fake-formatter: add --uppercase and --append formatting behaviors
This allows tests to easily distinguish the effects of multiple formatters that
could be applied during a single `jj fix` command, which is helpful for testing
the feature for configuring multiple formatters on potentially overlapping
filesets.

Uppercase is a counterpart to lowercase. Append exposes the number of changes
and their order of execution in the file content, which provides a terse way of
writing test expectations.
2024-07-25 13:40:18 -05:00
Yuya Nishihara
d6e97883df cli: port description template to templater
This implements a building block of "signed-off-by line" #1399 and "commit
--verbose" #1946. We'll probably need an easy way to customize the diff part,
but I'm not sure if it can be as simple as a template alias function. User
might want to embed diffs without "JJ: " prefixes?

Perhaps, we can deprecate "ui.default-description", but it's not addressed in
this patch. It could be replaced with "default_description" template alias,
but we might want to configure default per command. Suppose we add a default
"backout_description" template, it would have to be rendered against the
source commit, not the newly-created backout commit.

The template key is named as "draft_commit_description" because it is the
template to generate an editor template. "templates.commit_description_template"
sounds a bit odd.

There's one minor behavior change: the default description is now terminated
by "\n".

Closes #1354
2024-07-25 22:39:00 +09:00
Yuya Nishihara
5a19eb6331 cli: merge description_template_for_*() functions 2024-07-25 22:39:00 +09:00
Yuya Nishihara
45d16f4b34 cli: commit, split: set default description to intermediate commit object
description_template_for_*() functions will be merged soon.

We don't need to set the default description to the second commit of the split
because its description should be kept empty if it was.
2024-07-25 22:39:00 +09:00
Yuya Nishihara
6395d32358 cli: commit, split: pass temporary commit object to description helper 2024-07-25 22:39:00 +09:00
Yuya Nishihara
b9cc61b535 cli: describe: set default description to temporary commit object
This could be handled by description_template_for_describe(), but I think it's
better to do mutation by caller. I also think commands like "backout" or "new"
can do a similar thing to generate a default commit description from the source
or merge parent commits.
2024-07-25 22:39:00 +09:00
Philip Metzger
fa7f4e68c5 run: Treat jj run -j0 <command> as use all available cores
Waleed noticed this in #4021.
2024-07-24 22:13:28 +02:00
Yuya Nishihara
7d50ebc23e cli: commit: set up rewritten commit early
For the same reason as the previous commit.
2024-07-25 00:09:39 +09:00
Yuya Nishihara
453e4f3fcc cli: split: set up rewritten commits early
For the same reason as the cmd_describe() change. A temporary commit object
will be constructed in order to render it as a description template.
2024-07-25 00:09:39 +09:00
Yuya Nishihara
0208e60358 cli: split: make local variable names shorter 2024-07-25 00:09:39 +09:00
Yuya Nishihara
4e234c1a18 cli: split: narrow scope of temporary variables of first/second commits 2024-07-25 00:09:39 +09:00
Yuya Nishihara
d637216c16 cli: describe: start transaction and set up rewritten commit early
This will help consolidate description_template_for_*() functions and port them
to templater. This change also means the committer (and operation start)
timestamp is set earlier. I think that's good.
2024-07-25 00:09:39 +09:00
Yuya Nishihara
69bb57d1d1 cli: describe: don't unwrap read error of stdin 2024-07-25 00:09:39 +09:00
Yuya Nishihara
d328adca7b tests: use insta::assert_snapshot!() to capture description templates 2024-07-25 00:09:39 +09:00
Martin von Zweigbergk
d740f1801b conflicts: use non-legacy MergedTreeId for root commit
This is part of migrating away from legacy trees (with path-level
conflicts). I can't think of any practical impact (we already compare
the tree ids equal).
2024-07-24 14:33:05 +02:00
Yuya Nishihara
bafb357209 git: on abandoning unreachable commits, don't count HEAD ref
This basically reverts 20eb9ecec1 "git: don't abandon HEAD commit when it
loses a branch." I think the new behavior is more consistent because the Git
HEAD is equivalent to @- in jj, so it shouldn't be considered a named ref.

Note that we've made old HEAD branch not considered at 92cfffd843 "git: on
external HEAD move, do not abandon old branch."

#4108
2024-07-24 21:22:26 +09:00
Yuya Nishihara
eb332b1d08 cli: make for_loaded_repo() callers specify whether repo/workspace are synced
It's wrong to deduce loaded_at_head from command-line arguments if the repo was
loaded at an arbitrary operation. Instead, the caller should specify whether
the working copy state is synchronized with the repo view.

I think .for_loaded_repo(ui, workspace, repo, true) would be bad for
readability, so I added separate functions. I'm not happy with the name
.for_temporary_repo(), but it seems okay for the current call sites.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
d7c1b97418 cli: fix "workspace add --at-op" to set up new working copy properly
Because new workspace is created for the new operation forked from the --at-op
operation, the new working copy should be writable.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
b76947c1d6 cli: error out on "init --at-op/--ignore-working-copy" or "clone --at-op"
--at-op should be invalid on repo initialization. "init --ignore-working-copy"
could be supported by using working_copy.reset(), but I don't think it's
worth the effort. If the working directory is empty, --ignore-working-copy
is meaningless, and if the directory is not empty, the user would probably
want to do snapshot at some point.
2024-07-24 18:06:09 +09:00