Commit Graph

1961 Commits

Author SHA1 Message Date
Ilya Grigoriev
3e86baa7f1 Test basic jj resolve functionality 2022-12-03 15:12:40 -08:00
Ilya Grigoriev
c2a4198efc Make fake-editor error output even more verbose
This is a followup to f4b175a8. When debugging `fake-editor`
failures, it is often useful to distinguish empty files,
files consisting of a single "\n" and so on.
2022-12-03 15:12:40 -08:00
Ilya Grigoriev
aeeae0af18 jj resolve: error when merge tool args are not configured 2022-12-03 15:12:40 -08:00
Ilya Grigoriev
1eccd3430f Make the choice and arguments of mergetool configurable
Also makes the merge/diff tool binary default to the tool's name
(thus changing the diff editor behavior slightly)
2022-12-03 15:12:40 -08:00
Ilya Grigoriev
1158600c80 New jj resolve command to resolve conflicts
This command uses an external merge tool to resolve conflicts
simple enough that they can be resolved with a 3-way merge.

This commit provides a very basic version of `jj resolve` that
is hardcoded to use vimdiff.

This also slightly changes the errors of the Diff Editor, so that
both the diff editor and `jj resolve can share an error type.
2022-12-03 15:12:40 -08:00
Ilya Grigoriev
55762e3681 Rename FileConflictData to ConflictHunk, use it in files.rs.
There's no point in having two identical types used for the same
purpose in two different places.
2022-12-03 15:12:40 -08:00
Ilya Grigoriev
85b472b507 Expose functions useful for conflict resolution UI
This refactors `conflicts.rs` to:

1. Make `describe_conflict` public

2. Extract the functionality to create text version of
a conflict as the `materialize_merge_result` function.

3. Extract the functionality to turn a conflicted file
into the complete contents of each version of the file
"added" or removed" (when possible). This becomes the
`extract_file_conflict_data` function.

This is useful in order to present these text versions
in a merge tool.
2022-12-03 15:12:40 -08:00
Martin von Zweigbergk
b3fe52305a git: inline export_changes()
The function doesn't do much at all now and there's a single caller,
so let's inline it.

I tried to clean up the code a bit futher so it wouldn't even create
the `old_view`, but it was harder than I had hoped. I might get back
to it later.
2022-12-03 09:32:49 -08:00
Martin von Zweigbergk
8a440d8042 git: on export, use repo view's git_refs as record of old export state
@yuja asked on #701 about the difference between the state in the
`git_export_view` and what we have in `mut_repo.view()`. It's true
that the branches in `mut_repo.view().git_refs()` should match what we
wrote to disk. We can therefore remove the on-disk storage and
simplify quite a bit. For now, I create the `last_export_view` from
the `mut_repo.view().git_refs()` before calling
`export_changes()`. I'll clean up a bit more next.

I think this is correct even considering e.g. undo. Let's consider
what would happen in a non-colocated Git repo (not because tricky
cases cannot happen there but because the explicit exports and imports
make it easier to discuss, and more cases can occur). If the user
moved a branch and then did `jj git export`, `jj undo`, and then `jj
git export` again, we would think on the second export that we should
perform the same changes to the Git repo, which should have no effect.

This patch also fixes the bug we were forced to work around in the
test case in the previous patch.

This removes one of our uses of Thrift.
2022-12-03 09:32:49 -08:00
Martin von Zweigbergk
39792368ba git: when exporting, don't overwrite changes made by git
This fixes the bugs shown by the tests added in the previous patch by
checking that the git branches we're about to update have not been
updated by git since our last export. If they have, we fail those
branches. The user can then re-import from the git repo and resolve
any conflicts before exporting again.

I had to update the `test_export_import_sequence` to make it
pass. That shows a new bug, which I'll fix next. The problem is that
the exported view doesn't get updated on import, so we would try to
export changes compared to an earlier export, even though we actually
knew (because of the `jj git import`) that the state in git had
changed.
2022-12-03 09:32:49 -08:00
Martin von Zweigbergk
a98ed62519 changelog: list fix for #493 was a bugfix, not a feature 2022-12-03 09:32:49 -08:00
Martin von Zweigbergk
9b59461242 git: add test for concurrent change in git repo between exports
If you update a branch using regular `git` (or some Git-based tool)
between two `jj git export`, we will overwrite that change if you had
also changed the branch in jj land. There's a similar problem if you
delete the branch in jj land. Let's have a test for that. I'm going to
make us not overwrite it soon. This patch adds a test for those cases,
plus many other cases in consistent way. Since the new test covers
some cases tested by existing tests, I removed those tests.
2022-12-03 09:32:49 -08:00
Martin von Zweigbergk
25008b63a4 local_backend: switch from Thrift back to Protobuf
The Protobuf team at Google decided to let us use Protobufs internally
after all. That will make things a little easier for us with the
Google-internal adapations, and the `protobuf` crate is noticeably
faster than the `thrift` crate.

This effectively rolls back commit 5b10c9aa0a. I resolved some
conflicts caused by the rename from `NormalFile` to `File`. I also
kept the changelog entry, but I changed it to say that the hashing
scheme has changed (not the format), but since the hashes are just
used for identity, existing repos should still work.
2022-12-02 19:29:45 -08:00
Martin von Zweigbergk
69f85dfd27 docs: describe how we do code reviews 2022-12-02 13:05:32 -08:00
Yuya Nishihara
de639c3ef1 cli: accept command arguments specified by array
It should be more reliable than parsing a command string into array.

Also updated some of the doc example to use array syntax. I don't think
"C:/Program Files" was parsed properly, but might work thanks to Windows
magic.
2022-12-02 15:44:10 +09:00
Yuya Nishihara
3b5edd480c cli: split pager arguments like ui.editor
Environment like $PAGER or $EDITOR is supposed to be executed via shell,
so we need to at least split the command string.
2022-12-02 15:44:10 +09:00
Yuya Nishihara
f23302bc53 cli: add helper function that makes Command builder from CommandArgs 2022-12-02 15:44:10 +09:00
Yuya Nishihara
368aa06fdc cli: add wrapper struct for command arguments read from config
It implements Deserialize because config.get() requires that. We could instead
add TryFrom<config::Value>, but we'll need Deserialize anyway if we want to
parse a struct containing FullCommandArgs.

I don't know if src/config.rs is the right place, but I feel it's slightly
better than messing up ui.rs.
2022-12-02 15:44:10 +09:00
Martin von Zweigbergk
ee7e7e1b62 github: new attempt at auto-enabling merge of Dependabot PRs
cli/cli#1314 is now marked fixed, so let's see if this works. This
rolls back commit 184280f8f801.
2022-12-01 19:28:39 -08:00
Martin von Zweigbergk
b80c39d77c view: test that merging divergent rewrites results in both commits visible
It seems that we didn't have a test for this simple case. I wrote this
test case while working on #111 but I don't know why I didn't push it
back then.
2022-12-01 19:20:38 -08:00
Pranay Sashank
47067c1368 git: do not delete or track git submodules.
A new FileType, GitSubmodule is added which is ignored. Files or
directories having this type are not added to the work queue and
are ignored in snapshot. Submodules are not created by jujutsu
when resetting or checking out a tree, they should be currently
managed using git.
2022-12-01 23:14:55 +05:30
Yuya Nishihara
34fe0899ca cli: colorize pager spawn error
I've moved error handling to the call site to avoid passing &mut Ui
around.
2022-12-02 00:57:19 +09:00
Yuya Nishihara
74084d026c cli: add missing newline to pager error messages
Also added colon for consistency.
2022-12-02 00:57:19 +09:00
Martin von Zweigbergk
79267b5492 readme: add some badges
Originally written by @xxxserxxx.
2022-11-30 11:31:24 -08:00
Martin von Zweigbergk
f30a92216c cli: correct and clarify rebase help text
The example for the `-b` flag was completely incorrect. It looks like
I have copied the example from `-r` and then forgotten to update
it. This fixes that, and also adds some more commits to the example to
hopefully clarify.
2022-11-30 09:31:25 -08:00
Yuya Nishihara
5cc99b6451 revset: inline ChildrenRevsetIterator by using .filter() 2022-11-30 23:42:51 +09:00
Yuya Nishihara
fae3822422 revset: inline FilterRevsetIterator by using .filter() 2022-11-30 23:42:51 +09:00
Yuya Nishihara
5b13c0b38f revset: inline RevWalkRevsetIterator which is just an identity iterator 2022-11-30 23:42:51 +09:00
Ilya Grigoriev
52fadc046e Miscellaneous improvements to config docs
Also moves the "relative timestamps" section to make merge tool
docs fit in better.
2022-11-29 20:55:11 -08:00
Benjamin Saunders
ce0aa95162 docs: clarify diff editor interface 2022-11-29 17:58:02 -08:00
Glen Choo
0df5f7c5bf cli: add --no-pager 2022-11-30 06:14:39 +08:00
Glen Choo
7c2400f3e5 ui: add pager
Teach Ui's writing functions to write to a pager without touching the
process's file descriptors. This is done by introducing UiOutput::Paged,
which spawns a pager that Ui's functions can write to.

The pager program can be chosen via `ui.pager`. (defaults to Defaults to
$PAGER, and 'less' if that is unset (falling back to 'less' also makes
the tests pass).

Currently, commands are paginated if:

- they have "long" output (as defined by jj developers)
- jj is invoked in a terminal

The next commit will allow pagination to be turned off via a CLI option.
More complex pagination toggling (e.g. showing a pager even if the
output doesn't look like a terminal, using a pager for shorter ouput) is
left for a future PR.
2022-11-30 06:14:39 +08:00
Glen Choo
f4f0fbbd5d settings: move cli-specific settings to src/ui.rs 2022-11-30 06:14:39 +08:00
Glen Choo
d622656deb cli: rename UiOutputPair to UiOutput
We'll add a variant that isn't a pair. Also add a function to create a
new UiOutput::Terminal, we will create this variant in a few places
because we want to fall back to it.
2022-11-30 06:14:39 +08:00
dependabot[bot]
babbdc4e72 cargo: bump clap from 4.0.27 to 4.0.29
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.27 to 4.0.29.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.0.27...v4.0.29)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-29 08:07:34 -08:00
Yuya Nishihara
ea485801f9 tests: update revset error message after 8b00a64ab2 and 48d10d648c 2022-11-29 16:12:55 +09:00
Yuya Nishihara
0e99747728 revset: eliminate double negates
Writing double negates is silly, but it might be hidden by revset alias
if we added such feature.

I made fold_redundant_expression() a separate step from fold_difference()
since I'll probably want to apply the cleanup step before rewriting filter
expressions.
2022-11-29 15:46:15 +09:00
Yuya Nishihara
54044ea8d6 revset: transform negative intersection to difference 2022-11-29 15:46:15 +09:00
Yuya Nishihara
48d10d648c revset: add unary negate (or set complement) operator '~y'
Because a unary negation node '~y' is more primitive than the corresponding
difference node 'x~y', '~y' is easier to deal with while rewriting the tree.
That's the main reason to add RevsetExpression::NotIn node.

As we have a NotIn node, it makes sense to add an operator for that. This
patch reuses '~' token, which I feel intuitive since the other set operators
looks like bitwise ops. Another option is '!'.

The unary '~' operator has the highest precedence among the set operators,
but they are lower than the ranges. This might be counter intuitive, but
useful because a prefix range ':x' can be negated without parens.

Maybe we can remove the redundant infix operator 'x ~ y', but it isn't
decided yet.
2022-11-29 15:46:15 +09:00
Martin von Zweigbergk
2e725270e4 cli: hint about how to recover from failed export of branches 2022-11-28 19:54:31 -08:00
Martin von Zweigbergk
e6d21ed442 changelog: thank people who contributed to a release
Thanks, everyone! :) I'm happy to rephrase the text. I included people
in order of their first contribution in the release. I included their
full name and the GitHub username.
2022-11-28 10:17:21 -10:00
Martin von Zweigbergk
b32598e989 cli: require revision arguments to be non-empty strings
I can't see any reason the user would want to specify revisions
matching the empty string, so let's disallow it. I created a custom
type for revision arguments instead of repeating `value_parser =
NonEmptyStringValueParser::new()`.
2022-11-28 09:17:43 -10:00
Martin von Zweigbergk
fd02dc2dc2 cli: disallow creating branch with empty name
If the user creates a branch with an empty name, it seems very likely
to be an accident. Let's help them realize that by erroring out.

I didn't add the same checks to `jj branch delete`, since that would
make it hard to delete a branch with an empty name from existing
repos.
2022-11-28 09:17:43 -10:00
Yuya Nishihara
7fbd7b48e5 revset: highlight whole function expression on substitution failed
The error may be caused by arguments passed in to the alias function.
2022-11-29 04:17:12 +09:00
Yuya Nishihara
70292f79b7 revset: implement function alias expansion
Function parameters are processed as local symbols while substituting
alias expression. This isn't as efficient as Mercurial which caches
a tree of fully-expanded function template, but that wouldn't matter in
practice.
2022-11-29 04:17:12 +09:00
Martin von Zweigbergk
d8feed9be4 copyright: change from "Google LLC" to "The Jujutsu Authors"
Let's acknowledge everyone's contributions by replacing "Google LLC"
in the copyright header by "The Jujutsu Authors". If I understand
correctly, it won't have any legal effect, but maybe it still helps
reduce concerns from contributors (though I haven't heard any
concerns).

Google employees can read about Google's policy at
go/releasing/contributions#copyright.
2022-11-28 06:05:45 -10:00
dependabot[bot]
a7ff8d5ee3 cargo: bump insta from 1.21.1 to 1.21.2
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.21.1 to 1.21.2.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.21.1...1.21.2)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 05:29:03 -10:00
dependabot[bot]
374d8f1208 cargo: bump rpassword from 7.1.0 to 7.2.0
Bumps [rpassword](https://github.com/conradkleinespel/rpassword) from 7.1.0 to 7.2.0.
- [Release notes](https://github.com/conradkleinespel/rpassword/releases)
- [Commits](https://github.com/conradkleinespel/rpassword/compare/v7.1.0...v7.2.0)

---
updated-dependencies:
- dependency-name: rpassword
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 05:27:12 -10:00
dependabot[bot]
cc9ca6dfdb cargo: bump serde from 1.0.147 to 1.0.148
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.147 to 1.0.148.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.147...v1.0.148)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 05:25:56 -10:00
dependabot[bot]
d90a08676c github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from 55c7845fad90d0ae8b2e83715cb900e5e861e8cb to e645b0cf01249a964ec099494d38d2da0f0b349f.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](55c7845fad...e645b0cf01)

---
updated-dependencies:
- dependency-name: dtolnay/rust-toolchain
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 05:22:27 -10:00