Commit graph

2120 commits

Author SHA1 Message Date
Martin von Zweigbergk
5a9d1e5fdd op_store: rename variables in upgrade code to be direction-agnostic
The code for migrating from ProtoBuf to Thrift is almost completely
independent of which direction the upgrade goes, so we can very easily
reuse it for migrating from Thrift to Protobuf. This patch renames
some variables to "old/new" instead of "proto/thrift", making the next
patch even simpler.
2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
472dee6403 op_store: move ThriftOpStore to new file
Since we're now allowed to use the `protobuf` crate, I'm going to make
`SimpleOpStore` use it again. This moves the `ThriftOpStore` into a
new `legacy_thrift_op_store.rs` file.
2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
fdf43b845a content_hash: absorb duplicate hash() functions
We use the same blake2b hash for `ContentHash` impls in several
places, and I'm about to add more places, so let's centralize the
helper function.
2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
c0a819e94a op_store: remove legacy_protobuf Cargo feature
Since we now have approval to use the `protobuf` crate at Google, it's
no longer the "legacy" format, so we should remove it. I'll almost
definitely soon add `legacy_thrift` feature instead.
2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
7e224003e3 changelog: copy formatting of links to issues from Cargo
I thought I had seen our current formatting, i.e. `(#123)`, get
auto-linked by GitHub, but it seems it doesn't. This patch therefore
changes to use markdown links. I copied the style from Cargo (and
Clippy).
2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
d3dffe933c changelog: remove mention of native backend's hashing scheme
The change in hashing scheme should not even be noticeable, except
maybe because the same objects may be saved twice and take extra
space, and may be slower because we compare the contents for equality
instead of short-circuiting when we the hash matches.
2022-12-03 22:31:02 -08:00
Ilya Grigoriev
8222ba94cf Documentation for jj resolve and merge tool config 2022-12-03 15:12:40 -08:00
Ilya Grigoriev
e3fd49993e Add a default merge tool config for meld, vimdiff, kdiff3. 2022-12-03 15:12:40 -08:00
Ilya Grigoriev
d6c1b0bc9c jj resolve: option to parse conflict markers + tests
If this new option is not specified, we start with empty output
file and trust the merge tool did a complete merge no matter
what the file contains.

Includes tests.
2022-12-03 15:12:40 -08:00
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