60 Commits

Author SHA1 Message Date
Yuya Nishihara
af9c608ca5 config: migrate ui.default-description to template alias
Since we now have the template alias, it's easy to migrate the config value
programatically. However, there are a couple of minor behavior changes:

 a. default description won't be used if user customized the
    draft_commit_description template.
 b. default description won't be inserted if trailer is added

For (a), I assumed user would inline the default description in the draft
template if they customized the template. (b) should be okay because the
trailers template is a new feature.
2025-04-21 14:39:47 +00:00
Gaëtan Lehmann
fae66ace9b split: add trailer support 2025-04-18 16:48:01 +00:00
Winter
af60f3d674 cli: deprecate ui.default-description
Closes https://github.com/jj-vcs/jj/issues/6298.
2025-04-17 02:03:48 +00:00
Yuya Nishihara
87a35d5bb2 tests: port test_split_command.rs to TestWorkDir API 2025-04-03 01:43:02 +00:00
Yuya Nishihara
f2ca6b7740 tests: set up fake editor early in test_{split,squash}_command.rs
This helps avoid borrowing issue.
2025-04-03 01:43:02 +00:00
Yuya Nishihara
4bcebe678c cli: pad empty description intro/instruction lines with "JJ:"
Since 7618b52b "cli: consider 'JJ:' lines as comments also when not followed by
space", lines starting with "JJ:" (without space) are also ignored. We can
simply add "JJ:" prefix to empty intro/instruction lines.

Closes #5484
2025-04-01 02:02:02 +00:00
Yuya Nishihara
fd05b6f4cb cli: make description template insert blank line if old description was empty
This helps detect whether the last line is "JJ:" instruction or not. It seems
also nice that I don't have to insert newline to reflow the edited paragraph.
2025-04-01 02:02:02 +00:00
Robin Stocker
0456701e18 cli: Print @ and @- in status and print_updated_working_copy_stats
This helps newcomers learn/remember what @ and @- stand for.
2025-03-31 11:57:04 +00:00
Evan Mesterhazy
83ce245995 cli split: Check the evolog in two tests
This is to ensure two things:

1. That the evolog isn't missing the history from the target commit.
2. That the evolog doesn't include extra "temporary" commits due to
   the way `jj split` is implemented.

The impetus for this is the discussion in https://github.com/jj-vcs/jj/pull/5926.
The changes added here detect the extra temporary commit added to the evolog
when `split --parallel` is run using the implementation in #5926.
2025-03-25 14:21:44 +00:00
Evan Mesterhazy
6ba5a76f51 cli split: Rename "siblings" test to "parallel"
The name of the flag was changed from --siblings to --parallel a while back,
but the tests weren't renamed.

#cleanup
2025-03-24 14:42:40 +00:00
Evan Mesterhazy
bb78c06d76 cli split: Add a simple split with descendants test
We have this test for split --parallel, but we don't actually have a
non-parallel split test where the target commit has descendants.
2025-03-24 14:42:06 +00:00
Evan Mesterhazy
b627924828 cli split: Explain how the diff script works in test_split_interactive_with_paths
It wasn't immediately obvious to me what was happening here, but once I
understood it it seemed pretty simple. Perhaps it's worth a comment to explain
it to the next reader.
2025-03-24 13:58:21 +00:00
Ilya Grigoriev
5eae2d92a0 tests: run insta --force-update-snapshots
This is a replacement for #5558.

Thanks to @yuja 's https://github.com/mitsuhiko/insta/pull/722, this is
now easy to generate.
2025-03-06 21:35:08 +00:00
Evan Mesterhazy
2af5b60d32 cli split: Disable the new bookmark behavior for jj split
The consensus about this change, if one ever existed, seems to have dissolved
into two cohorts, one which is happy with the change, and one which thinks we
should move both the bookmark and change id to the child commit instead of
leaving them on the parent.

We may decide to add flags to allow users to choose between the two behaviors,
but there are also other concerns such as where @ should go (parent or child).
Until we agree on a path forward it seems reasonable to delay the breaking
change by disabling it via the config option we added. I don't think it's
necessary to fully revert the code and new tests since we aren't announcing the
option.


#3419
2025-02-28 23:23:06 +00:00
Yuya Nishihara
7fa8420908 tests: resolve directory path to run_jj_in() relative to env_root
Suppose we'll add test_env.init_workspace(path) or something, this will probably
make sense.
2025-02-25 15:40:14 +00:00
Yuya Nishihara
ad6985fd9c tests: migrate unusual patterns of jj_cmd_ok() to run_jj_in()
These callers are manually ported to run_jj_in().
2025-02-24 15:39:11 +00:00
Yuya Nishihara
804d175fd9 tests: migrate non-snapshot users of jj_cmd_ok() to run_jj_in().success()
These callers were mostly substituted mechanically.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
3193513049 tests: migrate snapshot users of jj_cmd_ok() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up formatting.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
255532b6b8 tests: reorder comments and snapshots, split insta::allow_duplicates! { .. }
This helps replace jj_cmd_ok() by pattern matching.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
cdcc777730 tests: migrate snapshot users of jj_cmd_success() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up minor
formatting and name errors.
2025-02-23 13:34:17 +00:00
Yuya Nishihara
d19e58f591 tests: migrate callers of jj_cmd_failure() to run_jj_in() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
f1cd3a4e53 tests: migrate some jj_cmd_success() output wrappers to run_jj_in() 2025-02-22 01:23:04 +00:00
Yuya Nishihara
b1eca3710c cli: parse bookmark name to be created/updated as revset symbol
This should help prevent misuse of "jj bookmark set" with e.g. remote bookmark
name. A remote-looking bookmark can be created by quoting the name if needed.

This patch doesn't change the parsing of name patterns. For patterns, I think
it's better to add support for compound expressions (e.g. `glob:foo* & ~bar`)
rather than adding revset::parse_string_pattern(text) -> StringPattern.

Closes #5705
2025-02-20 08:05:20 +00:00
Yuya Nishihara
630036eeb0 tests: add [EOF] marker to command output when displaying
It's important to test that command output is (usually) terminated with newline,
but insta::assert_snapshot!() is lax about that.
2025-02-19 02:31:59 +00:00
Yuya Nishihara
a54165230a tests: add CommandOutputString wrapper
I'm going to add "[EOF]" marker to test that command output is terminated by
newline char. This patch ensures that callers who expect a raw output string
would never be affected by any normalization passes.

Some common normalization functions are extracted as CommandOutputString
methods.
2025-02-19 02:31:59 +00:00
Evan Mesterhazy
a4b064ea8d cli split: Move bookmarks to the first commit instead of the second
After even more discussion on Discord, we decided to use the new bookmark
behavior immediately and only print a warning during `jj split` if the user has
opted out of the new behavior using the `split.legacy-bookmark-behavior` config
setting.

The reasoning is that if the behavior change breaks someone's workflow or is
very disruptive, they are likely to check the changelog and learn about the
config option. For users that are not adversely impacted, printing a warning
that can only be silenced by changing their config is also disruptive.

#3419
2025-02-16 04:02:24 +00:00
Evan Mesterhazy
37992412b6 cli split: Recommend jj config set --user instead of --repo in deprecation warning
It only occurred to me after I rebuilt jj and actually had to run the command
that we should probably recommend a change to the user config instead of the
repo config.

#3419
2025-02-14 01:41:41 +00:00
Evan Mesterhazy
d5d21643d5 cli split: Add a config option controlling how bookmarks move during splits
Currently, `jj split` moves bookmarks from the target revision to the second
revision created by the split. Since the first revision inherits the change id
of the target revision, moving the bookmarks to the first revision is less
surprising (i.e. the bookmarks stay with the change id). This no-implicit-move
behavior also aligns with how `jj abandon` drops bookmarks instead of moving
them to the parent revision.

Two releases from now, `jj split` will no longer move bookmarks to the second
revision created by the split. Instead, local bookmarks associated with the
target revision will move to the first revision created by the split (which
inherits the target revision's change id). You can opt out of this change by
setting `split.legacy-bookmark-behavior = true`, but this will likely be
removed in a future release. You can also try the new behavior now by setting
`split.legacy-bookmark-behavior = false`.

Users who have not opted into the new behavior via the config setting will see
a warning when they run `jj split` informing them about the change. The default
behavior be changed in the future.

The `jj split` tests for bookmarks are updated to run in all three configurations:

- Config setting enabled
- Config setting disabled
- Config setting unset


#3419
2025-02-13 21:45:56 +00:00
Evan Mesterhazy
b2e2c79088 cli split: Move bookmark testing to a separate test
We are planning to add a config option that controls how bookmarks and change
ids move during `jj split` based on feedback in https://github.com/jj-vcs/jj/pull/5618.
I think the tests will be more readable after the config option is added if we
move the bookmark testing to its own test.

#3419
2025-02-12 19:45:37 +00:00
David Rieber
dd73b5ab7d bookmarks: First step to make target revision a required argument to bookmark create/move/set.
With this change a warning is shown if the user does not explicitly specify the target revision, but the behavior is unchanged (it still defaults to the working copy).
In the future the warning will be turned into an error. In other words, it will be required to specify target revision.

The bulk of the changes here are to prepare tests for the upcoming change, to make the transition easier.

For additional details please see:
* https://github.com/jj-vcs/jj/issues/5374
* https://github.com/jj-vcs/jj/discussions/5363
2025-02-11 22:21:19 +00:00
Evan Mesterhazy
915fe8f11e cli split: Test how the working copy commit changes across multiple workspaces
When a commit is split, the second commit produced by the split becomes the
working copy commit for all workspaces whose working copy commit was the target
of the split.

This commit adds two tests for this behavior:

1. Split a commit which is the working copy commit for two workspaces.
2. Split a commit which is the working copy commit for only one of the two
   workspaces.

These tests check that the working copy commits for the workspaces are updated
correctly. Both parallel and non-parallel splits are tested.
2025-02-10 14:05:45 +00:00
Yuya Nishihara
0d022f1202 cli: fix interactive diff selection to not retain unmatched files
This patch doesn't fix DiffEditor::edit() API, which is fundamentally broken
if matcher argument is specified. I'm not sure if the builtin behavior is
correct or not. Suppose we add "jj diffedit FILESETS..", it would probably make
sense to leave unmatched paths unmodified because it is the command to edit the
destination (or right) tree. This is the edit_diff_external() behavior.

Fixes #5252
2025-01-04 22:21:37 +09:00
Martin von Zweigbergk
7618b52b79 cli: consider "JJ:" lines as comments also when not followed by space
We currently ignore lines prefixed with "JJ: " (including the space)
in commit messages and in the list of sparse paths from `jj sparse
edit`. I think I included the trailing space in the prefix simply
because that's how we render comments line we insert before we ask the
user to edit the file. However, as #5004 says, Git doesn't require a
space after their "#" prefix. Neither does Mercurial after their "HG:"
prefix. So let's follow their lead and not require the trailing
space. Seems useful especially for people who have their editor
configured to strip trailing spaces.
2024-12-04 10:40:56 -08:00
Samuel Tardieu
f38c59f734 split: do not prevent all changes from going into the first commit
Let the user select all changes interactively and put them into
the first commit, and create a second commit with the possibility
of preserving the current commit message. This was previously only
possible in non-interactive mode by specifying matching paths, e.g.
".".  In both cases, a warning will be issued indicating that the second
commit is empty.
2024-09-27 13:33:05 +02:00
Samuel Tardieu
98c16c4e19 split: do not reference file paths in warning
jj split warning was potentially wrong in both interactive and
non-interactive modes when everything is put into the child commit:

- Non-interactive mode: "The given paths does not match any file:
  PATHS". The message is misleading, as the PATHS given on the command-line
  may match files but not match files containing changes.
- Interactive mode: "The given paths does not match any file: " while
  if possible that no paths were given on the command line.
2024-09-27 13:33:05 +02:00
Philip Metzger
d9c68e08b1 everything: Rename branches to bookmarks
Jujutsu's branches do not behave like Git branches, which is a major
hurdle for people adopting it from Git. They rather behave like
Mercurial's (hg) bookmarks. 

We've had multiple discussions about it in the last ~1.5 years about this rename in the Discord, 
where multiple people agreed that this _false_ familiarity does not help anyone. Initially we were 
reluctant to do it but overtime, more and more users agreed that `bookmark` was a better for name 
the current mechanism. This may be hard break for current `jj branch` users, but it will immensly 
help Jujutsu's future, by defining it as our first own term. The `[experimental-moving-branches]` 
config option is currently left alone, to force not another large config update for
users, since the last time this happened was when `jj log -T show` was removed, which immediately 
resulted in breaking users and introduced soft deprecations.

This name change will also make it easier to introduce Topics (#3402) as _topological branches_ 
with a easier model. 

This was mostly done via LSP, ripgrep and sed and a whole bunch of manual changes either from
me being lazy or thankfully pointed out by reviewers.
2024-09-11 18:54:45 +02:00
Matt Kulukundis
8ead72e99f formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04: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
d328adca7b tests: use insta::assert_snapshot!() to capture description templates 2024-07-25 00:09:39 +09:00
Anton Älgmyr
c7eac90200 Enable the new graph nodes by default.
It's been tested in various places now, so this is probably mature
enough to be the default.
2024-07-16 12:54:24 +02:00
Scott Taylor
b27ff28956 cli: skip formatting instructions if not required
`tx.format_commit_summary()` can be expensive because it needs to build
an IdPrefixContext now, so it's best to avoid formatting instruction
messages unless they are actually required.
2024-07-09 20:24:14 -05:00
mlcui
c256ad8a0a windows: avoid UNC paths in run_ui_editor
See #3986 for more details. This is a no-op for non-Windows.
2024-07-04 11:30:20 +10:00
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Martin von Zweigbergk
a9953b3fb0 cli: deprecate jj split --siblings in favor of jj split --parallel
This better matches `jj parallelize`.
2024-06-15 22:45:34 +09:00
Martin von Zweigbergk
fe9daac483 tests: avoid deprecated jj init --git/--git-repo
I left the instances in `test_init_command.rs` alone since they're
about testing `jj init`.
2024-05-17 13:55:20 -07:00
Alexander Potashev
07559f24ec Refuse to split an empty commit with jj split.
Rationale: The user may be confused by the empty diff in the diff editor
tool if they accidentally run `jj split` on a wrong (empty) commit.
2024-05-10 19:37:28 +02:00
Evan Mesterhazy
e0c53bcfc0 Rewrite rebasing in jj split using transform_descendants()
This is following on the rewrite for `parallelize`.

- https://github.com/martinvonz/jj/pull/3521

Since rebase_descendants from rebase.rs is no longer used outside of that file,
it can be made private again.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
6d2884317a Add checks for stderr and stdout to jj split tests
This would have caught a bug in https://github.com/martinvonz/jj/pull/3550
that otherwise might have slipped through.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
65a525cfd9 Add a test for splitting the parent of a merge commit without --siblings
This is the same as the `test_split_siblings_with_merge_child` added in
https://github.com/martinvonz/jj/pull/3485, but without the siblings flag. I
forgot to add the non-siblings version in that PR.

#3485
2024-04-11 14:58:55 -04:00
Evan Mesterhazy
37be542ebf Fix a bug when the target of jj split has merge commit children
Ilya reported this in https://github.com/martinvonz/jj/issues/3483.

The bug was introduced in 976320726d.

Before this fix, `jj split` dropped any parents what weren't involved in the
split when it rebased the children of the commit being split. This meant that
any children which were merge commits lost their other parents unintentionally.

Fixes #3483
2024-04-11 13:26:07 -04:00