Commit graph

1085 commits

Author SHA1 Message Date
dploch
20af8c79ef revset: support custom filter extensions 2024-05-06 10:42:01 -04:00
dploch
387ae9bce1 revset: support defining custom revset functions 2024-05-06 10:42:01 -04:00
dploch
4e0abf0631 revset: make RevsetParseContext opaque 2024-05-06 10:42:01 -04: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
Ilya Grigoriev
04158c3744 External merge tools: better error message for unsupported usage
I've heard of one instance of a person being confused by the error.

Previously, the error was:

```
Error: Failed to load tool configuration
Caused by: To use `diffedit3` as a merge tool, the config `merge-tools.diffedit3.merge-args` must be defined (see docs for details)

```

Now, it is:

```
Error: The tool `diffedit3` cannot be used as a merge tool with `jj resolve`.
Hint: To use `diffedit3` as a merge tool, the config `merge-tools.diffedit3.merge-args` must be defined (see docs for details)
```

TODO for future PR: allow setting `merge-tools.TOOL.edit-args = false` so that
attempting to use TOOL as a diff editor fails. This would be helpful, for
example, for the `vscode` tool.
2024-05-05 18:33:53 -07:00
Martin von Zweigbergk
3dab92d2e9 cli: move revsets.log default to config file 2024-05-05 09:08: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
Yuya Nishihara
34fce3ca9d cli: extract functions that map fileset/revset/template errors to hints 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
Yuya Nishihara
8abcbd659a templater: add RefName::local_only() constructor
It will be called from cmd_tag_list().
2024-05-03 15:16:52 +09:00
Yuya Nishihara
35e550e863 templater: store associated RefTarget in RefName struct
I'm going to add ref_name.target*() template methods so the commit templater
can be reused for branches/tags templates. RefTarget could be looked up by
(name, kind) pair, but it's simpler to store it in RefName.
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
2bd2358d6a squash: move updating of source commits out of diff-editing loop
This is just a little refactoring to prepare for using
`transform_descendants()`.
2024-04-30 20:03:57 -07:00
Martin von Zweigbergk
7319479df9 squash: decide to abandon source commit if entire diff was selected
Before this patch, we would abandon the source commit if it became
empty after applying the reverse diff. This changes that condition to
the equivalent condition of the selected tree being the source
commit's original tree. This will help us rewrite the code to use
`transform_descendants()`.
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
dploch
586ab1f076 revset: add a SymbolResolverExtension trait to provide custom resolvers 2024-04-26 10:55:34 -04:00
dploch
0cef90f4f4 examples: simplify commit templater example with Default 2024-04-26 10:55:34 -04:00
dploch
bad9e9e3d7 revset: convert commit and change prefix resolvers into partial symbol resolvers 2024-04-26 10:55:34 -04:00
dploch
cf78532bd8 revset: add two new error variants to support extensions 2024-04-26 10:55:34 -04:00
Martin von Zweigbergk
d13be927a8 cli: add global --ignore-immutable
Closes #3576
2024-04-26 06:13:15 -07:00
Yuya Nishihara
c267f55809 templates: remove implicit self dependency from description_placeholder alias
Spotted while experimenting with "jj tag list -T". The description_placeholder
alias could be changed to function taking a Commit object, but I feel it's odd.
Conceptually, the placeholder could also be used in "op log" templates.
2024-04-26 16:56:35 +09:00
Yuya Nishihara
dbc7ad2d8e templates: extract common parts from commit_summary templates
If "branch"/"tag list" are migrate to templates, the added alias function
will be called from these templates.
2024-04-26 16:56:35 +09: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
Yuya Nishihara
5394f342ce templater: add type_name() method to tagged property types
Suppose we add binary comparison operators, we'll probably need an easy way to
get (lhs, rhs) property types to produce a meaningful error message.
2024-04-26 00:57:26 +09:00
Yuya Nishihara
5b769c5c9e fileset, revset, templater: add support for single-quoted raw string literals
Since fileset/revset/template expressions are specified as command-line
arguments, it's sometimes convenient to use single quotes instead of double
quotes. Various scripting languages parse single-quoted strings in various ways,
but I choose the TOML rule because it's simple and practically useful. TOML is
our config language, so copying the TOML syntax would be less surprising than
borrowing it from another language.

https://github.com/toml-lang/toml/issues/188
2024-04-25 11:14:33 +09:00
Rowan Walsh
f185a838d7 Fixes typo in 'jj git init' args 2024-04-24 09:12:37 -07:00
Yuya Nishihara
528ccb318e fileset: fall back to bare pattern/string if no operator-like character found
While I like strict parsing, it's not uncommon that we have to deal with file
names containing spaces, and doubly-quoted strings such as '"Foo Bar"' look
ugly. So, this patch adds an exception that accepts top-level bare strings.
This parsing rule is specific to command arguments, and won't be enabled when
loading fileset aliases.
2024-04-24 12:02:07 +09: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