ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

2190 commits

Author SHA1 Message Date
Ilya Grigoriev
b58be8d7a4 Mention path in message for ConflictResolveError::NotNormalFilesError. 2022-12-04 22:39:45 -08:00
Martin von Zweigbergk
48c44344bf cli: make jj status not just care about the first parent
It seems like I forgot to update the `jj status` output when I decided
(years ago?) that the changes in a commit should always be compared to
the auto-merged parents. I was very confused before I realized that
`jj status` was showing the diff summary against the first parent. I
suppose the fact that `jj status` lists only one parent should have
been a hint. Thanks to ilyagr@ for finding this odd behavior. This
patch fixes it by making the command list all parents, and changes the
diff summary to be against the auto-merged parents.
2022-12-04 22:29:12 -08:00
Yuya Nishihara
f4953cdb60 index: return early from RevWalk if items get filled with unwanted 2022-12-05 14:31:14 +09:00
Yuya Nishihara
2a00481ec5 index: make RevWalk push all parents and deduplicate later on pop()
The idea behind this is to extend RevWalk to track generation (or depth from
the initial wanted items.) Basic DAG walk doesn't need such data, but a query
like 'rev---' could be translated to a RevWalk yielding nth ancestors.
The default log revset can also be expressed as 0/1-th ancestors of
'(remote_branches() | tags())..'.

Also, this appears to be faster than using boundary sets, based on the
bench extracted from test_index_commits_criss_cross().
2022-12-05 14:31:14 +09:00
Martin von Zweigbergk
dc8830843e cli: use pager for print
The `print` command shows the contents of a file, so that is obviously
often more than a page long. Both `hg cat file` and `git show
HEAD:file` page the output.
2022-12-04 20:52:29 -08:00
Martin von Zweigbergk
8e994a28fe cli: use pager for files
The output from `files` is often longer than a screen, so the pager is
useful, even though this command is probably used mostly by
scripts. As with `status`, `hg` pages its output, but `git` doesn't.
2022-12-04 20:52:29 -08:00
Martin von Zweigbergk
cb9ba5abc1 cli: enable pager on status
The status output may be long, so the pager can useful. Now that we
pass `-F` to the pager by default, it should also be fine to use the
pager for short output. For reference, `hg` pages `status` output, but
`git` doesn't.
2022-12-04 20:52:29 -08:00
Luke Granger-Brown
e95b8edca1 Give the "unset user" warning a trailing newline.
At the moment, the unset user warning is lacking a trailing newline, so
we end up printing anything else that's output directly on the same line.
2022-12-04 18:01:09 -08:00
Ilya Grigoriev
c52a14eac6 Remove an unused import warning on recent versions of Rust
This warning used to show up, at least, on Rust nightly:
     unused import: `crate::nightly_shims::BTreeSetExt`
2022-12-04 13:15:42 -08:00
Yuya Nishihara
e17fc89a8d revset: make filter node unary, move candidates to outer intersection
In order to optimize a query like '(author(_) | @) & main..', we'll probably
need a predicate form of an iterable set so that the query can be evaluated
to '(main..).iter().filter(author(_) | @)'. And if a predicate function can
terminate the source iterator early (by returning true/false/false_forever),
complexity of a filtered revset is basically the same as an intersection of
iterator pair. This means we can eventually merge IntersectionRevset with
FilterRevset.

With that in mind, this patch removes the redundant 'candidates' field from
the filter node, which would otherwise appear in the predicate function as
'candidates.contains(entry)'. A filter node with candidates was somewhat
useful while rewriting the tree, but that can be dealt with a view function
like as_filter_intersection() in this patch.

This also simplify the subsequent filter transformation as we no longer need
to test if candidates == All.
2022-12-05 00:32:18 +09:00
Yuya Nishihara
6d977c73e4 revset: add test of filter intersection over non-linear tree
Previously we only have a test for the left recursion. The added test
contains right recursion path, which should have caught the error I made
while working on the next "unary filter node" patch.
2022-12-05 00:32:18 +09:00
Yuya Nishihara
48d426529c revset: update doc of filter transformation, apply minor style change
The doc comment summarizes what I'm going to implement. I'm not sure if
we'll add all of them because revset evaluation isn't the key performance
bottleneck at the moment. Anyway, I don't think any of these ideas would
logically conflict with segmented changelog adaptation unless we decide to
replace the whole revset stack with Eden/Sapling's.
2022-12-05 00:32:18 +09:00
Yuya Nishihara
ec6f2cf393 revset: extract function that builds predicate function from spec 2022-12-05 00:32:18 +09:00
Yuya Nishihara
ce84d17060 cli: spawn pager after command arguments are validated
Just like hg, it's probably better to show short error message without pager.
2022-12-04 23:08:01 +09:00
Martin von Zweigbergk
c5c89b9e9b pager: default to less -FRX
As dbarnett@ reported on #9, our default of `less`, combined with our
default of enabling color on TTYs, means that we print ANSI codes to
`less` by default. Unless the user has set e.g. `$LESS=R`, `less` is
going to escape those codes, resulting in garbage like this:

```
@ ESC[1;35mbb39c26a29feESC[0m ESC[1;33m(no email configured)ESC[0m ESC[1;36m2022-12-03....
```

I guess most of us didn't notice because we have something like
`$LESS=FRX` set.

This patch changes our default from `less` to `less -FRX`. Those are
the flags we're using for our internal hg distribution at Google, and
that has seemed quite uncontroversial.

I added a pointer from the changelog to the tracking issue while at
it.
2022-12-04 00:00:31 -08:00
Martin von Zweigbergk
be383cebc7 git: on import, add GC-preventing refs to all seen refs
To prevent git's GC from breaking a repo, we already add a git ref to
commits we create in the git backend. However, we don't add refs to
commits we import from git. This fixes that.

Closes #815.
2022-12-03 22:50:26 -08:00
Martin von Zweigbergk
9df247f87c git: on import, update record of ref only if it changed
There's no need to update our record of the ref if it didn't
change. This is just about making it clearer; I doubt it will have
measurable performance impact.
2022-12-03 22:50:26 -08:00
Martin von Zweigbergk
84a4dee673 thrift: add legacy-thrift Cargo feature
This patch adds a `legacy-thrift` Cargo feature that's enabled by
default. If it's disabled, the upgrade from Thrift-based operation log
does not happen, and the `thrift` depdendency is not included.
2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
6b964218bf legacy_thrift_op_store: remove implementation write methods 2022-12-03 22:31:02 -08:00
Martin von Zweigbergk
c269b72fb3 op_store: auto-upgrade existing repos from Thrift to Protobuf
With this patch, we auto-upgrade existing repos that use Thrift format
for the operation log to use Protobuf format. That would only be repos
used with an unreleased version of jj after 0.5.1 (which may be the
majority of repos?).

The upgrade from Thrift is simpler because we now use the same hashing
scheme for the Protobuf-based storage, so the operation and view IDs
remain the same as they were in the Thrift-based storage. We could
simplify the code a bit more as a result, but since this code is
supposed to be short-lived, I didn't bother.

Since the change from the Protobuf format with the old hashing scheme
to a the (same) Protobuf format with the new hashing scheme shouldn't
impact users, I removed the entry we had in the changelog about the
format change.
2022-12-03 22:31:02 -08:00
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