Commit graph

414 commits

Author SHA1 Message Date
Yuya Nishihara
6125fb160e op_store: embed details in operation/view not found error
This is basically a copy of BackendError::ObjectNotFound. The failed id may
be either view or operation id.
2023-11-11 22:35:40 +09:00
Yuya Nishihara
9533177422 cli: include branch name in non-fast-forwardable error
Just like the other errors.
2023-11-11 07:03:31 +09:00
Yuya Nishihara
8706fadca1 cli: inline check for non-fast-forwardable branch move
The caller knows whether the branch is present or not.
2023-11-11 07:03:31 +09:00
Yuya Nishihara
27751b0142 tests: add test for moving conflicting branch to one of descendants 2023-11-11 07:03:31 +09:00
Yuya Nishihara
0d21578846 cli: disallow to create new branch by "jj branch set"
Per discussion in https://github.com/martinvonz/jj/discussions/2555. I'm
okay with either way, but it's confusing if we had "branch create" and
"branch set" and both of these could create a new branch.
2023-11-11 07:03:31 +09:00
Yuya Nishihara
aca2a3cf93 tests: don't create new branch by "jj branch set" 2023-11-11 07:03:31 +09:00
Martin von Zweigbergk
bf36933d9d diff_utils: return &str from basic_diff_file_type()
We don't currently need an owned `String`.
2023-11-10 11:08:43 -08:00
Martin von Zweigbergk
ffbfd74108 cli: pass MaterializedTreeValue into diff_content()
Another little preparation for reading the materialized values
concurrently.
2023-11-10 04:54:47 -08:00
Martin von Zweigbergk
120115a20d cli: pass MaterializedTreeValue into git_diff_part()
Just a little preparation for reading the materialized values
concurrently.
2023-11-10 04:54:47 -08:00
Łukasz Kurowski
57d7aeab5e cli: generate commit template after selecting changes
Renamed `description_template_for_commit` to
`description_template_for_describe` since it's only used in
`cmd_describe`.

Renamed `description_template_for_cmd_split` to
`description_template_for_commit` and modified to accomodate empty
`intro` argument.

Fixes #2439.
2023-11-09 15:10:25 +01:00
Yuya Nishihara
e2fd309d28 cli: reorder check of branch create/set arguments so they look similar
I think it's better to not emit "multiple branches" warning if we refuse to
move branches.
2023-11-09 15:38:22 +09:00
Yuya Nishihara
e880976deb cli: simplify check for conflicting branch name to create
There's no need to collect args.names into new Vec.
2023-11-09 15:38:22 +09:00
Yuya Nishihara
70479a712b cli: include branch names in bulk branch creation/update warning
This will probably help notice missing -r flag. Maybe we can also warn if
one of the branch names looks like a revset.

https://github.com/martinvonz/jj/discussions/2555
2023-11-09 15:38:22 +09:00
Yuya Nishihara
a6aa8aa4f4 tests: add test for moving branch forward and backward 2023-11-09 15:38:22 +09:00
Martin von Zweigbergk
b11f7eee1b diff_utils: pass tree value into diff_content() by value
Avoids a few calls to `.clone()`.
2023-11-08 21:21:38 -08:00
Martin von Zweigbergk
9b24d24612 conflicts: add another helper for materializing a tree value
We have a few places where we have a `MergedTreeValue` and need to
read the data associated with it so we can write to the working copy
or include it in a diff. Let's extract some of that shared logic to a
function so we can reuse it. I plan to use it for reading file
contents in advance while streaming a diff in `local_working_copy`
soon (and probably in `jj diff` thereafter), but I think it seems like
an improvement on its own.
2023-11-08 21:21:38 -08:00
Anton Bulakh
d27351b978 misc: drop a few low-hanging unsafes
Remove a couple of unnecessary unsafes:
- The NonZeroUsize is a constant where the unwrap will optimize away
anyway and we don't have an unsafe without any good reason there :)
- The other two were simply not needed, lifetimes worked fine, maybe
Rust became better since that code was written? NLL? Anyway, they're
gone now
2023-11-08 02:16:08 +02:00
Yuya Nishihara
2ac9865ce7 revset: exclude @git branches from remote_branches()
As discussed in Discord, it's less useful if remote_branches() included
Git-tracking branches. Users wouldn't consider the backing Git repo as
a remote.

We could allow explicit 'remote_branches(remote=exact:"git")' query by changing
the default remote pattern to something like 'remote=~exact:"git"'. I don't
know which will be better overall, but we don't have support for negative
patterns anyway.
2023-11-08 07:34:30 +09:00
Yuya Nishihara
59640496aa cargo: sort dependencies list alphabetically 2023-11-07 23:46:05 +09:00
Yuya Nishihara
dd26b7be40 merge: add Merge constructor that accepts interleaved values
Also migrated some callers of 3-way merge, where [left, base, right] order
looks okay.
2023-11-07 17:10:12 +09:00
Martin von Zweigbergk
d989d4093d merged_tree: let backend influence whether to use new diff algo
Since the concurrent diff algorithm is significantly slower when using
the Git backend, I think we'll have to use switch between the two
algorithms depending on backend. Even if the concurrent version always
performed as well as the sequential version, exactly how concurrent it
should be probably still depends on the backend. This commit therefore
adds a function to the `Backend` trait, so each backend can say how
much concurrency they deal well with. I then use that number for
choosing between the sequential and concurrent versions in
`MergedTree::diff_stream()`, and also to decide the number of
concurrent reads to do in the concurrent version.
2023-11-06 23:12:02 -08:00
Yuya Nishihara
e4b0e629c9 merge_tools: borrow file contents without consuming Merge object 2023-11-07 06:52:35 +09:00
Yuya Nishihara
895bbce8c0 files: use borrowed Merge iterator in merge()
Since the underlying Merge data type is no longer (Vec<T>, Vec<T>), it doesn't
make sense to build removes/adds Vecs and concatenate them.
2023-11-07 06:52:35 +09:00
Antoine Cezar
afc2382833 cli: move description utils to description_util.rs 2023-11-06 17:49:02 +01:00
Yuya Nishihara
f1898a31b5 merge: simply print interleaved conflict values in debug output
We could apply that for the resolved case, but Resolved/Conflicted label
seems more useful than just printing Merge([value]).
2023-11-06 07:21:06 +09:00
Yuya Nishihara
b07b370ed3 merge: simply generate content hash from interleaved values 2023-11-06 07:21:06 +09:00
Yuya Nishihara
d8a7822c38 merge_tools: do not follow or change permission of symlinks
Fixes #2525.
2023-11-06 07:20:52 +09:00
Martin von Zweigbergk
7c923514ee git: add config to disable abandoning of unreachable commits
Some users prefer to have commits not get abandoned when importing
refs. This adds a config option for that.

Closes #2504.
2023-11-05 06:10:54 -08:00
Yuya Nishihara
d9fbf21794 merge: have Merge::adds()/removes() return iterator
The Merge type will be changed to store interleaved values internally.
2023-11-05 16:43:06 +09:00
Martin von Zweigbergk
5b02987012 merge tools: use MergedTree::diff_stream() 2023-11-04 21:07:49 -07:00
Yuya Nishihara
602b44258e workspace: add function that initializes colocated git repository
One less git2 API use in CLI.

The function name GitBackend::init_colocated() is a bit odd, but we need to
specify the work-tree path, not the ".git" repo path. So we can't eliminate
the notion of the working copy path anyway.
2023-11-05 08:48:35 +09:00
Philip Metzger
8e4b6dfeaa run: Teach run to resolve revsets and about jobs.
This also adds `jobs`, the argument reading the thread count to use and `shell_command`.
While we're at it, make `execute` a no-op and teach `run` to resolve the passed revsets. 
I also fixed my misunderstanding of `Clap` which makes 
`jj run 'echo hello world' -r 'mine() & ~origin@remote' --jobs 4` parse correctly. 

Also contains a small fix in the `pre-commit` example for it.
2023-11-04 16:29:06 +01:00
Austin Seipp
17bcac6838 cli: move resolve_destination_revs to cli_utils and rename
Summary: This is currently used by `new.rs`, `workspace.rs`, and `rebase.rs`,
and may be useful for other commands and custom CLIs. So just go ahead and move
it into the parent module hierarchy.

Also rename the function to `resolve_all_revs`, as it isn't actually specific to
rebase at all.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I0ea12afd8107f95a37a91340820221a0
2023-11-04 10:26:08 -05:00
Austin Seipp
e1193db4cf cli: support multiple --revision arguments to workspace add
Summary: A natural extension of the existing support, as suggested by Scott
Olson. Closes #2496.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I91c9c8c377ad67ccde7945ed41af6c79
2023-11-04 10:26:08 -05:00
Antoine Cezar
5973ab47b9 commands: move rebase_to_dest_parent to jj_lib::rewrite
What make rebase_to_dest_parent a good candidate for jj_lib::rewrite module:

- It is used both in obslog and interdiff. It's a sign that it may be moved to a lower layer
- CommandError is returned by converting from TreeMergeError. Not explicitly.
- It only use jj_lib::rewrite fonctions.
2023-11-03 20:48:00 +01:00
Martin von Zweigbergk
72245cfac5 merged_tree: add Stream-based version of diff(), delegating for now
I'm going to implement a `Stream`-based version optimized for
high-latency (RPC-based) commit backends. So far, that implementation
is about 20% slower in the Linux repo when running `jj diff
--ignore-working-copy -s --from v5.0 --to v6.0`. I think that's almost
only because the algorithm is different, not because it's async per
se.

This commit adds a `Stream`-based version of `MergedTree::diff()` that
just wraps the regular iterator in stream. I updated `jj diff` to use
it. I couldn't measure any difference on the command above in the
Linux repo. I think that means we can safely use the same
`Stream`-based interface regardless of backend, even if we end up
needing two different implementations of the `Stream`. We would then
be using the wrapped iterator from this commit for local backends, and
the new implementation for remote backends. But ideally we can make
the remote-friendly implementation fast enough that we don't need two
implementations.
2023-11-03 08:15:10 -07:00
Martin von Zweigbergk
24b706641f async: switch to pollster's block_on()
During the transition to using more async code, I keep running into
https://github.com/rust-lang/futures-rs/issues/2090. Right now, I want
to convert `MergedTree::diff()` into a `Stream`. I don't want to
update all call sites at once, so instead I'm adding a
`MergedTree::diff_stream()` method, which just wraps
`MergedTree::diff()` in a `Stream. However, since the iterator is
synchronous, it needs to block on the async `Backend::read_tree()`
calls. If we then also block on the `Stream` in the CLI, we run into
the panic.
2023-11-03 08:15:10 -07:00
Antoine Cezar
b7c480a575 commands: move show_predecessor_patch code to obslog.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
5d45bd194a commands: move workspace code to workspace.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
9e462509f8 commands: move version code to version.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
04eddc666c commands: move untrack code to untrack.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
9d72fa2a51 commands: move unsquash code to unsquash.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
8bb0383ad5 commands: move util code to util.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
abe658d966 commands: move status code to status.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
116214a79d commands: move squash code to squash.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
38898336a0 commands: move split code to split.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
6d0633443b commands: move sparse code to sparse.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
8f09fcc434 commands: move show code to show.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
6ae2e4c54f commands: move run code to run.rs 2023-11-03 04:45:55 +01:00
Antoine Cezar
e2336728da commands: move restore code to restore.rs 2023-11-03 04:45:55 +01:00