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

3810 commits

Author SHA1 Message Date
Ilya Grigoriev
a22255bd51 Fix cargo +nightly clippy warnings 2023-07-28 22:19:52 -07:00
Yuya Nishihara
b3ae7e7657 revset_graph: preserve original parents order
It seemed awkward if merged PR is sometimes rendered as a first branch.
Instead of sorting edges in index order, let's build a HashSet only when
deduplication is needed.
2023-07-29 05:36:09 +09:00
Yuya Nishihara
1bf6ab5370 revset_graph: avoid construction of edges if already known
The stack can contain duplicated entries, and we only need the last one to
resolve edges.
2023-07-29 05:36:09 +09:00
Martin von Zweigbergk
beb997e85a watchman: don't even add non-watchman files to set of deleted files
It's faster to add only files matched by the Watchman matcher to the
set of deleted files than to add all files and then removed files not
matched. This speeds up `jj diff` with Watchman in the Linux repo from
~530 ms to ~460 ms.
2023-07-28 12:12:09 -07:00
Waleed Khan
4b635e9713 working_copy: use tree rather than file states to detect if directory is tracked
This moves us closer towards treating the `file_states` map as purely a cache rather than authoritative state.
2023-07-28 10:15:33 -07:00
Waleed Khan
9d8702b537 refactor(working_copy): return new file state from update_file_state 2023-07-28 09:52:37 -07:00
Waleed Khan
c409f4ed53 refactor(working_copy): hoist current and new file states to top of update_file_state
Reduces some indentation and simplifies some control flow.
2023-07-28 09:52:37 -07:00
Waleed Khan
3264135489 refactor(working_copy): return updated new tree value from update_file_state
The intention in this and some future commits is to have `update_file_state` accept `&self` instead of `&mut self` to make clear what data is updated by `update_file_state` and to ensure transactional safety of the `TreeState` contents.
2023-07-28 09:52:37 -07:00
Martin von Zweigbergk
3ef552c4c1 tests: add TestWorkspace::snapshot() to simplify snapshotting
It's currently a bit complicated to snapshot the working copy and
there's a lot of duplication in tests. This commit introduces a
function to simplify it. I made the function snapshot the working copy
and save the updated state. Some of the tests I changed previously
discarded the changes instead of saving them, but I think they all did
so because it was simpler. I left a few call sites unchanged because
they make concurrent changes.
2023-07-28 09:32:18 -07:00
Martin von Zweigbergk
2ccd3247f9 tests: remove a duplicate code block
It looks like this has been duplicated since I added the test in
cd4fbd3565.
2023-07-28 09:32:18 -07:00
Waleed Khan
1e28b312c6 perf: instrument some steps in snapshot 2023-07-28 09:28:01 -07:00
Waleed Khan
018bb88ec6 perf: add several #[instrument]s 2023-07-28 09:28:01 -07:00
Waleed Khan
7875656354 perf: add #[instrument] to all cmd_* functions 2023-07-28 09:28:01 -07:00
Waleed Khan
2ce02357e5 perf: set filename according to JJ_TRACE 2023-07-28 09:28:01 -07:00
Martin von Zweigbergk
ba6ea6f638 cli: make jj debug operation --display operation work with broken view
This is to aid debugging in cases like #1907, where the operation
object has an invalid view object.
2023-07-28 08:42:34 -07:00
dependabot[bot]
28ea03612d cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [serde](https://github.com/serde-rs/serde).

- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.176...v1.0.177)

---
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>
2023-07-28 15:28:07 +00:00
Piotr Kufel
04d120aad0 Allow editing non-existent configs
Addresses #1571.
2023-07-27 15:49:08 -07:00
dependabot[bot]
5d02a57713 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 [serde_json](https://github.com/serde-rs/json).


Updates `serde` from 1.0.175 to 1.0.176
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.175...v1.0.176)

Updates `serde_json` from 1.0.103 to 1.0.104
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.103...v1.0.104)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-27 15:57:54 +00:00
Yuya Nishihara
4834d12c37 simple_op_store: serialize RefTarget in new format (breaks downgrades)
This is breaking change. Old jj binary will panic if it sees a view saved by
new jj. Alternatively, we can store both new and legacy data for backward
compatibility.
2023-07-27 15:32:48 +09:00
Yuya Nishihara
8351a743f6 simple_op_store: add deserialization support of new Conflict-based RefTarget
CommitId is wrapped with a message since we need a representation for None.
This is different from TreeConflict in which an empty tree has an id.
2023-07-27 15:32:48 +09:00
Yuya Nishihara
2382ae09e2 gen-protos: make old protoc accept optional fields
The version installed by ubuntu "latest" doesn't seem to support optional
fields yet. This is copied from the prost documentation.

https://docs.rs/prost-build/latest/prost_build/struct.Config.html#method.protoc_arg
2023-07-27 15:32:48 +09:00
Martin von Zweigbergk
4348d0b487 working_copy: leverage create_tree() in test
This also lets us compare the resulting tree because the working copy
now exactly matches the tree (it used to be that the `.gitignore` file
wasn't initially snapshotted).
2023-07-26 23:30:10 -07:00
Martin von Zweigbergk
55520a0e9c simple_op_store: add object type and id to protobuf decode errors 2023-07-26 14:17:21 -07:00
Martin von Zweigbergk
56750bb360 op_store: add read/write error variants, matching commit backend
This will hopefully give enough information to tell which path was
unexpectedly a directory in #1907.
2023-07-26 14:17:21 -07:00
Martin von Zweigbergk
96e75e6ad1 simple_op_store: return NotFound for missing views
I guess we don't depend on `read_view()` ever returning `NotFound` the
way `read_operation()` does, but it seems like it still should return
`NotFound` when the view doesn't exist.
2023-07-26 14:17:21 -07:00
Martin von Zweigbergk
84a60d15bc op_store: make ViewId and OperationId implement ObjectId 2023-07-26 14:17:21 -07:00
Martin von Zweigbergk
769426f99a op_store: make OpStoreError::Other preserve source error object
This is the OpStore version of e1e75daa8e.
2023-07-26 14:17:21 -07:00
Yuya Nishihara
60d48c27f6 revset_graph: ignore duplicated entries in emittable stack
Since parent->child edge is populated lazily, emittable stack may have
duplicated entries.

Fixes #1909
2023-07-26 04:04:34 +09:00
Waleed Khan
70d3c64b1e operation: propagate OpStoreError
This is a rote propagation of the error value to hopefully improve the panic in https://github.com/martinvonz/jj/issues/1907.
2023-07-25 12:46:59 -05:00
Martin von Zweigbergk
4acc5870e5 docs: fix a missed jujutsu->jj-cli in config docs 2023-07-25 05:40:26 -07:00
Martin von Zweigbergk
7cc916e4f1 working_copy: in mtime race case, don't mutate current state
There's a comment saying that mutating the file's current state
simplifies later logic, but I don't think that's true. It might have
been true in the past, when we had `FileType::Conflict`.
2023-07-24 16:41:44 -07:00
Martin von Zweigbergk
8d1cb1e1d7 working_copy: add test of racy checkout followed by file write
We don't seem to have any tests that our protection from undetected
changes caused by writes happening right after checkout, so let's add
one. The test case loops 100 times and each iteration fails slightly
more than 80% of the time on my machine (if I remove the protection in
`TreeState::update_file_state()`), so it seems quite good at
triggering the race.
2023-07-24 16:41:44 -07:00
Martin von Zweigbergk
e364c49854 test_working_copy_concurrent: run only with git backend
I don't see any reason for these tests to differ depending on backend,
so let's avoid running them twice (there are probably lots of other
tests that we're also running with different backends for little
reason).
2023-07-24 16:41:44 -07:00
Martin von Zweigbergk
861788ae09 working_copy: propagate errors from failing to read conflict file 2023-07-24 15:14:42 -07:00
Martin von Zweigbergk
99fec7ed06 working_copy: don't re-read resolved conflict from disk on snapshot
When snapshotting a conflict, we read the contents and parse conflict
markers. If we determine that it's no longer a conflict, then we write
a normal file entry to the tree instead. When we do that, we re-read
the file from the working copy. Let's instead write the file contents
we already read.
2023-07-24 15:14:42 -07:00
Martin von Zweigbergk
72d389cefb working_copy: extract a function for writing a conflict 2023-07-24 15:14:42 -07:00
Martin von Zweigbergk
c7e736f73c working_copy: update file state for conflict and non-conflict the same
When a file's mtime has changed on disk, we update our record of that
mtime, but we did so in a separate place for conflicts compared to
non-conflicts. Let's reuse it.
2023-07-24 15:14:42 -07:00
Martin von Zweigbergk
10a2a15993 working_copy: don't track conflict-ness in state file, use tree object
The working copy's current tree tracks whether a file is a
conflict. We also track that in the `TreeState` object. That allows us
to not read the trees object to decide if we should try to parse a
file as a conflict.

One disadvantage is that it's redundant information that needs to be
kept in sync with the tree object. Also, for Watchman, we would like
to completely ignore the persisted `FileState`.

This commit removes the `FileType::Conflict` variant and instead
checks in the tree object whether a given path was a conflict. This is
the change I mentioned in dc8a207737. We still skip the check
completely if the file's mtime etc. is unchanged, so it shouldn't have
much effect in the common case of a mostly unchanged working copy. I
measured a slowdown on `jj diff` by ~3% in the Linux repo with a clean
working copy with all mtimes bumped. I think the simpler code and
reduced risk of subtle bugs is worth the performance hit.
2023-07-24 15:02:33 -07:00
Yuya Nishihara
a80758ee1d revset_graph: remove redundant boxing from reverse iterator constructor 2023-07-25 01:45:37 +09:00
Yuya Nishihara
a382e96168 revset_graph: place new heads as close to fork point as possible
The idea is simple. New heads are ignored until the node dependency resolution
stuck. Then, only the first head that will unblock the visit will be queued.

Closes #242
2023-07-25 01:45:37 +09:00
Yuya Nishihara
fb33620f9e revset_graph: group commits topologically
The original idea was similar to Mercurial's "topo" sorting, but it was bad
at handling merge-heavy history. In order to render merges of topic branches
nicely, we need to prioritize branches at merge point, not at fork point.
OTOH, we do also want to place unmerged branches as close to the fork point
as possible. This commit implements the former requirement, and the latter
will be addressed by the next commit.

I think this is similar to Git's sorting logic described in the following blog
post. In our case, the in-degree walk can be dumb since topological order is
guaranteed by the index. We keep HashSet<CommitId> instead of an in-degree
integer value, which will be used in the next commit to resolve new heads as
late as possible.

https://github.blog/2022-08-30-gits-database-internals-ii-commit-history-queries/#topological-sorting

Compared to Sapling's beautify_graph(), this is lazy, and can roughly preserve
the index (or chronological) order. I tried beautify_graph() with prioritizing
the @ commit, but the result seemed too aggressively reordered. Perhaps, for
more complex history, beautify_graph() would produce a better result. For my
wip branches (~30 branches, a couple of commits per branch), this works pretty
well.

#242
2023-07-25 01:45:37 +09:00
Yuya Nishihara
6fcb98c0c4 revset_graph: add helper to test graph sorting 2023-07-25 01:45:37 +09:00
Yuya Nishihara
e2f9ed439e revset: extract graph-related types to separate module
I'm going to add a topo-grouping iterator adapter, and the revset module is
already big enough to split.
2023-07-25 01:45:37 +09:00
dependabot[bot]
c255ff1eaf cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [clap](https://github.com/clap-rs/clap), [serde](https://github.com/serde-rs/serde) and [cargo_metadata](https://github.com/oli-obk/cargo_metadata).


Updates `clap` from 4.3.17 to 4.3.19
- [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.3.17...v4.3.19)

Updates `serde` from 1.0.174 to 1.0.175
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.174...v1.0.175)

Updates `cargo_metadata` from 0.15.4 to 0.17.0
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.15.4...0.17.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 09:40:43 -07:00
dependabot[bot]
179cff7a71 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [DeterminateSystems/magic-nix-cache-action](https://github.com/determinatesystems/magic-nix-cache-action).

- [Release notes](https://github.com/determinatesystems/magic-nix-cache-action/releases)
- [Commits](5cc3a5e24b...749fc5bbc9)

---
updated-dependencies:
- dependency-name: DeterminateSystems/magic-nix-cache-action
  dependency-type: direct:production
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-24 15:26:44 +00:00
Yuya Nishihara
817713c921 graphlog: use IndexPosition until transitive edges get eliminated
This partially reverts 4c8f484278 "graphlog: key by commit id (not index
position)." As Martin pointed out, it made "log -r 'tags()' -T.." in git
repo super slow. Apparently, both clone() and hash map insertion/lookup costs
increased by that change. Since we don't need CommitId inside the graph
iterator, we can simply replace it with IndexPosition, and resolve it to
CommitId later.
2023-07-24 05:07:07 +09:00
Yuya Nishihara
2bbaa4352a refs: rename RefTarget::is_conflict() to has_conflict()
Copied from MergedTree::has_conflict(). I feel it's slightly better since
RefTarget "is" always a Conflict-based type. It could be inverted to
RefTarget::is_resolved(), but refs are usually resolved, and all callers
have special case for !is_resolved() state.
2023-07-23 22:25:57 +09:00
Yuya Nishihara
961bb49ff0 refs: leverage Conflict::is_resolved() 2023-07-23 22:25:57 +09:00
Yuya Nishihara
465b8d9cf0 working_copy: remove unused SnapshotError::FileOpenError variant
Perhaps, this would have been generalized as IoError.
2023-07-23 14:58:17 +09:00
Linus Arver
38e6151100 fix zsh completion guidance
We upgraded to clap 4.1 in 8f1dc490 (cargo: upgrade to clap 4.1,
2023-03-17), and the pipe to `sed` was removed in the README.md file in
that same commit. However the documentation was not updated in mod.rs,
which leads us to give the obsolete (now incorrect) advice when we run
`jj util completion --help`.

See #1393.
2023-07-22 21:28:19 -07:00