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

3171 commits

Author SHA1 Message Date
Yuya Nishihara
11b9888cdf refs: retry trivial resolution after merging targets
This helps resolve diverged refs by abandoning both sides:

    D  ref = [D]
    |\
    | C       C  ref = [B - D + C]
    | |       |
    B |     B |     B  ref = [B - D + A]
    |/      |/      |
    A       A       A       A  ref = [A - D + A]
2024-09-02 09:20:16 +09:00
Yuya Nishihara
982ee63ba8 rewrite: remove redundant workspace lookup from update_all_references() 2024-09-02 09:20:05 +09:00
Yuya Nishihara
38bd5fbf32 rewrite: use intersperse() to interleave new/old commit ids
This is stricter than from_legacy_from() in that wrong number of add/remove
terms will panic.
2024-09-02 09:20:05 +09:00
Yuya Nishihara
1b6617bbd7 rewrite: remove redundant branch lookup from update_all_references()
It no longer makes sense to look up branches by old_commit_id. Just loop over
branch (name, target) pairs instead.
2024-09-02 09:20:05 +09:00
Martin von Zweigbergk
781351e4d0 local_working_copy: delete obsolete comment about libgit2
We have not used libgit2 for gitignores since commit 88f7f473
(2021-05-13).
2024-08-31 19:15:28 -07:00
Yuya Nishihara
8e500c0182 rewrite: do not resolve transitive parents repeatedly when updating refs
This was quadratic before, and was super slow if thousands of commits were
abandoned.

#4352
2024-09-01 11:11:12 +09:00
Yuya Nishihara
cb16b5afd0 rewrite: ensure that rewritten refs move across divergent entries
This is closer to the original behavior before 5e8d7f8c "rewrite: update
references after rewriting all commits." References can move to divergent
commits, so they should propagate further if there are more rewrites. See
the inline comment for subtle behavior difference.

We could instead replay parent_mapping in topological order, but we would
still need to flatten abandon records.
2024-09-01 11:11:12 +09:00
Yuya Nishihara
780692c2f1 rewrite: extract new_parents() that doesn't ignore divergent entries
I'll use this in debug assertion. The extracted function is not named as
new_parents_with() because it's not really about parents.
2024-09-01 11:11:12 +09:00
Martin von Zweigbergk
cc15ecf7c7 op log: change "resolve concurrent" to "reconcile divergent"
"Concurrent" operations are not necessarily actually concurrent, so
"divergent" seems like a better name. And "reconcile" seems like a
better term for merging them, though we also sometimes use "merge".
2024-08-30 21:56:11 -07:00
dploch
f963af3f16 workspace: turn WorkspaceLoader into a trait
Like https://github.com/martinvonz/jj/pull/4189, this allows extensions the ability to load the repo in an environment where the local filesystem is not accessible. This change allows such extensions to exist at the CLI layer where jj is invoked as a subprocess, rather than a library (common in testing).
2024-08-30 13:35:52 -04:00
Yuya Nishihara
db6a58d315 store: switch in-memory cache to LRU-based HashMap to cap memory usage
I just choose "clru" because it already exists in our dependency tree thorough
gix. I don't think LRU is the best cache eviction policy for our use case (a
simpler FIFO-based one might be good enough?), but it wouldn't matter for CLI
or GUI use case. I don't see significant performance degradation with "jj log
--stat -n1000".

RwLock is replaced with Mutex since get() is inherently a mutable operation.
2024-08-29 23:33:37 +09:00
Yuya Nishihara
424623ba91 cargo: add "clru" dependency 2024-08-29 23:33:37 +09:00
Yuya Nishihara
d99a8508e4 rewrite: pass old parent ids in to mut_repo.new_parents() by slice 2024-08-29 08:59:22 +09:00
Yuya Nishihara
1fe9422a6e rewrite: deduplicate parent ids per remap iteration
If merge-heavy history was abandoned, intermediate parent chains can have tons
of duplicates, and the process explodes soon. Instead, we can skip any parent
ids that have been remapped.

We can no longer detect cycles reliably, but I think that's okay so long as
the function terminates.

Fixes #4352
2024-08-29 08:59:22 +09:00
Yuya Nishihara
d76d4a90a7 rewrite: flip inner/outer loops of mut_repo.new_parents()
This is basically a DFS to find leaf nodes. It will help omit duplicated
parent ids early.
2024-08-29 08:59:22 +09:00
Yuya Nishihara
9c9e564dc4 conflicts: pass around conflict contents without materialization
We haven't decided how conflict diffs should be rendered, but whatever style
we'll choose, we'll need raw unmaterialized conflict contents.
2024-08-28 10:23:57 +09:00
Yuya Nishihara
73a8b13e4c conflicts: split materialized value to FileConflict and OtherConflict
FileConflict will be changed to not materialize Merge<BString>. I also updated
the revset engine to ignore non-file conflict. It doesn't make sense to grep
conflict description.
2024-08-28 10:23:57 +09:00
Yuya Nishihara
0c14a0a9ca conflicts: make describe() simply return string
I'll add more callers of id.describe(), and the output size wouldn't be large
enough to avoid allocation by using Write API.
2024-08-28 10:23:57 +09:00
Yuya Nishihara
1ba581b37c conflicts: replace ContentHunk with BString
ContentHunk is basically a nice wrapper around Vec<u8>. I think it would give
little benefit for type safety.
2024-08-28 10:23:57 +09:00
Martin von Zweigbergk
acdcb578bc copies: in unsupported backends, return an empty stream instead of error
The native backend currently errors out if you ask it about copies. So
does the test backend. I think it's better to return an empty stream
of copies so it doesn't prevent other functionality.
2024-08-23 18:51:02 -07:00
Yuya Nishihara
87fb169266 cleanup: remove redundant ::{self} from use declarations 2024-08-23 13:05:27 +09:00
Yuya Nishihara
f5187fa063 copies: determine copy/rename operation by CopiesTreeDiffStream
Not all callers need this information, but I assumed it's relatively cheap to
look up the source path in the target tree compared to diffing.

This could be represented as Regular(_)|Copied(_, _)|Renamed(_, _), but it's
a bit weird if Copied and Renamed were separate variants. Instead, I decided
to wrap copy metadata in Option.
2024-08-23 10:29:12 +09:00
Yuya Nishihara
b6060ce6dd copies: wrap source path in Option to save allocation
Most diff entries should have no copy sources.
2024-08-23 10:29:12 +09:00
Yuya Nishihara
08262eb152 copies: extract (source, target) path pair to separate type
This patch adds accessor methods as I'm going to change the underlying data
types. Since entry values are consumed separately, these methods are implemented
on CopiesTreeDiffEntryPath, not on *TreeDiffEntry.
2024-08-23 10:29:12 +09:00
Yuya Nishihara
43bf195314 merged_tree: rename diff entry field from "value" to "values"
It seems a slightly better, and aligns with the local variable name in
materialized_diff_stream().
2024-08-23 10:29:12 +09:00
Yuya Nishihara
10cbb513fa copies: define CopiesTreeDiffEntry struct before stream type
I'm going to add some methods, and I don't want to insert them in between
the stream type and impls.
2024-08-23 10:29:12 +09:00
Matt Kulukundis
e67aac6d5c Update dependencies and bump the version for gix 2024-08-22 20:06:34 -04:00
Matt Kulukundis
8ead72e99f formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
Yuya Nishihara
352a4a0eea copies: filter rename source entries by CopiesTreeDiffStream 2024-08-22 20:17:19 +09:00
Yuya Nishihara
47ff9ad231 copies: break method chaining in CopiesTreeDiffStream::poll_next()
So that it can be wrapped within a while loop + continue.
2024-08-22 20:17:19 +09:00
Yuya Nishihara
2cffcc9323 copies: provide source path mapping by CopyRecords
All for/has_source/target() combinations are added for API consistency.
2024-08-22 20:17:19 +09:00
Yuya Nishihara
d85e66bbb4 copies: turn add_records() into non-stream API, block_on_stream() by caller
This is simpler, and I think it's generally better to not spawn executor in
library code.
2024-08-22 20:17:19 +09:00
Martin von Zweigbergk
3acb89e7cc merged_tree: remove TreeDiffEntry::source 2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
721aa1238c copies: add a separate diff stream item type with copy info
The goal is to have the new item type know if it represent a copy, a
rename, a deleted rename source, or a regular copy-unrelated item.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
70598498b0 merged_tree: provide separate version of diff_stream() with copy info
I plan to provide a richer version of `TreeDiffEntry` with copy info
(and to make `TreeDiffEntry` itself "poorer"). Most callers want to
know about copies/renames, but at least working copy implementations
probably don't. This patch adds separate `diff_stream()` and
`diff_stream_with_copies()` so we can provide the simpler interface
for callers that don't need copy info.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
bce8550db1 merged_tree: inline next_impl() and poll_next_impl() 2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
ad86dd1c1b copies: inline adjust_for_copy_tracking()
We now have only one caller, and it's in a different module, so it
makes more sense to move it there.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
e670837ff6 copies: implement copy support in MergedTree::diff_stream() as adapter
The support for copy tracing is already simply added to the stream
just before yielding the item, so we can easily implement it as a
stream adapter. That ensures that we use the same logic for the
iterator- and stream-based versions. More importantly, it enables
further cleanups and a simpler interface.
2024-08-18 22:16:41 -07:00
Martin von Zweigbergk
fd9a236be5 copies: move CopyRecords to new copies module
Copy/rename handling is complicated. It seems worth having a module
for it. I'm going to add more content to it next.
2024-08-18 22:16:41 -07:00
Yuya Nishihara
6101a66a76 diff: inline Diff::default_refinement() in diff()
There are no callers other than tests and benches.
2024-08-19 11:54:58 +09:00
Yuya Nishihara
864dd73856 tests: use diff::diff() instead of Diff::default_refinement()
Diff::default_refinement() will be removed.
2024-08-19 11:54:58 +09:00
Yuya Nishihara
db0a4bccc5 diff: make diff() function accept any number of inputs
So that more tests can leverage diff::diff() helper.

I also removed the fast path for identical inputs. This function is only used by
tests and benches, and production code usually compares content hashes first.
2024-08-19 11:54:58 +09:00
Martin von Zweigbergk
aa0fbd9f3f drop "support" for legacy tree config
The tree-level conflicts have worked well in practice and we don't
want to allow users to use legacy trees for new commits. We don't
really support legacy trees very well since 0590f8bece anyway.
2024-08-18 07:19:50 -07:00
Yuya Nishihara
59745fb67f files: allow DiffLineIterator users to specify and retrieve line numbers
The added functions will be used in order to iterate middle hunks which don't
start from line_number = 1.
2024-08-18 12:40:07 +09:00
Yuya Nishihara
2be8e596e2 diff: extract Diff::by_word() function
I'm going to split color-words diffs to by_line() and by_word() stages.

Perhaps, Diff::default_refinement() can be removed once all non-test callers
are migrated.
2024-08-18 12:40:07 +09:00
Benjamin Tan
f258664a2f rewrite: move_commits: do not remove parents of target commits which are outside the target set
This ensures consistency between the commands `jj rebase -r a::` and `jj
rebase -s a`.
2024-08-17 23:27:47 +08:00
Martin von Zweigbergk
749a284354 working_copy: delete path() method from trait
We don't currently use the `path()` method. Not all working copies
even have a relevant path. For example, working copies on Google's
server don't.
2024-08-16 16:55:14 -07:00
Yuya Nishihara
085e17e1cc files: micro-optimzie DiffLine::reset_line() to not clone hunks 2024-08-16 09:30:30 +09:00
Yuya Nishihara
a973c7b0ea files: replace precomputed has_left/right_content flags with functions
I don't think the iteration cost would matter here, and it doesn't make sense
that has_left/right_content are cached whereas is_unmodified() isn't.
2024-08-16 09:30:30 +09:00
Yuya Nishihara
cca5277184 diff: clarify that DiffLine hunk doesn't have [left, right] diff pair
This will simplify users of line.hunks[] which I'm going to add.
2024-08-16 09:30:30 +09:00