Commit graph

3436 commits

Author SHA1 Message Date
Yuya Nishihara
db7facb78e tree: rewrite sub_tree_recursive() to not use known_sub_tree()
This is the only place where the caller of known_sub_tree() doesn't know
the full repo path.
2023-06-15 00:45:07 +09:00
Yuya Nishihara
589917a53c repo_path: micro-optimize .join() to not reallocate cloned Vec
While playing with perf.data captured with "jj log", I noticed RepoPath::join()
has measurable cost. The first half is small alloc()s for Vec and Strings, and
the latter is realloc() on Vec::push(). Removing realloc() is easy, so let's
do that.
2023-06-15 00:45:07 +09:00
Martin von Zweigbergk
b01d6cdf5d docs: note how our heads() and roots() revsets differ from hg's 2023-06-14 14:08:58 +02:00
Ilya Grigoriev
d13db728ba README: Delete the section on the rust version
We'll rely on `cargo` informing users instead. The previously confusing
error is hopefully obsolete.
2023-06-13 12:50:47 -07:00
Martin von Zweigbergk
d886d8c203 conflicts: extract methods for converting to/from generic legacy form
We already have the new `Conflict::from_backend_conflict()` for
converting from a `backend::Conflict`, but we model conflicts in a
similar way in at least `RefTarget`. I'd like to be able to use
`conflicts::Conflict` there too. To prepare for that, let's extract
generic methods from `Conflict::from_backend_conflict()` and
`Conflict::to_backend_conflict()`.

I'm not sure I'll get around to making `RefTarget` use `Conflict` but
this commit seems like nice cleanup either way. It makes the tests
simpler if nothing else.
2023-06-13 21:48:35 +02:00
Martin von Zweigbergk
bbbae2c172 conflicts: fix a typo (lossy conflict -> lossy conversion) 2023-06-13 21:48:35 +02:00
Yuya Nishihara
eb4f6a2c92 ui: send progress output to stderr
So the snapshot progress can be displayed even if the main output is
redirected to file.
2023-06-13 21:50:01 +09:00
Yuya Nishihara
bea1ef73e6 ui: create separate io wrapper for progress output
I'm going to redirect progress message to stderr, but the current Ui API
makes it less clear whether the underlying streams of .write*()/.flush()/
.output_guard() are related or not.
2023-06-13 21:50:01 +09:00
Yuya Nishihara
dc7f7fb23d ui: extract term_width() helper as static function
I'll add progress output wrapper which will be used in place of ui object.
2023-06-13 21:50:01 +09:00
Yuya Nishihara
dbe8d3fcdc ui: on progress output, also take pager status into account 2023-06-13 21:50:01 +09:00
Yuya Nishihara
1b0feb913d progress: use common duration constants
New update interval is 33ms, but I don't think that would matter.
2023-06-13 21:38:32 +09:00
Martin von Zweigbergk
02bb3aecf3 tree: don't read file contents on contents/executable "conflict"
If one side changes the contents and one side changes the executable
bit, we get a non-trivial conflict in the `TreeValue`s, but once we've
split them up into `FileId`s and bools, we can trivially resolve them
separately, without having to read file contents.
2023-06-13 08:49:46 +02:00
Martin von Zweigbergk
6e6ca16fd4 tree: make try_resolve_file_conflict() write resolved file to store
The function takes a `&Conflict<Option<TreeValue>>` argument so it
seems it should return an `Option<TreeValue>` for symmetry.
2023-06-13 08:49:46 +02:00
Martin von Zweigbergk
1f1c6867c7 conflicts: add a simplify() method, taken from tree.rs
It seems generally useful to be able to simplify a conflict, and it's
not specific to merging trees, so let's move it to
`conflicts.rs`. Once we're done with the migration to tree-level
conflicts, I think `Conflict::simplify()` will remain but
`tree::simplify_conflict()` will be gone.

The tests I added there are quite similar to those of
`trivial_merge()`. I hope we can make `Conflict::simplify()` call
`trivial_merge()` later. I think it would also make sense to move
`trivial_merge()` onto `Conflict`, or at least have a
`Conflict::resolve_trivial()` calling `trivial_merge()`.
2023-06-13 08:49:46 +02:00
Martin von Zweigbergk
e5a28996b4 tree: specialize and inline tree_value_to_conflict()
It seems that this function didn't serve the purpose I intended it to;
we only passed in `TreeValue::Conflict` variants to it.
2023-06-13 08:49:46 +02:00
Martin von Zweigbergk
ee98d1eee8 tree: remove check for conflict-simplification resulting in deletion
Since we switched to the new `conflicts::Conflict` type, we represent
a missing tree entry by a `None` value in the conflict, not a missing
"add", so the condition removed in this commit will never happen, and
the case will be handled by the case just below it instead.
2023-06-13 08:49:46 +02:00
Martin von Zweigbergk
19fd8a917a conflicts: remove ConflictId from update_conflict_from_content()
For tree-level conflicts (#1624), I plan to remove `ConflictId`
completely. This commit removes `ConflictId` from
`update_conflict_from_content()` by instead making it take a
`Conflict<Option<TreeValue>>` and return a possibly different such
value.

I made the call site in `working_copy` avoid writing the conflict to
the store if it's unchanged, but I didn't make the same optimization
in `merge_tools` becuase it's much more likely to have changed there.
2023-06-13 08:49:46 +02:00
Ilya Grigoriev
096538ba18 revsets: stop jj parsing br as a git_ref refs/heads/br
Use `br@git` instead.

Before, if there is not a local branch `br`, jj tried to resolve
it as a git ref `refs/heads/br`. Unchanged from before, `br` can
still be resolved as a tag `refs/tag/br`.
2023-06-12 14:31:44 -07:00
Ilya Grigoriev
a483252cf2 revset: allow checking out git-tracking (@git) branches 2023-06-12 14:31:44 -07:00
Ilya Grigoriev
d5e8896d1b tests: demo jj branch forget behavior in colocated repos 2023-06-12 14:31:44 -07:00
Ilya Grigoriev
8df945b71d cmd: have jj branch list report git-tracking (@git) branches
This doesn't change the way @git branches are stored in `git_refs` as opposed
to inside `BranchTarget` like normal remote-tracking branches. There are
subtle differences in behavior with e.g. `jj branch forget` and I'm not sure
how easy it is to rewrite `jj git import/export` to support a different
way of storage.

I've decided to call these "local-git tracking branches" since they track
branches in the local git repository. "local git-tracking" branches sounds a
bit more natural, but these could be confused with there are no remote
git-tracking branches. If one had the idea these might exist, they would be
confused with remote-tracking branches in the local git repo.

This addresses a portion of #1666
2023-06-12 14:31:44 -07:00
Waleed Khan
9963879d15 docs(commands): adjust option help text for jj rebase 2023-06-12 14:25:48 -07:00
dependabot[bot]
abe5d098c5 cargo: bump rustix from 0.37.19 to 0.37.20
Bumps [rustix](https://github.com/bytecodealliance/rustix) from 0.37.19 to 0.37.20.
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.37.19...v0.37.20)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-12 12:29:26 -07:00
Yuya Nishihara
6c1e39f3ff ui: ensure progress completion output is flushed
Since stdout is wrapped with LineWriter, we need to explicitly flush the
output. Otherwise the snapshot progress would persist until newline character
is printed.

It might also be better to send progress to stderr?
2023-06-12 20:21:17 +09:00
Ilya Grigoriev
738f99ddf1 test_revset.rs: disable nightly clippy false-positive warning
I opened a bug for the clippy error:
https://github.com/frondeus/test-case/issues/122
2023-06-11 13:11:01 -07:00
Yuya Nishihara
7a6f832e14 operation: iterate ancestors incrementally with timestamp-based heuristic
Suppose the operation log is mostly linear, this means "jj op log" iterator
won't look ahead more than one entry.

Another idea is to either add a "generation" number to operation data, or
build index of operations. Since we'll eventually add GC command, I don't
think op index would be required. I think readdir() is good enough to resolve
hex prefix against ~10k entries.

For now, walk_ancestors() is a free function. If we add Repo-like abstraction
over OpStore + OpHeadsStore, this function will probably be migrated there.
2023-06-11 11:38:03 +09:00
Yuya Nishihara
5cecdb54ce dag_walk: add lazy topo-order iterator for chronological data
The idea is that the DAG can be split at single fork point while walking
chronologically, and run DFS-based topological sort for each sub graph.
This works well for operation log.

We could also build a topo-sort stack while splitting, but we couldn't detect
cycles in that way. It would also be quite expensive on pessimistic cases.
2023-06-11 11:38:03 +09:00
Yuya Nishihara
fb7fff4409 dag_walk: extract topo-order helper that doesn't reverse the result
I'll add an iterator wrapper that pop()s the sorted result.
2023-06-11 11:38:03 +09:00
Yuya Nishihara
4987c74d4b dag_walk: flatten nested loops in topo_order_reverse() 2023-06-11 11:38:03 +09:00
Yuya Nishihara
d9c417dcb8 dag_walk: add a few more tests for topo_order_reverse(), extract callbacks
I'm going to add an iterator version which can load linear part of the
operation history lazily.
2023-06-11 11:38:03 +09:00
Yuya Nishihara
459e9174ad dag_walk: remove unneeded trait bound on node type 2023-06-11 11:38:03 +09:00
dependabot[bot]
04115e8079 github: bump github/codeql-action from 2.3.6 to 2.13.4
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.6 to 2.13.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](83f0fe6c49...cdcdbb5797)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 23:24:18 +02:00
dependabot[bot]
8a7ef3e245 github: bump actions/checkout from 3.5.2 to 3.5.3
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](8e5e7e5ab8...c85c95e3d7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 14:21:58 -07:00
dependabot[bot]
b65439bad9 cargo: bump clap from 4.3.2 to 4.3.3
Bumps [clap](https://github.com/clap-rs/clap) from 4.3.2 to 4.3.3.
- [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.2...v4.3.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 14:19:14 -07:00
dependabot[bot]
840c283cac cargo: bump tempfile from 3.5.0 to 3.6.0
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.5.0 to 3.6.0.
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.5.0...v3.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-08 22:53:55 -07:00
dependabot[bot]
aa18df5265 cargo: bump serde from 1.0.163 to 1.0.164
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.163 to 1.0.164.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.163...v1.0.164)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-08 22:53:35 -07:00
Kevin Liao
44f3cff219 Fix invalid code link 2023-06-09 07:51:52 +02:00
Martin von Zweigbergk
81aa90efd3 merge_tools: leverage ok_or_else() instead of pattern matching 2023-06-07 13:45:16 -07:00
Martin von Zweigbergk
fb3f8b3bd3 merge_tools: check complexity of conflict before reading content
We can know before we read the content if the conflict is too complex
for a merge tool to resolve.
2023-06-07 13:45:16 -07:00
Martin von Zweigbergk
de71df2447 conflicts: move conversion to FileId conflict to callers
This simplifies a bit, in particular by removing the error case from
`extract_file_conflict_as_single_hunk()`.
2023-06-07 13:45:16 -07:00
Martin von Zweigbergk
ad667d6bb5 conflicts: convert TreeValue to FileId conflict to avoid panic!
By converting a `Conflict<Option<TreeValue>>` to a
`Conflict<Option<FileId>>`, we don't have to check later that
`TreeValue` really is a `File`.
2023-06-07 13:45:16 -07:00
Martin von Zweigbergk
ddb07e639c merge_tools: simplify error message for complex conflicts
Since e48ace56d1, the number of adds in the hunk is always exactly
one more than enumber of removes, so we can simplify the condition and
the error message accordingly.
2023-06-07 13:45:16 -07:00
Martin von Zweigbergk
4a0fa4d9a0 cli: simplify calculation of number of sides of conflict
The number of adds (including `None` terms) is now the number of
"sides".
2023-06-07 13:45:16 -07:00
Ilya Grigoriev
337544cf96 No-op clarification of import_export tests 2023-06-07 13:42:48 -07:00
Ilya Grigoriev
fa1e961f53 jj debug operation --display id option to show current operation id for tests
I also considered `jj operation id`, but I'm not sure this is useful outside tests
2023-06-07 13:42:48 -07:00
Ilya Grigoriev
14e19d0692 cmd: move debug commands to a separate debug.rs file
This follows #1061 for consistency. The resulting file is of a similar size to
operation.rs.
2023-06-07 13:42:48 -07:00
Waleed Khan
74b846870c feat(diff): add ui.diff-instructions option to suppress JJ-INSTRUCTIONS file 2023-06-06 22:43:14 -07:00
dependabot[bot]
8f9d72c028 cargo: bump clap from 4.3.1 to 4.3.2
Bumps [clap](https://github.com/clap-rs/clap) from 4.3.1 to 4.3.2.
- [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/clap_complete-v4.3.1...v4.3.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-06 17:19:06 +00:00
dependabot[bot]
0c36b1ad4e cargo: bump libc from 0.2.145 to 0.2.146
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.145 to 0.2.146.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.145...0.2.146)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-06 10:02:08 -07:00
dependabot[bot]
06cd6fbc4e cargo: bump libc from 0.2.144 to 0.2.145
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.144 to 0.2.145.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.144...0.2.145)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-05 16:25:42 +00:00