ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

464 commits

Author SHA1 Message Date
Ilya Grigoriev
48d586cba0 test_abandon_command: create another test for bug 2600
See comments inline for details. Cc #2600.

In particular, I wanted to make sure these behaviors are not affected by #2646.
They don't seem to be.

The tests ended up weirder than expected because of
https://github.com/martinvonz/jj/issues/2600#issuecomment-1835418824. Even
though, right now, the behavior of tests is unaffected by that issue, the
*expected* behavior is different.
2023-12-01 17:03:44 -08:00
Ilya Grigoriev
0634dc5674 test_abandon_command: show change ids in get_log_output
Branches move around a little confusigly with `abandon`. We do want to keep
them, to test their behavior, but we can show the change id to make things
clearer.
2023-12-01 17:03:44 -08:00
Martin von Zweigbergk
a0cbe7ced0 cli: rename *Commands enums to *Command
Each instance of the enum represents a single command, so singular
`*Command` seems better. That also seems to match the examples in
clap's documentation.
2023-12-01 16:53:54 -08:00
Martin von Zweigbergk
4aad7f86ac commands: rename various *matches variables to *args
I think the `*matches` names are leftovers from before we used clap's
Derive API.
2023-12-01 16:53:54 -08:00
Yuya Nishihara
d747879aee signing: pass SigningFn by reference
write_commit() doesn't need ownership of the signing function.
2023-12-01 22:55:04 +09:00
Anton Bulakh
eb1c0ab4a2 sign: Implement a test signing backend and add a few basic tests 2023-11-30 23:36:56 +02:00
Anton Bulakh
d7229a3f90 sign: Define signing backend API and integrate it
Finished everything except actual signing backend implementation(s) and
the UI.
2023-11-30 23:36:56 +02:00
Ilya Grigoriev
bb72def464 cli rebase: tests for weird ancestry for -s and -b 2023-11-28 21:36:51 -08:00
Ilya Grigoriev
22abbbea9b cli rebase -r: add tests for weird ancestry, record a bug, fix a comment
Note that one of the new tests panics; this is a newly discovered bug.

In Git, a commit's direct parent is allowed to also be an indirect ancestor
at the same time. `jj` currently tries to prevent this situation, but does
allow it. The correctness of `rebase -r A -d descendant_of_A` currently depends
on this jj-specific behavior; we should change that.

Cc #2600
2023-11-28 21:36:51 -08:00
Chris Krycho
b4caef7fe0 cli: do not allow jj init --git in existing Git repo
Allowing `jj init --git` in an existing Git repo creates a second Git
store in `.jj/repo/store/git`, totally disconnected from the existing
Git store. This will only produce extremely confusing bugs for users,
since any operations they make in Git will *not* be reflected in the
jj repo.
2023-11-28 17:31:54 -06:00
Ilya Grigoriev
3e96bf5372 clippy: fix a nightly clippy warning 2023-11-27 16:35:47 -08:00
Yuya Nishihara
28ab9593c3 repo_path: split RepoPath into owned and borrowed types
This enables cheap str-to-RepoPath cast, which is useful when sorting and
filtering a large Vec<(String, _)> list by using matcher for example. It
will also eliminate temporary allocation by repo_path.parent().
2023-11-28 07:33:28 +09:00
Yuya Nishihara
0a1bc2ba42 repo_path: add stub RepoPathBuf type, update callers
Most RepoPath::from_internal_string() callers will be migrated to the function
that returns &RepoPath, and cloning &RepoPath won't work.
2023-11-28 07:33:28 +09:00
Yuya Nishihara
d322df0c8d matchers: make Files/PrefixMatcher constructors accept slice of borrowed paths
RepoPath will become slice type (like str), and it doesn't make sense to
require &[RepoPathBuf] here.
2023-11-28 07:33:28 +09:00
Ilya Grigoriev
6aef4bb52e cli rebase: do not allow -r --skip-empty
This follows up on 3967f63 (see that commit's description for more
motivation) and e79c8b6.

In a discussion linked below, it was decided that forbidding `-r --skip-empty`
entirely is preferable to the mixed behavior introduced in 3967f63.

3967f637dc (commitcomment-133539911)
2023-11-27 10:16:36 -08:00
Yuya Nishihara
55f75278bc repo_path: make to_internal_file_string() return &str, rename accordingly 2023-11-27 08:42:09 +09:00
Ilya Grigoriev
3967f637dc cli rebase: do not allow -r --skip-empty to drop emptied descendants
This follows up on @matts1 's #2609.

We still allow the `-r` commit to become empty. I would be more comfortable if
there was a test for that, but I haven't done that (yet?) and it seems pretty
safe. If that's a problem, I'm happy to forbid `-r --skip-empty` entirely,
since it is far less useful than `-s --skip-empty` or `-b --skip-empty`.

I think it is undesired to abandon emptied descendants. As far as descendants
of `A` are concerned, `jj rebase -r A` should be equivalent to `jj abandon A`,
and `jj abandon` does not remove emptied commits. It also doesn't seem very
useful to do that, since I think descendant commits of an abandoned (or moved
with `-r`) commit only become empty in pathological cases.

Additionally, if we did want -r to empty descendants of `A`, we'd have to add
thorough tests and possibly improve the algorithm. I want to refactor `rebase
-r` and add features to it, and having to consider cases of commits becoming
abandoned makes everything harder.

For example, if we have

```
root -> A -> B -> C
```

and `jj rebase -r A -d C` empties commit `B` (or `C`), I do not know whether
the current algorithm will work correctly. It seems possible that it would, but
that depends on the fact that empty merge commits are not abandoned for
descendants. That seems dangerous to rely on without tests.

I hope (but can't promise) that in the near future, making DescendantRebaser
return more information  should help make it possible to create such
functionality in a more robust way. I am likely to attempt this as part of
implementing `-r --after`.
2023-11-26 10:56:58 -08:00
Philip Metzger
c78425cf65 run: Fix up various things.
Adress the post-merge comments from #2486, which found a doc comment
inaccurate and to not blindly ignore `-j 0` which would've worked until now.
I've also reduced the default `jobs` size to one, as it's user-visible configuration
which determines how many processes should run.

Thanks to @necauqua the controversial `unsafe` usage was already removed.

I've omitted to change `revisions` from an Vec to a RevisonArg for the moment, 
as I will keep working on the file anyway.
2023-11-26 15:13:41 +01:00
Ilya Grigoriev
95949e8011 test_abandon_command: rename test 2023-11-25 21:36:35 -08:00
Yuya Nishihara
4f2503cbce cli: show hint of non-tracking remote branches on "jj init --git-repo"
If the existing git repo contains local and remote branches of the same name,
one of the remote branches is probably a tracking remote branch. Let's show
a hint how to set up tracking branches. The tracking state could be derived
from .git/config, but doing that automatically might cause another issue like
#1862, which could have been mitigated by git.auto-local-branch = false.
2023-11-25 16:46:10 +09:00
Martin von Zweigbergk
550164209c revset: add a RevsetExpression::evaluate_programmatic()
We often resolve a programmatic revset and then immediately evaluate
it. This patch adds a convenience method for those two steps.
2023-11-24 21:13:58 -10:00
Martin von Zweigbergk
f2602f78cf revset: make resolve_programmatic() not return a Result
I think it's always a programming error if `resolve_programmatic()`
returns a `Result`, so it shouldn't have to return a `Result`.
2023-11-24 21:13:58 -10:00
Martin von Zweigbergk
f27f52984e revset: rename resolve() to resolve_programmatic()
`RevsetExpression::resolve()` is meant for programmatically created
expressions. In particular, it may not contain symbols. Let's try to
clarify that by renaming the function and documenting it.
2023-11-24 21:13:58 -10:00
Matt Stark
e79c8b6f62 cli: Add a --skip-empty flag to rebase 2023-11-24 14:48:06 +11:00
Matt Stark
0a95e20ebe lib: Implement skipping of empty commits 2023-11-24 14:48:06 +11:00
Anton Bulakh
5c3c0e9f6e sign: Implement generic commit signing on the backend 2023-11-23 22:52:20 +02:00
Ilya Grigoriev
811ac5ff23 cli new: have --no-edit print description of the new commit 2023-11-23 11:15:38 -08:00
Ilya Grigoriev
e33f57a0f5 cli new: add --no-edit option
This allows, for example, creating a merge commit with `jj new a b --no-edit -m Merge`, without
affecting the working copy.
2023-11-23 11:15:38 -08:00
Ilya Grigoriev
aa08de30c7 cli new: Make -r, --before, and --after repeatable
Repeating these is a no-op. This allows:

```shell
jj new -r a -r b # Equivalent to jj new a b
jj new --before a --before b  # Equivalent to jj new a b --before
```

I keep typing the latter and getting an annoying error.
2023-11-23 11:15:38 -08:00
Ilya Grigoriev
ea22f90018 cli editor and pager: Add a comment
Follows up on 13c93d5270.

The information I added is explained in that commit's description, but
I feel like it could reduce confusion for future readers of the code.
2023-11-22 23:36:16 -08:00
Yuya Nishihara
13c93d5270 cli: show executable name in error message, include underlying error details
Since this is the error to spawn (or wait) process, command arguments aren't
important. Let's make that clear by not showing full command string.

#2614
2023-11-23 10:05:45 +09:00
Yuya Nishihara
31def4b131 cleanup: don't use debug format to print source errors 2023-11-23 10:05:37 +09:00
Ilya Grigoriev
d8df36b9a2 cli diff help: add detailed explanation of -r merge_commit 2023-11-20 20:40:01 -08:00
Ilya Grigoriev
e3852ffd55 cli diff: add short description to jj help and jj diff -h 2023-11-20 20:40:01 -08:00
Ilya Grigoriev
22ad4d7599 test_abandon_command: test avoidance of simultaneous direct and indirect descendants
This is similar to the following test:

5186066cf5/cli/tests/test_rebase_command.rs (L264-L269) 

from https://github.com/martinvonz/jj/pull/538.
2023-11-19 16:37:49 -08:00
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