Commit graph

429 commits

Author SHA1 Message Date
Ilya Grigoriev
e5cfada7e2 test_abandon_command: remove obsolete TODO
This was fixed in 7c8f66ab0, I believe.
2023-11-19 16:37:49 -08:00
Łukasz Kurowski
e21ffb0139 merge_tools: use left_file_mode in make_diff_files
The `scm-record` library comments say that the `file_mode` is:
> The Unix file mode of the file (before any changes), if available.

This reverts commit ffd6884 and fixes #2591 and #2548.
2023-11-19 22:41:23 +01:00
Ilya Grigoriev
0357915778 cli: move make_branch_term out of commands/mod.rs
It is now out of place in mod.rs. It is only used in two places, so
I copied it to each of them.

Follows up on @AntoineCezar 's work.
2023-11-18 12:21:36 -08:00
Ilya Grigoriev
af81cbd942 cli: make dummy revert command accept any arguments
Before, `jj revert qq` would say that `qq` is an extraneous argument.
Now, it says "Error: No such subcommand: revert".
2023-11-18 10:25:53 -08:00
Ilya Grigoriev
1c5d0e0d63 cli: adjust error message for dummy revert command 2023-11-18 10:25:53 -08:00
Martin von Zweigbergk
c2d5e3d343 clippy: fix new issues spotted by nightly version 2023-11-16 10:20:07 -08:00
Benjamin Saunders
2526620f82 cli: Suggest jj backout or jj restore in place of jj revert 2023-11-14 15:35:13 -08:00
Yuya Nishihara
6c98dfcdcb git: have import_refs() obtain git2::Repository instance from store
This helps gitoxide migration. It's theoretically possible to import Git refs
from non-Git backend, but I don't think such API flexibility is needed.
2023-11-14 17:35:27 +09:00
Yuya Nishihara
8e143541a5 operation: propagate OpStoreError from parents()
We need to .collect_vec() the parents iterator to temporary buffer since the
borrowed iterator can't be returned back to the dag_walk functions. Another
option is to clone op_store and parent ids to remove &self lifetime from the
iterator, but that also means a temporary Vec is created.
2023-11-14 07:16:39 +09:00
Yuya Nishihara
3f5e5994eb cli: use op.parent_ids() where operation object isn't needed 2023-11-14 07:16:39 +09:00
Łukasz Kurowski
ffd688472e merge_tools: use right_file_mode in make_diff_files
See the issue #2548 for more context.
2023-11-12 00:36:34 +01:00
Yuya Nishihara
ea32c0cb9e git_backend: pass UserSettings to GitBackend constructors 2023-11-11 22:35:54 +09:00
Yuya Nishihara
8a2048a0e5 repo: pass UserSettings to store factories and initializers
GitBackend will use it to configure gix::Repository. I think UserSettings
is generally useful to pass store-specific parameters, so I've updated all
factory functions.
2023-11-11 22:35:54 +09:00
Yuya Nishihara
0251c9fe51 cli: propagate read_operation() errors
This is easy one. op.parents() can still panic, which would be a bit more
involved to fix.

#2549
2023-11-11 22:35:40 +09:00
Yuya Nishihara
4ab8a1ae6e cli: flatten check_stale_working_copy() result
I'll make it propagate OpStoreError, but OpStoreError is quite different
from the existing StaleWorkingCopyError. I think this error isn't actually
an "error" but a description of the working copy state.
2023-11-11 22:35:40 +09:00
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