Commit graph

3019 commits

Author SHA1 Message Date
Ivan Petkov
e0ca7c653d lib: refactor git fetch ahead of future updates 2025-08-25 15:55:18 +00:00
Yuya Nishihara
a763de49ed templater: add serialization support for config::AnnotatedValue type
GenericTemplateLanguage now requires C: Serialize, which I think is okay because
the context type here would usually be a struct of value types.
2025-08-25 05:52:46 +00:00
Yuya Nishihara
535d8d48dd templater: serialize ConfigValue through toml::Value
We could instead implement serde::Serialize wrapper manually, but it would be
tedious to process recursive data structure. Let's just rely on the toml crate.
The cost of conversion wouldn't matter.
2025-08-25 05:52:46 +00:00
Yuya Nishihara
4962e13480 templater: relax trait bounds of methods table types
Instead of requiring L::Property type, make it the default type parameter which
can be specified as needed. This helps remove unnecessary trait bounds from
later patches.
2025-08-25 05:52:46 +00:00
Yuya Nishihara
bbf12c5ab5 templater: reorder generic functions in methods table, rename variables
This isn't important, but empty() and merge() don't need L: TemplateLanguage, so
they can be split to new impl block.
2025-08-25 05:52:46 +00:00
Yuya Nishihara
6e63c5d9aa templates: remove operation timestamp from default evolog template
The operation timestamp is often very close to the committer timestamp, so I
don't think it's useful in evolog. I also removed "root()" as it wouldn't be
useful either, and the root operation should have no evolved commits.
2025-08-25 05:52:37 +00:00
Ian Wrzesinski
ab8bf205a5 diff_working_copies: Simplify tree checkout functions
I got annoyed by the checkout function and tried to compress the code a bit,
and I think the result is much nicer. I'm not certain that a closure is the
right solution here, but I think it becomes easier to reason about the two
temp filenames that get generated.

I initially changed `Option<DiffSide>` to a bool, but found an enum more
meaningful and more likely to be flexible in the future.

I also moved the instruction writing to its own function. This makes the main
`DiffEditWorkingCopies::check_out()` function much nicer.
2025-08-24 22:55:37 +00:00
Remo Senekowitsch
32020573b8 undo: deprecate the --what flag
Relevant discussion:
https://github.com/jj-vcs/jj/pull/7277#discussion_r2291421321
2025-08-24 07:14:01 +00:00
Remo Senekowitsch
12b3a26f3d undo: revert progressively older operations with repeated calls
New users (especially ones unfamiliar with CLI programs) intuitively
expect `jj undo` to work the same way the "undo" functionality of
typical GUI applications do. That means, running `jj undo` multiple
times should restore progressively older states of the repository
one-by-one.

Related feature request "jj undo ergonomics":
https://github.com/jj-vcs/jj/issues/3700
2025-08-24 06:56:40 +00:00
Ivan Petkov
61a5c10916 cli: use clap::ValueHint::{FilePath,DirPath} over PathCompleter::{file,dir}()
The only two cases where PathCompleter was used were simple enough to be
replaced with clap::ValueHint directly (since statically know the type
of file to be completed). This also makes things more consistent given
that we use clap::ValueHint everywhere else.

The main difference between PathCompleter and ValueHint is that
PathCompleter requires dynamic completion, wheres ValueHint works in
static situations.
2025-08-24 03:13:45 +00:00
Ivan Petkov
09251f158a cli: complete destination paths for jj workspace add 2025-08-23 22:18:14 +00:00
Yuya Nishihara
7e80eb4dfa cargo: bump toml_edit to 0.23.3
Also updated deprecated ImDocument references to Document.
2025-08-23 03:46:11 +00:00
Yuya Nishihara
0367c96037 templates: simplify blank line insertion in default draft commit description
Since there exists at least one "JJ:" line, we no longer need to insert blank
line conditionally.
2025-08-22 04:53:02 +00:00
Hegui Dai
569ec5ddfe config: show IDs in draft description 2025-08-21 23:52:26 +00:00
Yuya Nishihara
a4cf4f2ae8 cli: evolog: migrate to evolution template type
This patch doesn't add builtin_evolog_redacted template because I'm not sure if
we want to collect evolution log for debugging purpose. The redacted template
can be added later if needed.
2025-08-21 13:35:21 +00:00
Yuya Nishihara
425b719045 templater: add CommitEvolutionEntry type
I don't have a strong feeling whether we should add "entry.commit() -> Commit"
method or forward method calls to the Commit object, but this patch implements
the former because:

 a. evolution_entry.diff() should return inter diff, whereas commit.diff()
    doesn't.
 b. auto-labeling works if self.commit() is an explicit method call.
 c. the implementation and documentation can be simple.

Tests will be added by the next patch.
2025-08-21 13:35:21 +00:00
Yuya Nishihara
b45336b900 templater: add operation types and methods to commit templater 2025-08-21 13:35:21 +00:00
Yuya Nishihara
da40d2199f templater: add Option<Operation> type to be used in evolution template 2025-08-21 13:35:21 +00:00
Martin von Zweigbergk
8864867226 cli: provide builtin_log_compact template as function too
This adds `builtin_log_compact(commit)` etc. and redefines
`builtin_log_compact` as `builtin_log_compact(self)`. That should make
it easier to reuse these functions e.g. in the the `jj evolog`
template.
2025-08-21 13:02:10 +00:00
Yuya Nishihara
a81d457018 templater: move build_method() of non-Core operation types to symbol table 2025-08-21 10:12:45 +00:00
Yuya Nishihara
a54763fac7 templater: extract non-Core operation property enum
.try_into_<eq|cmp>() are forwarded with Self and Core types because there may be
comparison operator between OperationId and String for example.
2025-08-21 10:12:45 +00:00
Yuya Nishihara
a774d79b5d templater: extract non-Core operation methods table 2025-08-21 10:12:45 +00:00
Yuya Nishihara
a8b6c0cba5 templater: rename language-specific operation template types
I'll extract non-"Core" operation types so they can be reused in the commit
templater.
2025-08-21 10:12:45 +00:00
Yuya Nishihara
62bd23adc9 templater: introduce abstraction over operation types and global context
This will allow us to use operation template types in the commit template.
OperationTemplateEnvironment and OperationTemplatePropertyVar correspond to
(a part of) TemplateLanguage and CoreTemplatePropertyVar respectively.
2025-08-21 10:12:45 +00:00
George Christou
d592653003 git fetch: add --tracked flag
Add `--tracked` flag to `jj git fetch` that fetches only tracked bookmarks
from the specified remote(s). This is symmetrical with the existing `jj git
push --tracked` functionality and is useful in large repositories where
fetching all bookmarks is slow, and manually specifying each tracked bookmark
is cumbersome.

Conflicts with `--branch` to avoid confusion. When no tracked bookmarks are
found for a remote, a warning is displayed and the remote is skipped.

Resolves #7209
2025-08-20 10:49:03 +00:00
Yuya Nishihara
d61be4cb8e cli: make all DiffRenderer methods async
There aren't many callers to do .block_on(). Let's propagate async-ness.
2025-08-20 01:38:45 +00:00
Yuya Nishihara
914903a90c cli: pass from/to_tree in to DiffRenderer as an array
We do this internally in order to reduce the number of arguments, and it seems
also good for public API.
2025-08-20 01:38:45 +00:00
Gaëtan Lehmann
1e58ca2253 squash: add -A/-B/-d options
For example, with a commit tree like this one:

@  kkrvspxk (empty) (no description set)
○  lpllnppl file4
│  A file4
○  xynqvmyt file3
│  A file3
○  wkrztqwl file2
│  A file2
○  mzuowqnz file1
│  A file1
♦  zzzzzzzz root()

we can jj squash -f x:: -d m to squash xynqvmyt and all its descendant
as a new commit onto mzuowqnz.

@  youptqqn (empty) (no description set)
○  wkrztqwl file2
│  A file2
│ ○  vsonsouy file3 file4
├─╯  A file3
│    A file4
○  mzuowqnz file1
│  A file1
♦  zzzzzzzz root()

On the implementation side, I've chosen to prepare the destination
commit before hand, and keep the squash algorithm mostly unmodified.
2025-08-19 11:38:55 +00:00
Yuya Nishihara
f6c43fa0d4 tests: restore --config* ordering sample from 15c673459f 2025-08-19 03:14:01 +00:00
Remo Senekowitsch
15c673459f cli: remove deprecated --config-toml flag 2025-08-18 17:37:43 +00:00
Remo Senekowitsch
2fe06ed45f template: remove deprecated Signature.username() method 2025-08-18 17:24:07 +00:00
Remo Senekowitsch
f339d1dd5a config: remove the deprecated git.auto-local-branch option 2025-08-18 17:00:08 +00:00
Remo Senekowitsch
92ad813085 undo: deprecate the operation argument
`jj undo` is planned to become a higher-level command that progressively
undoes more operations when executed repeatedly (in a strict order).
This will be separate from the lower-level semantics of `jj op revert`,
which reverts arbitrary operations on top of the current one. The
semantics of the new, high-level `jj undo` won't make sense when
combined with specifying a specific operation to undo. Thus, start the
lengthy deprecation period right now.

Related feature request "jj undo ergonomics":
https://github.com/jj-vcs/jj/issues/3700
2025-08-18 13:58:22 +00:00
Yuya Nishihara
8b522f073e tests: fix immutable working-copy tests to not snapshot config files 2025-08-18 10:37:42 +00:00
Remo Senekowitsch
6dc5d95e0d op: revert: fix missed string during rename from op undo
I only grepped for "undo", so "undid" slipped through the cracks.
2025-08-17 23:49:54 +00:00
Ivan Petkov
3cb62c1e51 cli: fix fetching all tags during jj git clone
By default, `git clone` will fetch all tags (same as `git clone
--tags`), but since we perform a clone by creating a remote first then
fetching it, we have to be a little smarter and keep track of when we're
doing a clone so that we ensure all tags are fetched.

`git clone --no-tags` will skip fetching tags at all, and so this is
also the now the behavior of `jj git clone --fetch-tags none`

Closes #4682
2025-08-17 15:48:36 +00:00
Ivan Petkov
b5b259ad97 cli: refactor test_git_clone_tags to include tags 2025-08-17 15:48:36 +00:00
Ivan Petkov
1df3c5d3b7 lib/git: support temporarily fetching all tags as part of a fetch
By default `git clone` will fetch all tags on a remote (unless
`--no-tags` is specified). Eventually we'll want to support the same
behavior, though since we first configure a remote and then fetch, we'll
need to configure the remote with the correct *general* tag fetching
behavior, but still perform the first fetch with all tags included.
2025-08-17 15:48:36 +00:00
Remo Senekowitsch
16ba92b497 undo: move or duplicate tests to op revert
`jj undo` and `jj op revert` used to be aliases. Now that their
semantics are planned to diverge, we need to think about which of the
existing tests belongs to which of the commands. Since `jj op revert`
will keep the current low-level semantics, all of the tests naturally
belong to it. `jj undo` will incrementally grow a new set of tests
together with its new, higher-level functionality. Some tests are
duplicated, in anticipation that they will be meaningful for `jj undo`
as well.

The moved tests are left as-is, except for any references to "undo" are
replaced by "revert" and invocations of `jj undo` are replaced by
invocations of `jj op revert`.
2025-08-17 15:05:14 +00:00
George Christou
bb9882fba1 cli: op show: add templates.op_show configuration 2025-08-17 13:16:55 +00:00
George Christou
e3b69cbfb4 cli: op show: add template support
Add `-T/--template` flag to `jj op show` to allow custom formatting of
output, matching the functionality available in `jj op log`.

Also add `--no-patch` flag to suppress the diff.

`templates.op_log` remains available as a config setting, used as a fallback
when `-T/--template` is not specified.

Resolves #6980
2025-08-17 13:16:55 +00:00
George Christou
5fedd36fd0 git init: prefer upstream over origin for trunk() alias
When both `origin` and `upstream` are present, prefer `upstream` over `origin`
as the default remote for the `trunk()` alias.

This allows developers working on forks to have `trunk()` automatically point
to the `main` branch of the upstream repository rather than their fork's
origin. This is common when using the `gh` CLI to set up repositories.

Resolves #7228
2025-08-17 11:59:17 +00:00
George Christou
b89cce9162 template: add any and all methods to lists
This allows checking whether "any" or "all" elements in a list satisfy a given
predicate, similar to Python's native `any()` and `all()` functions, but
instead as list methods that take lambda predicates.

These new methods follow the same pattern as existing `filter` and `map`
operations, i.e. taking a lambda that receives each item and must return a
boolean.
2025-08-16 11:28:35 +00:00
Yuya Nishihara
69115282ff cli: fold help comments of "jj undo"
We no longer have a reason to add separate help text to Command::Undo.
2025-08-16 06:21:25 +00:00
Remo Senekowitsch
36ee36ce78 op: undo: rename to revert
This paves the way for the semantics of `jj undo` and `jj op revert` to
evolve independently. `jj op revert` is going to stay the low-level
command to apply the inverse of any operation. The new name is
consistent with `jj revert`, which applies the inverse of a commit.

`jj undo` on the other hand is planned to become a higher-level command,
which is more similar to, say, Ctrl+Z in typical GUI applications.
Running `jj undo` repeatedly will revert progressively older operations,
allowing the user to walk backwards in time. At the same time, `jj undo`
will lose the abilitly to revert arbitrary operations, to keep its
semantics simple and intuitive.

Related feature request "jj undo ergonomics":
https://github.com/jj-vcs/jj/issues/3700
2025-08-15 21:31:15 +00:00
Remo Senekowitsch
687c4719db undo: turn alias into independent command
This paves the way for `jj undo` and `jj op undo` to evolve
independently. The planned changes revolve around making `jj undo` a
more high-level command and renaming `jj op undo` to `jj op revert`,
keeping the low-level semantics.

Related feature request "jj undo ergonomics":
https://github.com/jj-vcs/jj/issues/3700
2025-08-15 21:31:15 +00:00
Yuya Nishihara
2dd5934c74 cli: add debug command to enable changed-path index
Maybe we should add a config knob to enable changed-path index, do indexing in
background, etc., but I don't have a concrete idea.

Closes #4674
2025-08-15 11:46:49 +00:00
Gaëtan Lehmann
8a9c356f5e touch: add an option to generate a new change-id 2025-08-14 17:36:20 +00:00
Gaëtan Lehmann
8bc11f272c touch: add options to modify author and author timestamp 2025-08-14 17:36:20 +00:00
Gaëtan Lehmann
de74f88cfc touch: a command to modify some revision metadata 2025-08-14 17:36:20 +00:00