Commit graph

487 commits

Author SHA1 Message Date
jyn
0d3e949439 give a warning when trying to redefine a built-in command
previously, aliases to built-in commands were silently ignored. this matches git's behavior, but seems unhelpful, especially if the user doesn't know that a command with that name already exists.
give a warning rather than silently ignoring it.
2024-05-17 16:50:54 +01:00
Théo Daron
0a48ac63cb cli: make jj branch track show conflicts 2024-05-17 12:21:10 +02:00
Théo Daron
823041c795 cli: create new wc_commit when wc_commit become immuable 2024-05-14 08:53:11 +02:00
Yuya Nishihara
b0d17acb30 merge_tools: leverage Display for printing exit status
This should handle signal exits better. format_tool_aborted() is inlined
because it is more or less a string literal now.
2024-05-14 10:24:28 +09:00
tinger
d0a29a831d cli: add ui.color = "debug"
When using `ui.color = "debug"`, changes in the output style
additionally include delimiters << and >>, as well as all active labels
at this point separated by ::. The output is otherwise unformatted and
the delimiters and labels inherit the style of the content they apply
to.
2024-05-11 10:16:09 +02:00
Yuya Nishihara
d6613304c9 cli: print deleted branch hints at end of "branch list" output
These hints shouldn't be interleaved in the template output. The new output
might look a little bit worse, but I don't think it's unacceptably bad.
2024-05-11 09:43:53 +09:00
Yuya Nishihara
2f3ac4e4d7 tests: snapshot both stdout and stderr in "branch list" tests 2024-05-11 09:43:53 +09:00
Yuya Nishihara
60825c4591 tests: use get_branch_output() at a few more places
Not all "branch list --all-remotes" callers are replaced because I'm going to
make get_branch_output() suppress hints by default, and there should be tests
for the hints.
2024-05-11 09:43:53 +09:00
Alexander Potashev
07559f24ec Refuse to split an empty commit with jj split.
Rationale: The user may be confused by the empty diff in the diff editor
tool if they accidentally run `jj split` on a wrong (empty) commit.
2024-05-10 19:37:28 +02:00
Yuya Nishihara
3307696ba8 cli: parse out redundant "all:" revset modifier in arguments and templates
This also means "all:" is allowed in default revsets (such as "revsets.log"),
but that seems okay. In revset aliases, "all:" isn't allowed because aliases
may be expanded to sub-expression position.

Closes #3654
2024-05-10 15:28:18 +09:00
Yuya Nishihara
12b873e1ef cli: port "branch list" to template
Perhaps, this can be used to generate parsable branches list.

The hint for deleted branches isn't migrated to the template. I'm thinking of
moving it out of the loop and printed once at the end. If we want to generate
a hint in template, we'll probably need local_ref.tracking_remote_refs(), etc.
that return a list of RefNames.
2024-05-10 08:36:38 +09:00
Yuya Nishihara
8e4f75552d templater: add tracking methods to remote RefName
More tests will be added later as "branch list" templates.

In "log" template, we might want to see the number of "local" commits ahead
of any tracked remotes. It can be implemented later in a similar way (or as a
nested remote_refs list.)
2024-05-10 08:36:38 +09:00
Yuya Nishihara
c2c160f635 templater: add helper method that unwraps Option<T> property
I'll add a few more optional property types, and I don't want to duplicate the
error message. Type names are capitalized for consistency.
2024-05-09 08:51:34 +09:00
Ilya Grigoriev
2760b23f8d cli jj util completion --help: Make the terminal output a bit prettier
Cc: https://github.com/martinvonz/jj/pull/2949#issuecomment-2098710774
2024-05-08 11:40:54 -07:00
Ilya Grigoriev
70b517ca64 conflicts.rs: label conflict number and sides next to conflict markers
For example, 

```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```

or

```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```

Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.

Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.

While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.

I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.

Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-05-05 18:42:14 -07:00
Ilya Grigoriev
2f48f76e85 test_resolve_command: use diff --git for readability 2024-05-05 18:42:14 -07:00
Yuya Nishihara
f1fd1d8071 cli: show hint for inner fileset/revset/template errors
Note that find_source_parse_error_hint() has recursion, but it should terminate
because err.source() shouldn't have a cycle.
2024-05-05 11:16:17 +09:00
Ilya Grigoriev
5322c1d2bf cli --ignore-immutable help: remove double negative 2024-05-03 15:50:17 -07:00
Charles Crete
4b215a3405 docs: update obslog description 2024-05-03 12:06:32 -04:00
Charles Crete
c1de6eaa81 docs: mention origin of obslog name 2024-05-03 12:06:32 -04:00
Yuya Nishihara
0d630ac1bc cli: show commit summary in "tag list"
This is basically a template version of print_branch_target().
2024-05-03 15:16:52 +09:00
Yuya Nishihara
4db068e7f7 templater: expose RefTarget methods through RefName type
I considered adding RefTarget template type, but some of the methods naturally
fit to RefName. For example, a conflicted branch name is decorated as "??", so
it makes sense to add branch.conflict() instead of branch.target().conflict().

I'm not pretty sure how many RefName methods we'll need to add to port the
current branch listing, but there will be .tracked(), .tracking_local_present(),
.ahead_by(), and .behind_by().
2024-05-03 15:16:52 +09:00
Yuya Nishihara
520b4db919 cli: colorize tag name in "tag list" output
"working_copy tag" wouldn't be needed, but is added for consistency.
2024-05-03 15:16:52 +09:00
Yuya Nishihara
1ce3e9fe44 cli: migrate "tag list" to template
I'm going to add more detailed output there. This is a step towards "branch
list" template. "tag list -T" wouldn't be that useful, but it shares primitives
with "branch list -T".
2024-05-03 15:16:52 +09:00
Yuya Nishihara
d1458b55d2 tests: simplify local repo setup in test_tag_list()
I'll update the test to include conflicted tag, which can't be easily set up
by fetching from remote.
2024-05-03 15:16:52 +09:00
Alexis (Poliorcetics) Bourget
52e494dcf2 cli: status: when current change has conflicts, display instructions to resolve them 2024-05-01 15:59:12 +02:00
Martin von Zweigbergk
0d1ff8a150 merged_tree: propagate errors from TreeEntriesIterator
We shouldn't panic if we fail to read a tree from the backend.
2024-05-01 06:10:08 -07:00
Martin von Zweigbergk
7093d5d359 squash: don't use unchanged source commit as predecessor 2024-04-30 20:03:57 -07:00
Martin von Zweigbergk
09b960538a squash: don't rewrite commits that didn't change
Closes #3334
2024-04-30 20:03:57 -07:00
Martin von Zweigbergk
8c2c319f77 squash: add more tests of no-op squashing
We didn't have any tests with `jj squash` with multiple source commits
and no matching paths.
2024-04-30 20:03:57 -07:00
Benjamin Tan
f1f84544fb rebase: do not print out commit summaries of skipped commits 2024-05-01 01:35:25 +08:00
Noah Mayr
dc693e7b8f template: add contained_in method to commit object in templates
this allows to conditionally display or label elements depending on 
whether the given commit is contained within the revset
2024-04-29 12:16:42 +02:00
Benjamin Tan
0e2e09a593 rebase: allow both --insert-after and --insert-before options to be used simultaneously 2024-04-29 14:19:09 +08:00
Benjamin Tan
f75461efc1 rebase: add --insert-after and --insert-before options for --revisions 2024-04-29 14:19:09 +08:00
Benjamin Tan
714bc0a9e6 rebase: add move_commits function to perform rebasing
The `move_commits` function accepts a set of target commits to shift to
a new location given by `new_parents` and `new_children`. The roots of
the target set will be reparented onto `new_parents`. `new_children`
will then be reparented onto the heads of the target set.

The commits will be rebased in reverse topological order based on the
new set of parents of each commit, which avoids the need for multiple
sets of rebase operations.
2024-04-29 14:19:09 +08:00
Martin von Zweigbergk
492dd99ba5 squash: add test that immutable commits are respected for --from/--into 2024-04-28 13:06:37 -07:00
Martin von Zweigbergk
9503179ea4 tests: avoid a use of deprecated jj move 2024-04-28 11:12:51 -07:00
Benjamin Tan
6752402113 rebase: allow -r to accept multiple revisions 2024-04-26 23:51:52 +08:00
Martin von Zweigbergk
d13be927a8 cli: add global --ignore-immutable
Closes #3576
2024-04-26 06:13:15 -07:00
Yuya Nishihara
2bd6983003 templates: reimplement builtin_change_id_with_hidden_and_divergent_info alias
This helps extract commit_summary template as an alias function.
2024-04-26 16:56:35 +09:00
Yuya Nishihara
a63dbcc329 templater: include actual type name in error messages 2024-04-26 00:57:26 +09:00
Rowan Walsh
f185a838d7 Fixes typo in 'jj git init' args 2024-04-24 09:12:37 -07:00
Martin von Zweigbergk
9d7ed54f8e git_backend: add a README to conflicted commits
When you use e.g. `git switch` to check out a conflicted commit,
you're going to end up with the `.jjconflicts-*` directories in your
working copy. It's probably not obvious what those mean. This patch
adds a README file to the root tree to try to explain to users what's
going on and how to recover.

The authoritative information about conflicts is stored in the
`jj:trees` commit header. The contents of conflicted commits is only
used for preventing GC. We can therefore add contents to the tree
without much consequence.
2024-04-22 06:22:54 -07:00
Benjamin Tan
e14ee8b563 rebase: do not simplify ancestor merges 2024-04-22 21:05:49 +08:00
Benjamin Tan
3ee35e70e9 rebase: modify tests to avoid a future ancestor merge with root commit
I will be updating `rebase -r` to avoid simplifying ancestor merges in a
subsequent commit, which will cause existing tests to fail for the Git
backend due to ancestor merges with the root commit.
2024-04-22 21:05:49 +08:00
Benjamin Tan
fb7c91ffa8 rebase: rewrite rebase_revision to use transform_descendants 2024-04-22 21:05:49 +08:00
Evan Mesterhazy
a2c49abbbe Add short a -e alias for --edit to prev and next
I'm not sure if this was an intentional omission, but I think it would be
useful to have `-e` as a short flag for `--edit`. I don't usually edit commits,
but I do use `prev` and `next` with edit to navigate to a commit that I want to
squash. Often this is easier than typing `--from` and `--into` plus the change
IDs.

If people want to edit commits we shouldn't stand in their way.
2024-04-21 13:58:38 -04:00
Evan Mesterhazy
e0c53bcfc0 Rewrite rebasing in jj split using transform_descendants()
This is following on the rewrite for `parallelize`.

- https://github.com/martinvonz/jj/pull/3521

Since rebase_descendants from rebase.rs is no longer used outside of that file,
it can be made private again.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
6d2884317a Add checks for stderr and stdout to jj split tests
This would have caught a bug in https://github.com/martinvonz/jj/pull/3550
that otherwise might have slipped through.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
0fb582ed8f Implement advance-branches for jj new 2024-04-20 10:26:04 -04:00