2112 Commits

Author SHA1 Message Date
pylbrecht
c90f0b96a4 sign: add default revisions for jj sign
When signing commits with `jj sign`, one might want to use a workflow
like:

```bash
jj fix && jj sign .. && jj git push
```

Making the default value for `-r`/`--revisions` configurable, will allow
such a workflow.

Co-Authored-By: Yuya Nishihara <yuya@tcha.org>
2025-02-28 07:14:59 +00:00
Aleksey Kuznetsov
cfcd034879 docs: Add pointers to usage of jj help -k <keyword>
Relates to #5306
2025-02-28 06:52:52 +00:00
Yuya Nishihara
ae8e6e8e8e view: port remote_bookmark accessors to RemoteRefSymbol 2025-02-26 03:17:45 +00:00
Yuya Nishihara
4b06274785 view: make remote bookmark iterators yield RemoteRefSymbol instead of tuple
This also changes formatting of remote symbol to use revset compatible form.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
6c71f3cbf2 git: use RemoteRefSymbolBuf to represent RefName::RemoteBranch variant
This also changes the formatting to use revset compatible form.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
c63a7fa4d2 cli: bookmark: replace RemoteBookmarkName with RemoteRefSymbol
Now remote bookmark names are printed in revset compatible form.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
cdd62a68f1 cli: bookmark: borrow remote bookmark names from cloned repo
This will help port find_remote_bookmarks() to RemoteRefSymbol<'_>.
2025-02-26 03:17:45 +00:00
Yuya Nishihara
4729a01082 cli: git: use RemoteRefSymbol type to specify trunk() alias 2025-02-26 03:17:45 +00:00
pylbrecht
f7ceac3bf4 unsign: implement jj unsign command
The output of `jj unsign` is based on that of `jj abandon`.

We output warnings when unsigning commits, which are not authored by the
user. This is encouraging to use `jj undo`, in case one unintentionally
drops signatures of others.

---

Co-authored-by: julienvincent <m@julienvincent.io>
Co-authored-by: necauqua <him@necauq.ua>
2025-02-25 13:36:44 +00:00
Anton Bulakh
76f79961fb sign: implement the jj sign command
We always sign commits. This means commits, which are already signed,
will be resigned. While this is cumbersome for people using hardware
devices for signatures, we cannot reliably check if a commit is already
signed at the moment (see https://github.com/jj-vcs/jj/issues/5786).

We output warnings when signing commits, which are not authored by the
user. This is encouraging to use `jj undo`, in case one unintentionally
signs commits of others.

The output of `jj sign` is based on that of `jj abandon`.

---

Co-authored-by: julienvincent <m@julienvincent.io>
Co-authored-by: necauqua <him@necauq.ua>
2025-02-25 13:36:44 +00:00
Yuya Nishihara
37bfc64cf2 working_copy: do not update watchman clock if untracked files exist
This means that watchman is partially disabled until the user cleans up
untracked files. This isn't nice, but should be better than hiding untracked
files forever.

Fixes #5728
Fixes #5602
2025-02-24 08:22:21 +00:00
Bryce Berger
708e1c58cd cli: improve hint message when suggesting --ignore-immutable
There have been a number of users confused about why
their commits are immutable, or what to do about it, ex.
[https://github.com/jj-vcs/jj/discussions/5659].

Separately, I feel that the cli is too quick to suggest
`--ignore-immutable`, without context of the consequences. A new user
could see that the command is failing, see a helpful hint to make it not
fail, apply it and move on. This has wildly different consequences, from
`jj squash --into someone_elses_branch@origin` rewriting a single commit,
to `jj edit 'root()+'` rewriting your entire history.

This commit changes the immutable hint by doing the following:

* Adds a short description of what immutable commits are used for, and a
  link to the relevant docs, to the hint message.
* Shows the number of immutable commits that would be rewritten if
  the operation had succeeded.
* Removes the suggestion to use `--ignore-immutable`.
2025-02-23 02:24:43 +00:00
Bryce Berger
a17ed203ab fix: invoke tools from the workspace root
Previously, tools invoked by `jj fix` did not have their
`.current_dir()` set, and would just run from whatever directory the
user was in.

Now, the tools will always be invoked from the same directory that
`jj root` gives.

As a motivating example, consider a configuration path that's always at
the workspace root:

```toml
[fix.tools.something]
# previous:
command = ["cmd", "--config", "$root/tool.toml"]
#                              ^^^^^^ not possible
# now:
command = ["cmd", "--config", "./tool.toml"]
#                              ^^ now, just use a relative path
```
2025-02-23 02:21:57 +00:00
Bryce Berger
35936463ed cli: warn when command differs after --config, including when subcommand not found
Aliases and `ui.default-command` are loaded before `--config` and
`--config-file` arguments are parsed (#5282).

There is supposed to be a warning when the result of these arguments
would change the parsed args: #5286.

However, that warning was not being printed if the arguments failed to
parse due to an unrecognized subcommand. Example:

```bash
# correct:
$ jj --config ui.default-command=nonsense
Warning: Command aliases cannot be loaded from -R/--repository path or --config/--config-file arguments.

# previous, confusing:
$ jj --config aliases.some-alias=nonsense some-alias
error: unrecognized subcommand 'some-alias'

# now:
$ jj --config aliases.some-alias=nonsense some-alias
Warning: Command aliases cannot be loaded from -R/--repository path or --config/--config-file arguments.
error: unrecognized subcommand 'some-alias'
```
2025-02-22 20:19:42 +00:00
George Christou
e1abaca21c templater: add trim methods to String type 2025-02-21 21:23:11 +00:00
Antoine Martin
631b9ada3d track: only print snapshot stats and hints once
Move the `track` specific logic to track.rs, let print_snapshot_stats
handle just the default case.

Previously print_snapshot_stats would get called twice and could warn
twice about a file (if that file was both in the auto-track fileset as
well as in the fileset passed to `jj file track`), so now we merge the
snapshot stats and display appropriate hints for each file.
2025-02-21 17:35:04 +00:00
Antoine Martin
0d02e855cd cli_utils: extract warning printing code from print_snapshot_stats
This will be re-used in the `track` command.
2025-02-21 17:35:04 +00:00
Antoine Martin
984c7aae20 cli_utils: make snapshot stats printing optional
Snapshot stats were automatically printed when calling
`WorkspaceCommandHelper::snapshot_working_copy`. This has been moved up
the call chain to allow more choice in when to actually print stats.

These functions used to trigger printing of the snapshot stats via
(direct or indirect) calls to `snapshot_working_copy`:

- CommandHelper::workspace_helper_with_stats
- CommandHelper::recover_stale_working_copy
- WorkspaceCommandHelper::maybe_snapshot_impl

This means we can now chose not to print the snapshot stats if we know
we will perform another snapshot operation during the same command, to
reduce the number of warnings and hints shown to the user.

Calling `workspace_helper`, or `maybe_snapshot` instead of
`workspace_helper_with_stats` and `maybe_snapshot_impl` still prints
stats automatically.
2025-02-21 17:35:04 +00:00
George Christou
f77e64391d cli: add support for Sublime Merge 2025-02-21 05:44:53 +00:00
George Christou
19cf1368f1 cli: restore: Fix --to placeholder 2025-02-21 05:40:43 +00:00
Yuya Nishihara
6308897a23 cli: mention revsets doc on syntax error
Maybe we can show more specific hints on certain cases, but this should be good
as a fallback. The message is copied from the FilesetParseError hint.
2025-02-20 08:05:20 +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
George Christou
a5e079f543 ui: add color to help text 2025-02-20 01:22:02 +00:00
Stephan Hügel
fececd9174 cli: add mergiraf to the default merge tools config
Added as per Martin's suggestion: https://discord.com/channels/968932220549103686/969291218347524238/1341910959601614893
2025-02-20 01:14:39 +00:00
Baltasar Dinis
f233de5f69 cli: remove error hint for invalid remote names
Existing hint suggests using `jj git remote rename`, but that's not
applicable to `jj git clone`.

This commit removes that hint.
2025-02-19 07:14:00 +00:00
Yuya Nishihara
48b02226f5 cli: add "Hint: " prefix to conflict hints 2025-02-19 06:52:09 +00:00
Yuya Nishihara
a2a9a9935c cli: render "conflicts" message as warning
I don't have strong feeling, but this might be better because conflicts are
unusual?
2025-02-19 06:52:09 +00:00
Yuya Nishihara
1fa4e5a340 cli: status: do not label message lines as "conflict"
The "conflict" label is supposed to highlight "(conflict)" markers in commit
template. This patch just removes the label as we don't colorize the same
message in update_working_copy().
2025-02-19 06:52:09 +00:00
Yuya Nishihara
617e17fbe6 cli: use commit.has_conflict() extensively
Maybe it's slightly cheaper if there are no conflicts.
2025-02-19 06:52:09 +00:00
Yuya Nishihara
067e2ebaaa cli: status: reorder conflict message to match checkout stats
It seems also nice that the list of conflict files is displayed closer to the
resolution hints.
2025-02-19 06:52:09 +00:00
Yuya Nishihara
dd59cef1a2 cli: show executable name (with suffix) in help requested by "jj help"
On Windows, "jj help" and "jj --help" outputs were slightly different because
the binary name may have ".exe" suffix.
2025-02-19 02:31:59 +00:00
Ilya Grigoriev
55f130e085 streampager: stop uselessly reading the config file (fix a TODO)
https://github.com/facebook/sapling/pull/1011 is in, yay! 🎉

Follows up on https://github.com/jj-vcs/jj/pull/5415
and https://github.com/jj-vcs/jj/pull/5711
2025-02-18 19:01:30 +00:00
Baltasar Dinis
64ea8bee47 git: reject remotes with forward slashes
Although this behaviour is accepted by git, it's a degenerate case.
Especially because we implicitely rely on being able to parse out the
remote from the refname (i.e., `refs/remotes/<remote>/<branch>`).

Branches can have forward slashes, but if remotes can also have them,
parsing the refname becomes ambiguous, and a pain. Especially because it
would be totally legal to have a branch "c" on remote "a/b" and a branch
"b" on remote "a".

Fixes #5731
2025-02-18 07:10:01 +00:00
Baltasar Dinis
d6e7047142 cli: add hint to rename on remote management error 2025-02-18 07:10:01 +00:00
Antoine Martin
149702ef7d working_copy: adjust max-size hint to fit all configurations
In the case where the user has set `snapshot.auto-track` to something
other than `all()`, running `jj st` with a higher file size set just for
that command will not actually fix the user's problem, `jj file track`
needs to be called instead.
2025-02-17 20:52:18 +00:00
Martin von Zweigbergk
a6ca04e6cb cli_util: call Workspace::check_out() also for no-op updates
Some working-copy implementations, like the Google CitC one, may want
to update the VFS's state even if the tree didn't change. In
particular, when updating between two commits with the same tree but
different mainline base, we want to update the base commit. Otherwise
a future snapshot, which we do relative to the mainline commit, may
notice an incorrect set of changed file.
2025-02-17 18:59:56 +00:00
Martin von Zweigbergk
a89bcf23ea cli_util: make update_working_copy() return all-zero stats instead of None
When updating the working copy results in no changes, we currently
return `None` from `cli_util::update_working_copy()`. However, a no-op
update is still an update, so I think it makes more sense to always
return a `CheckoutStats`. We already skip printing stats if they're
zero.
2025-02-17 18:59:56 +00:00
Scott Taylor
00f87a2846 cli: untrack remote bookmarks on bookmark forget
Forgetting remote bookmarks can lead to surprising behavior since it
causes the repo state to become out-of-sync with the remote until the
next `jj git fetch`. Untracking the bookmarks should be a simpler and
more intuitive default behavior. The old behavior is still available
with the `--include-remotes` flag.

I also changed the displayed number of forgotten branches. Previously
when forgetting "bookmark", "bookmark@remote", and "bookmark@git" it
would display `Forgot 1 bookmarks`, but I think this would be confusing
with the new flag since the user might think that `--include-remotes`
didn't work. Now it shows separate `Forgot N local bookmarks` and
`Forgot M remote bookmarks` messages when applicable.
2025-02-17 17:02:58 +00:00
Yuya Nishihara
3cdaa5b1d8 cli: bookmark: remove hint about upsert behavior
It was added at 3c80e3453db6 "cli: branch: make "set" do upsert as before" in
order to remind behavior change.
2025-02-17 12:44:03 +00:00
Alain Leufroy
fa3254b4a7 templates: add hook points for users to customize the default operation id
Same as `format_short_change_id`.

We can't use `format_short_id` because `operation.id()` does not have `shortest()` method.
2025-02-17 09:08:51 +00:00
Martin von Zweigbergk
3bfbec1c83 undo: fix check for double-undo
The condition we were checking (which I suggested during review) is
very broken. It checks if the new view is equal to view before the
current operation, but that's supposed to always be true (except for
operation that update remote bookmarks). The reason the warning didn't
trigger all the time was that we did the comparison after calling
`merge_view()` but before calling `rebase_descendants()` (via
`tx.finish()`). The former only records commits as abandoned without
actually hiding them. However, because of [the hack][hack] in
`merge_view()` to make it work reasonably well in huge repos, every
undo operation at Google would print the warning.

This patch fixes the bug by checking if the to-be-undone operation is
an undo by comparing its view to its grandparent's view.

 [hack]: ec6f8278fd/lib/src/repo.rs (L1693-L1708)
2025-02-16 16:52:51 +00:00
maan2003
ec6f8278fd signing: allow specifying sign behavior 2025-02-16 05:56:52 +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
Yuya Nishihara
4ec22dde38 templater: port annotation line content to template
I originally thought we would have to add BString template type first, but we
can use opaque Template type instead.
2025-02-15 11:07:17 +00:00
Yuya Nishihara
6f51696600 templater: use property.map() to apply infallible transformation
Also renamed data to line as the type name was changed to AnnotationLine.
2025-02-15 11:07:17 +00:00
Bryce Berger
3bc111e60e annotate: make AnnotationLine template type
Allows:
* self.commit()
* self.line_number()
* self.first_line_in_hunk()

Certain pagers (like `delta`), when used for `git blame`, only show the
commit information for the first line in a hunk. This would be a nice
addition to `jj file annotate`.

`jj file annotate` already uses a template to control the rendering of
commit information --- `templates.annotate_commit_summary`. Instead of
a custom CLI flag, the tools necessary to do this should be available in
the template language.

If `1 % 2` or `1.is_even()` was available in the template language, this
would also allow alternating colors (using `raw_escape_sequence`).

Example:

```toml
[templates]
# only show commit info for the first line of each hunk
annotate_commit_summary = '''
if(first_line_in_hunk,
  show_commit_info(commit),
  pad_end(20, " "),
)
'''
```
2025-02-15 02:34:38 +00:00
Martin von Zweigbergk
77fb50c8cd completion: mark git remote arguments as URL instead of path
Fixes #5704.
2025-02-15 01:59:16 +00:00
Bryce Berger
e4ad7b6c0f fix: add simple debugging logs
There's currently no way to tell what `jj fix` is doing. This adds some
traces such that `jj fix --debug` will at least tell you what's being
run and what it's exit code is, similar to other subprocessing code.
2025-02-15 01:13:17 +00:00
Philip Metzger
4a47a4fc1d commit: Add commit.is_hidden(repo)
Also simplify the `hidden()` revset with it.
2025-02-14 16:24:01 +00:00
Benjamin Tan
e021036740 cli: backout: add templates.backout_description configuration
Closes #5676.
2025-02-14 07:56:40 +00:00