Commit graph

6064 commits

Author SHA1 Message Date
Martin von Zweigbergk
2e44741e02 repo: move new commit ids into RewriteType enum
`RewriteType::Rewritten` must have exactly one replacement. I think
it's better to encode that in the type by attaching the value to the
enum variant. I also renamed the type to just `Rewrite` since it now
has attached data and `Type` sounds like a traditional data-free enum
to me.
2024-05-06 12:58:40 -07:00
Martin von Zweigbergk
c6bb94de42 repo: make RewriteType private
Looks like I forgot this in some recent refactoring.

I don't really see any harm in making the type public later. I might
want to make `rebase_descendants()` not clear `parent_mapping` and
instead provide a way of accessing it afterwards (removing the need
for the `_return_map()` flavors).  We'll see if that ends up
happening. For now it can be private anyway.
2024-05-06 12:58:40 -07:00
Austin Seipp
029a6002ad chore: nix flake update 2024-05-06 14:43:41 -05:00
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
cfa595199a revset: make a bunch of parsing types public 2024-05-06 10:42:01 -04:00
dploch
4e0abf0631 revset: make RevsetParseContext opaque 2024-05-06 10:42:01 -04:00
Ilya Grigoriev
3cf521fb41 fixup to 70b517c: remove errant conflict marker 2024-05-05 19:24:37 -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
Ilya Grigoriev
f43a810fe0 conflicts.rs: Teach jj to parse conflict markers that are followed by a label
The format is 7 characters of the separator followed by a space and arbitrary
text, followed by a newline. Separator followed by a newline is also allowed.
E.g.:

<<<<<<< Random text
%%%%%%% Random text
 line 2
-line 3
+left
 line 4
+++++++ Random text
right
%%%%%%% Random text
 line 2
+forward
 line 3
 line 4
>>>>>>> Random text

This commit only allows reading such conflicts.

I considered allowing longer separators (`<<<<<<<<<<<<<< Random text`), but we
wouldn't currently write them, so let's be strict for now.

7 characters if they are followed by a space and arbitrary text
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
Ilya Grigoriev
638649b435 tutorial: edits to the diff editor explanation
Follows up on #3599. I also moved the discussion of other diff editors to a
footnote, as it didn't seem to fit well into the flow of the text.
2024-05-05 18:17:38 -07:00
Martin von Zweigbergk
3dab92d2e9 cli: move revsets.log default to config file 2024-05-05 09:08:14 -07:00
Martin von Zweigbergk
f958957f9e cli: drop support for old ui.default-revset config
We replaced it by `revsets.log` in 0.8.0, which is long enough that
users should have been able to switch.
2024-05-05 09:08:14 -07:00
Eidolon
3d898d0a06 Add default value of revsets.log to config docs
I wanted to have a reference point for the built-in revsets,
but `jj config get revsets.log` doesn't turn anything up since
it has special handling for the legacy config key
`ui.default-revset`. So I had to dig into the source code of jj
to get it.

I think it might help others to be able to reason about revsets
to have the log default shown in the settings documentation.
2024-05-05 07:17:32 -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
Charles Crete
d9d60118a3 docs: update tutorial to include :builtin diff editor instructions 2024-05-02 23:04:40 -04:00
dependabot[bot]
7083530727 cargo: bump serde in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [serde](https://github.com/serde-rs/serde).


Updates `serde` from 1.0.199 to 1.0.200
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.199...v1.0.200)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-02 15:31:35 -07:00
Martin von Zweigbergk
19563fee74 release: release version 0.17.0
Thanks to everyone who's contributed!

Unlike previous releases, I went through the changelog entries and
reorganized them a bit.

We didn't have anything under "Deprecations" this time, but I moved
the heading after "Breaking changes" for next release. I think
breaking changes are more important because deprecations are just
about giving a heads up before it actually breaks.
2024-05-01 10:10:01 -07:00
dependabot[bot]
28e3751250 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [pest](https://github.com/pest-parser/pest) and [pest_derive](https://github.com/pest-parser/pest).


Updates `pest` from 2.7.9 to 2.7.10
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.9...v2.7.10)

Updates `pest_derive` from 2.7.9 to 2.7.10
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.9...v2.7.10)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-01 19:07:23 +02: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
dbf2a98903 rewrite: add CommitRewriter::record_abandoned_commit()
We already have two uses for this function and I think we're soon
going to have more.

The function record the old commit as abandoned with the new parents,
which is typically what you want. We could record it as abandoned with
the old parents instead but then we'd have to do an extra iteration to
find the parents when rebasing any children. It would also be
confusing if
`rewriter.set_parents(new_parents).record_abandoned_commit()` didn't
respect the new parents.
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
dependabot[bot]
b8e08d644c cargo: bump libc from 0.2.153 to 0.2.154 in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [libc](https://github.com/rust-lang/libc).


Updates `libc` from 0.2.153 to 0.2.154
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.153...0.2.154)

---
updated-dependencies:
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-30 15:45:51 +00:00
Jonathan Lorimer
e54e83b0f5 docs: Add information about configuring delta pager
docs: Add information about configuring delta pager

docs: only mention pager, not diff
2024-04-29 10:22:05 -07:00
dependabot[bot]
af95c788af cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [serde](https://github.com/serde-rs/serde) and [unicode-width](https://github.com/unicode-rs/unicode-width).


Updates `serde` from 1.0.198 to 1.0.199
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.198...v1.0.199)

Updates `unicode-width` from 0.1.11 to 0.1.12
- [Commits](https://github.com/unicode-rs/unicode-width/compare/v0.1.11...v0.1.12)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: unicode-width
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 18:15:13 +02:00
Charles Crete
c8123e1555 docs: mention obslog in tutorial 2024-04-29 08:40:05 -07:00
Yuya Nishihara
6a208e7af7 doc: fix typo of contained_in() template method 2024-04-29 22:56:44 +09: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