Commit graph

1458 commits

Author SHA1 Message Date
Ilya Grigoriev
d9c031c35b cli completion: remove non-functional diff editors/formatters
Follows up on  https://github.com/jj-vcs/jj/pull/7009
2025-07-19 18:09:01 +00:00
Ilya Grigoriev
fedbc3017f cli merge tools: allow setting diff-args=[] to disable diff formatting with a tool
Not setting `diff-args` is equivalent to `diff-args=["$left",
"$right"]`, which I also documented here.

I couldn't decide whether the new error should be part of
`DiffRenderError`, `DiffGenerateError`, or `MergeToolError`. Since the
treatment of diff formatters is already very different from other merge
tools, I just made it a CommandError for now.
2025-07-19 03:39:16 +00:00
Josh Steadmon
d7fa04f510 templater: add parents() method for Operation
Add a parents() method for `Operation` template objects, copied from the
implementation for `Commit`s.

The test case added in test_operations.rs was heavily inspired by
test_commit_templates.rs:test_log_parents().

Fixes #6979
2025-07-18 17:16:09 +00:00
Kaiyi Li
f1f1556731 local working copy: add support for EOL conversion 2025-07-17 15:36:28 +00:00
Evan Martin
d9b0a42a85 cli: make diff --stat fill available width
Previously, the computation for the available display width
included a padding constant, but this value was then used as
an upper bound for the width of the bar.  This meant the bar
would never fill the available screen width.
2025-07-17 02:03:16 +00:00
Evan Martin
228ea38aeb tests: make diff --stat test filenames clearer
Change the file names in the test to reflect a bit about what they're testing,
and add a test for a file that is a binary->binary modification.
2025-07-17 02:03:16 +00:00
Martin von Zweigbergk
59de83a84a cli: move desc and st aliases to config
We generally prefer to define aliases in the default config so users
can override them.
2025-07-15 06:11:28 +00:00
Hubert Głuchowski
8ec0196aca status: collapse entirely untracked directories
This change makes status collapse directories which don't contain any
tracked files into one line so that large untracked directories don't
clutter up the status with loads of files.

For example for a tree like this:
```
T src/main.rs
U src/lib.rs
U tmp/a.txt
U tmp/b.txt
```

Previously the status would display these untracked paths:
```
? src/lib.rs
? tmp/a.txt
? tmp/b.txt
```

With this change it now looks like this:
```
? src/lib.rs
? tmp/
```
2025-07-14 19:41:27 +00:00
Ilya Grigoriev
13d747c807 cli completion: complete diff tools such as :git and :summary 2025-07-14 05:29:09 +00:00
Ilya Grigoriev
1161e95640 cli completion: complete --tool args for merge tools
Includes diff tools, diff editors, and merge editors.
2025-07-14 05:29:09 +00:00
Stephen Jennings
9b86159789 fix: prepend file name to stderr output
To distinguish stderr output from different invocations of fix tools,
write the file name to stderr before writing the output from the fix
tool.
2025-07-12 05:35:34 +00:00
Stephen Jennings
8c12452f97 fix: write complete stderr output at once from fix tools
Fix tools often emit information on stderr for the user to see. Since
fix tools are run in parallel and stderr is unbuffered, this information
can be jumbled together. This seems to happen especially frequently on
Windows.

This change locks stderr before writing to it so the stderr output from
a tool is written all at once.
2025-07-12 05:35:34 +00:00
Yuya Nishihara
ea3c1791a6 revset: soft-deprecate "all:" modifier syntax 2025-07-11 17:15:26 +00:00
Yuya Nishihara
6c8f6e9744 cli: allow "large" revsets by default
Since divergent/conflicted symbols no longer resolve to multiple revisions, it's
less scary to allow "large" revsets than before.

The config doc is removed because it's largely duplicated from the revsets doc,
and the config key will be removed.

#6016
2025-07-11 17:15:26 +00:00
Yuya Nishihara
5666f4ac23 cli: complete: use diff template instead of parsing copied/renamed paths
I don't think the original implementation handles sorting and filtering of the
renamed source paths correctly, so I've added explicit .sort() at the end.

Fixes #6922
2025-07-10 12:42:08 +00:00
Yuya Nishihara
99e877b6a2 tests: add a few more copied/renamed files to completion sample 2025-07-10 12:42:08 +00:00
Remo Senekowitsch
5804bf95d0 bookmark rename: fix hint for pushing the rename
The --all flag previously also pushed deleted bookmarks. This was
changed and now --deleted is always required to push deleted bookmarks.
2025-07-09 18:37:22 +00:00
Ilya Grigoriev
083fdaac60 build.rs: separate commit ids if compiling at a merge commit
This makes the `test_version` test failure when run at a merge commit
less confusing. The test could be fixed, but I'm not sure it's worth it,
as we probably don't want to release a version of `jj` compiled at a
merge commit.

Now, if `jj` is compiled at a merge commit, this would print:

```
$ jj --version
jj 0.31.0-fb10a78cb359d52c0eda518a42ab07f117909004-ff9c9d0d8b4e929843eb683709fc1717645796df-99e035c5054e71906d7293ed98b542a9055057ef
```

Admittedly, this is a bit of a quick hack, but I've been confused by
`jj --version` output when compiled at a merge commit enough times
to want it.

Prior art: https://github.com/jj-vcs/jj/pull/6311 and
https://github.com/jj-vcs/jj/pull/4033 both pick one commit id hash
to print. I think I prefer printing all of them, even if it will fail
tests at a merge commit. After this commit, the failure will at least
be easy to understand.

However, if we prefer to merge one of the others, I'm OK with that too.
2025-07-08 02:38:21 +00:00
Pavan Kumar Sunkara
c038ef4bc3 workspaces: Add templating support to workspace list 2025-07-07 19:14:07 +00:00
Yuya Nishihara
be094ef76e revset: don't resolve symbol expression to multiple revisions
It's surprising that a symbol expression may be resolved to multiple revisions,
and that's one of the reason we require all: modifier in some places. Let's make
a symbol resolution fail in that case so we can deprecate the all: syntax.

The new error hints are a bit less informative, but I don't want to implement
ad-hoc formatting for resolve_some_revsets_default_single(). The user will have
to review the graph anyway in order to resolve divergence/conflicts.

Closes #5632
2025-07-07 14:11:29 +00:00
Ilya Grigoriev
784408f46f cli fetch: put all not-found branches into one warning
I often use the following command, sometimes in a loop over different repos.
It's annoying when it prints several lines of warnings. One line should
be enough.

```sh
jj git fetch && jj git fetch --remote upstream --branch main  --branch master \
   --branch 'glob:gh-readonly-queue*' --branch 'glob:ig/*'
```
2025-07-05 19:40:45 +00:00
Yuya Nishihara
ea8aa1e17c index: don't preserve commits not referred to by operations/views
In this implementation, we assume that predecessor commits created by old jj are
reachable from at least one of the historical views. However, there are a couple
of commands which create transitive predecessors. For example, "jj squash" into
grandparent will rebase a rewritten source, so the pre-rebase source commit
won't be visible to any views. To work around the problem, all immediate
predecessors of historically visible commits are also preserved.

Note that this change should be considered forward-incompatible change. The
stored commits may have unreachable predecessors once we run "jj op abandon &&
jj util gc".

WalkPredecessors::flush_commits() doesn't need to guard against unreachable
commits. I was wondering whether values (or old ids) of op.commit_predecessors
map should be preserved, and I decided to keep both keys and values. It's nice
that we can get rid of index.has_id() calls when we drop support for legacy
commit.predecessors.
2025-07-03 09:06:21 +00:00
Yuya Nishihara
3a8b83d1fc cli: git-push: make "change" bookmark names templated
Someone asked this on Discord, and it's useful if the bookmark name should
include e.g. issue number (which can be extracted from commit description.)
2025-07-02 01:55:59 +00:00
Yuya Nishihara
8db40c7fa2 revset: add change_id/commit_id(prefix) predicates
Basically, these functions work in the same way as bookmarks()/tags(). They
restrict the namespace to search the specified symbol, and unmatched symbol
isn't an error. One major difference is that ambiguous prefix triggers an error.
That's because ambiguous prefix should logically select all matching entries,
whereas the underlying functions don't provide this behavior. It's also unclear
whether we would want to get all matching commits by commit_id(prefix:'').

#5632
2025-06-30 14:38:50 +00:00
Gaëtan Lehmann
a59607db25 squash: allow to squash into the sources
This way it becomes possible, when squashing multiple commits, to specify
from which commit we keep the change-id, without needing to provide
multiple --from parameters.
For example, for a set of commits from x to z, with y somewhere in the
middle, before we had to run

  jj squash --from x::y- --from y+::z -into y

to squash x::z into y. Now we can

  jj squash --from x::z -into y

Squashing into the same change as the source becomes a no-op.

On the implementation side, we just make sure the destination commit is
not in the source commits.
2025-06-29 12:54:40 +00:00
Scott Taylor
bcde9ca728 revset: add parents(x, depth) and children(x, depth)
Resolves #3337.
2025-06-29 03:51:19 +00:00
Yuya Nishihara
d62052938c revset: normalize and simplify type error messages
These messages were inconsistent, and I think "expression of" is redundant.
2025-06-27 01:29:11 +00:00
Yuya Nishihara
f2b024caa3 revset: fix alias stack of pattern/literal parse error
The root error should be attached to the alias-unwrapped span.
2025-06-27 01:29:11 +00:00
Yuya Nishihara
a864eec073 templater: make Operation object serializable 2025-06-27 01:05:59 +00:00
Yuya Nishihara
5bfa79235d templater: make Commit object serializable 2025-06-27 01:05:47 +00:00
Yuya Nishihara
8adf0f6c16 templater: make CommitRef object serializable
Computed properties are removed from the serialized data. For example,
tracking ahead/behind count can be calculated by querying commits between
the target and tracking target.
2025-06-27 01:05:47 +00:00
Yuya Nishihara
d5e3ee8819 cli: op diff: use predecessors information to pair old/new commits
This should produce better results at squash/split operations. Since "op diff"
targets can be flipped, this patch implements basic handling of reversed
predecessors graph. It should also work for sibling operations so long as there
are no multiple greatest common ancestors.

resolve_transitive_edges() takes additional "start" parameter. It might be
useful in order to omit transitive edges in evolution log. Since
walk_predecessors() usually tracks a single commit, it would be wasteful to
build a fully-resolved predecessors graph.
2025-06-27 00:48:06 +00:00
Gaëtan Lehmann
0536c4cd7a squash: allow --interactive and fileset to be used together
everything required seems to be in place, but this was explicitly forbidden
in the command line parser configuration.
2025-06-24 18:57:19 +00:00
Yuya Nishihara
bc83eb0a48 id_prefix: check conflicting bookmarks/tags when calculating shortest length
Fixes #2416
2025-06-23 00:27:01 +00:00
Anton Älgmyr
e32326ebf6 cli: Remove hard-coding of log symbols and put them in default templates 2025-06-21 21:57:57 +00:00
Yuya Nishihara
26ba2a0975 cli: add "diff --template" argument
Since the commit template now supports diff.files(), it would probably make
sense that the diff command has the same functionality.

Closes #6681
2025-06-15 15:09:08 +00:00
Yuya Nishihara
91c2f842b9 cli: abandon: remove hidden revisions from the set to abandon
When experimenting on hidden revisions extension in revset #5871, I noticed "jj
abandon" attempted to re-abandon hidden revisions. This could be worked around
by repo.transform_descendants(), but I'm not sure whether the repo API should
ignore hidden revisions which are explicitly specified.

In any case, I don't think "jj abandon" should say hidden revisions get
abandoned.
2025-06-15 15:09:01 +00:00
Yuya Nishihara
b0f3c98175 cli: evolog: group graph nodes topologically
The output looks better if the graph had long parallel history. "--limit=N" is
applied after sorting for consistency with "jj log". The doc also mentions that.

Since TopoGroupedGraphIterator emits predecessors in reverse order at squash
point, we no longer need to tweak the visiting order by walk_predecessors().
2025-06-15 01:59:33 +00:00
Yuya Nishihara
e6c4890a0a cli: evolog: accept multiple starting revisions
There's no technical reason to restrict the starting revisions to a single
commit, and it will be nice that we can see evolution history of duplicated,
split, or divergent commits.
2025-06-15 01:59:33 +00:00
Vincent Ging Ho Yim
e72f161189 cli: fix typo in jj diff -r doc comment 2025-06-13 12:39:15 +00:00
Yuya Nishihara
0a9ab49dc5 revset: do not reinterpret set&filter intersection as filter
We use a query `heads | (domain & ::heads & files(path))` in annotation process,
and it was silly that the whole expression was filtered within `all()`. We
should instead evaluate `heads | filter_within(domain & ::heads, files(path))`.

Fixes #6713
2025-06-13 00:23:59 +00:00
Yuya Nishihara
c555687e8a tests: demonstrate bug of annotation starting from hidden revision 2025-06-13 00:23:59 +00:00
Yuya Nishihara
11599c6be1 cli: op diff: show divergent commits individually
Since divergence doesn't mean the commit has been squashed from / split into
multiple commits, it doesn't make much sense to show divergent commits as a
single entry. So this patch turns "changes" into a map indexed by CommitId in
order to track divergent commits individually. The ModifiedChange type is also
reorganized accordingly.

If old commits had divergence, we can't reliably associate new commit with the
old one. In the original implementation, we worked around the problem by not
displaying diffs for such changes. In this patch, the latest "old" commit is
arbitrarily chosen. I think this is better than disabling diffs, and will help
integrating predecessors information. Change-id based deduction won't be used
if new commits exist in the predecessors map.
2025-06-12 10:33:57 +00:00
Yuya Nishihara
cd173059dc cli: op diff: sort modified changes purely by commit ids
This basically means that the graph is sorted by "new" commits, then abandoned
commits follow. I'm thinking of integrating predecessors information into "op
diff", and it will make sense to identify changes by commit ids instead of
change ids there. Divergent commits will be displayed individually, and squashed
commits will have all predecessor commits including ones having different change
ids.

This should also fix "graph has cycle" issue. In the original implementation, we
mixed parent change ids of both new and old views, which could result in cycle.
2025-06-12 10:33:57 +00:00
Yuya Nishihara
25c028c5f0 tests: add "op diff" samples with divergent changes 2025-06-12 10:33:57 +00:00
Ilya Grigoriev
a96fa53101 cli git fetch: fix typo in error message 2025-06-12 00:28:41 +00:00
Yuya Nishihara
46dde130dd cli: op log/show: don't attempt to show diff from auto-merge parents
Unfortunately, we can't reproduce a merge in bit-exact manner. The shape of the
commits graphs should be identical, but commit/change ids differ. I don't think
we would want to see the list of "identical" changes, so this patch disables
show_op_diff() for merge operations. "op diff" is unchanged because it doesn't
fail, and the diff functionality might be useful for debugging problems.

Alternatively, we could show diff from the auto-merge state without rebasing
descendants, but I don't think that would be useful either. The state before
rebase_descendants() isn't visible to users, so it shouldn't be the stuff the
user would care about.

Fixes #4465
2025-06-12 00:16:21 +00:00
Yuya Nishihara
de6dd1c1f6 cli: op diff: don't show summary of dummy merge operation
A dummy merge shouldn't be visible to users. Only the merged view should matter.
2025-06-12 00:16:21 +00:00
Yuya Nishihara
efe1885456 tests: demonstrate problem of reproducing merged operation
Since merge_operations() may rebase descendants of the rewritten commits, it
can't produce the exactly same results.

#4465
2025-06-12 00:16:21 +00:00
Yuya Nishihara
523b9132c8 revset: remove redundant intersection/union with none()
Since we now have separate stage to resolve user symbols, we can simply rewrite
expressions like `x & none()` to `none()`.
2025-06-10 22:47:07 +00:00