2532 Commits

Author SHA1 Message Date
Ilya Grigoriev
5ca7dca3bf cli: warn on startup for vimdiff used as a diff editor
This is more visible than a comment. Once this is supported, I'm
considering removing this entirely. I doubt many people intentionally
use it, but if so, they can easily remove this warning in their config.

Another option would be to set up a file-by-file diff editing mode,
for which vimdiff would be fine.
2025-04-01 14:31:23 -07:00
Ilya Grigoriev
ecde53c5bb cli completion: add completion for jj git push --named
Follow-up to https://github.com/jj-vcs/jj/pull/5698
2025-04-01 16:56:33 +00:00
Remo Senekowitsch
fb1a27ff09 cli: require --deleted to push deleted bookmarks 2025-04-01 15:58:50 +00:00
Yuya Nishihara
5db62a6b96 tests: port test_revset_output.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
f1a52d8504 tests: port test_revert_command.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
4d4de68c91 tests: port test_restore_command.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
3ba2ea7ace tests: port test_resolve_command.rs to TestWorkDir API 2025-04-01 15:00:17 +00:00
Yuya Nishihara
169a8b3f35 tests: set up fake editor early in test_{resolve,restore}_command.rs
This helps avoid borrowing issue in the next patch.
2025-04-01 15:00:17 +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
Robin Stocker
2d9c72ffb1 cli/tests: Prevent git.subprocess from reading outside git config
A subset of cli tests could fail if the system /etc/gitconfig had
configuration interfering with the tests. The cause seems to be running
of `jj` commands that would in turn use a `git` subprocess.

Fix this by setting `GIT_CONFIG_SYSTEM` and `GIT_CONFIG_GLOBAL`, like
in `hermetic_git`.

Fixes #6159
2025-03-31 10:46:57 +00:00
Yuya Nishihara
60372ead43 tests: port test_repo_change_report.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
d15aa8c1c1 tests: port test_rebase_command.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
f3ed4cfed6 tests: port test_parallelize_command.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
da8ff3083c tests: port test_operations.rs to TestWorkDir API 2025-03-31 10:35:36 +00:00
Yuya Nishihara
022147e4f4 diff: use BString more consistently in rendering functions 2025-03-31 10:34:14 +00:00
Yuya Nishihara
a3a59abe74 diff: pass left/right contents and line number pairs by array
When rendering diff of conflicts, it might make sense to show diff of negative
(or base) terms with "removed"/"added" labels swapped. For example, diffs
between A and B-C+D can be rendered as

  {left, right} = {A (-), B (+)}, {A (+), C (-)}, {A (-), D (+)}

by padding -A+A to the left side. To achieve that, I'm thinking of adding
labels: [&str; 2] parameter. This patch will help keep function arguments more
consistent there.

FWIW, I also tried rendering in {A (-), B (+)}, {C (-), D (+)} forms. This
seemed not intuitive because, when diffing, we compare two distinct states. In
the example above, the diff {C, D} should be considered an internal state at the
right side, not the states pair to be diffed.
2025-03-31 10:34:14 +00:00
Ilya Grigoriev
9db0739320 cli git push: new --named NAME=REVISION argument to create and immediately push bookmark
Fixes #5472
2025-03-31 03:51:28 +00:00
Yuya Nishihara
3f5f872204 view: rename workspace "id" to "name"
This matches the current implementation.
2025-03-31 03:39:29 +00:00
Yuya Nishihara
e66c545438 view: replace WorkspaceId by string-like newtypes
I think this makes more sense because WorkspaceId is currently a human-readable
name. In error/status messages, workspace names are now printed in revset
syntax.

New WorkspaceId types do not implement Default. It would be weird if string-like
type had non-empty Default::default(). The DEFAULT constant is provided instead.
2025-03-31 03:39:29 +00:00
Yuya Nishihara
a08d53bef8 cli: do not panic on non-utf-8 workspace name to add 2025-03-31 03:39:29 +00:00
Yuya Nishihara
f87db58617 view: rename RemoteRefState::Tracking to Tracked
In jj's model, a local bookmark "tracks" remote bookmarks. It's wrong to call
a remote bookmark state as "tracking".
2025-03-31 01:41:31 +00:00
Yuya Nishihara
e4982a9c33 git: report HEAD export failure as warning
It's safe to commit transaction even if HEAD couldn't be updated due to
concurrent changes.

Closes #6098
2025-03-30 01:46:00 +00:00
Yuya Nishihara
cd1ee943e6 git: split GitResetHeadError, add UpdateHeadRef variant
This helps handle "HEAD" export failure differently. At this point, the set of
error variants look distinct enough to split the error types.
2025-03-30 01:46:00 +00:00
Yuya Nishihara
4beaa6c509 cli: don't map GitExportError to internal error
It seemed inconsistent that only GitExportError was translated to an internal
error. There are various reasons that triggers git::export_refs()/reset_head()
failure, and some of them are environmental error.
2025-03-30 01:46:00 +00:00
Yuya Nishihara
c33be3839d git: remove redundant error context messages, rename variants
Wrapped errors are usually displayed after "Failed to import refs ...", etc., so
the context is obvious. I also removed "Internal"/"Error" for consistency.
2025-03-30 01:46:00 +00:00
Yuya Nishihara
69f278a581 tests: port test_next_prev_commands.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
1df956bfb5 tests: port test_new_command.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
511d0bd499 tests: port test_log_command.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
7f1bc15469 tests: port test_interdiff_command.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Yuya Nishihara
76283dc4b6 tests: port test_immutable_commits.rs to TestWorkDir API 2025-03-29 14:42:08 +00:00
Jakob Hellermann
68ef93ebd6 cli: add revsets.log-graph-prioritize setting
The option will be used to prioritize branches of the `jj log` graph to
be displayed on the left.
This can make them more readable in some situations.
An example would be
```
[revsets]
log-graph-prioritize = "coalesce(description("megamerge\n"), trunk())"
```
2025-03-29 13:50:55 +00:00
Yuya Nishihara
96cfae1ff7 cli: abandon: show warning if deleted bookmarks had tracking remotes
This should mitigate the issue that user might push deleted bookmarks without
noticing by "jj abandon && jj git push --all".

https://github.com/jj-vcs/jj/issues/3505#issuecomment-2646024815
2025-03-28 14:34:51 +00:00
Yuya Nishihara
7124d1b90a cli: move has_tracked_remote_bookmarks() to cli_util 2025-03-28 14:34:51 +00:00
Yuya Nishihara
fb1c5da3db cli: git-push: remove support for existing long --change bookmark names
It's deprecated since 1aad25042029 "Shorten the git push branch when possible
using the short change ID hash" (2023-01-12). I don't think we need the
fallback. I also removed the check for ambiguous prefixes as I believe it
wouldn't practically matter. If needed, we can add a check for existing bookmark
pointing to different commit. We can also make it templated with default
"'push-' ++ change_id.shortest(12)".
2025-03-28 14:34:11 +00:00
Yuya Nishihara
d6be4a598e git: use GitRefName newtypes in push functions 2025-03-28 01:29:30 +00:00
Yuya Nishihara
fb8e45d6f9 view: introduce GitRefName newtypes
We don't reuse the RefName type here because fully-qualified Git ref name
shouldn't be considered a local ref name in jj.
2025-03-28 01:29:30 +00:00
Remo Senekowitsch
f295817fe3 cli: completion: fix renamed paths
Previously, the completions suggested the literal string:
`{f_not_yet_renamed => f_renamed}`. Instead, the old and new file names
should be completed separately.
2025-03-27 22:23:29 +00:00
Remo Senekowitsch
4c8ddd47d0 cli: completion: fix test for renamed paths
Previously, the "renamed" file wasn't deleted at its old location, so it
wasn't renamed at all. Correcting this reveals a bug in the completions
of renamed paths. The completions suggest the literal string:
`{f_not_yet_renamed => f_renamed}`. Instead, the old and new file names
should be completed separately.
2025-03-27 22:23:29 +00:00
Ilya Grigoriev
1dedd9ce10 vimdiff merge tool: automatically navigate to first conflict
This also sets the search pattern to `<<<<<`, allowing the user to press `n` to
jump to the next conflict
2025-03-27 22:12:08 +00:00
Ilya Grigoriev
9d8474768d vimdiff merge tool: use the default conflict markers
With the default config (if global `conflict-marker-style` is not
customized), this reverts the behavior to that before 7f57866332.

`vimdiff` config already shows three panes with the three snapshots for
each conflict, so it's helpful to show jj's diff view in the editing
pane.

In other words, previously the conflict was always shown in the
"snapshot" format in the main pane:

```
<<<<<<< Conflict 1 of 1
+++++++ Contents of side #1
fn has_tracked_remote_bookmarks(view: &View, bookmark: &RefName) -> bool {
------- Contents of base
fn has_tracked_remote_bookmarks(view: &View, bookmark: &str) -> bool {
+++++++ Contents of side #2
pub fn has_tracked_remote_bookmarks(view: &View, bookmark: &str) -> bool {
>>>>>>> Conflict 1 of 1 ends
```

and now it is shown in whatever format the user set as the default. If
the user didn't pick a default, the "diff" format is used in the main
pane:

```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-fn has_tracked_remote_bookmarks(view: &View, bookmark: &str) -> bool {
+fn has_tracked_remote_bookmarks(view: &View, bookmark: &RefName) -> bool {
+++++++ Contents of side #2
pub fn has_tracked_remote_bookmarks(view: &View, bookmark: &str) -> bool {
>>>>>>> Conflict 1 of 1 ends
```

See also the screenshot in https://github.com/jj-vcs/jj/pull/6147 to see
the main pane in the context of the three other panes that always
display the snapshots.
2025-03-27 22:12:08 +00:00
Yuya Nishihara
bcf3d5869b revset: add optional local variables to RevsetParseContext 2025-03-27 13:23:58 +00:00
Yuya Nishihara
ffad6fe96f revset: extract internal context struct from RevsetParseContext
This allows callers to mutate RevsetParseContext if needed.

RevsetParseContext was changed to an opaque struct at 4e0abf06317f "revset: make
RevsetParseContext opaque." I think the intent there was to hide implementation
details from revset extension functions. This is now achieved by opaque
LoweringContext.

Another reason of this change is that aliases_map is no longer needed when
transforming AST to UserRevsetExpression.
2025-03-26 13:03:41 +00:00
Yuya Nishihara
a50f3881f0 cli: move revset_parse_context() and template_aliases_map() to env object
There aren't many callers of these functions.
2025-03-26 13:03:41 +00:00
Yuya Nishihara
3656a62bf5 git: use RemoteName newtype in remote management functions 2025-03-26 13:03:37 +00:00
Yuya Nishihara
4ff2827d00 git: use RemoteName/RefName newtypes in fetch functions 2025-03-26 13:03:37 +00:00
Yuya Nishihara
b9f51ff992 ref_name: add RefName::to_remote_symbol(remote) for convenience 2025-03-26 13:03:37 +00:00
Yuya Nishihara
02722eae54 view: port bookmark/tag name types to RefName/RemoteName
I tried to minimize this patch, but it seemed rather complicated than porting
most callers all at once. Remote management functions in git.rs are unchanged.
They'll be ported separately.

With this change, many non-template bookmark/remote name outputs should be
rendered in revset syntax.
2025-03-26 11:07:06 +00:00
Yuya Nishihara
cc8a80c548 ref_name: move RemoteRefSymbol types from refs module 2025-03-26 11:07:06 +00:00