12 Commits

Author SHA1 Message Date
Yuya Nishihara
fc5f90c4ac annotate: reorganize functions as restartable process
I don't have any plan to implement incremental UI for file annotation, but I
think the new API is nicer in that they have fewer function arguments.

Note that this wouldn't help implement interactive UI to go ancestor annotation
by clicking annotated line. To achieve that cheaply, we'll need weave-like data.
2025-04-21 12:38:38 +00:00
Martin von Zweigbergk
f0545ee25c test: introduce test helpers for creating repo path types
I'm about to make the constructors return a `Result`. The helpers will
hide the unwrapping.
2025-04-15 14:42:23 +00:00
Yuya Nishihara
ec6c5235d5 annotate: report root commit id if no origin found within range
Suppose we add "jj file annotate" option to specify the search domain or depth,
the root commit within the range can be displayed as the boundary commit. "git
blame" for example displays boundary commits with ^ prefix.

This follows up 85e0a8b0687e "annotate: add option to not search all ancestors
of starting commit."
2025-03-17 10:57:33 +00:00
Yuya Nishihara
a27d925565 cleanup: switch to use<'_> capturing syntax
This patch fixes `'a: 'b, 'a` lifetime constraints, adds use<>, use<'_>, etc.
where the default would differ between editions. Redundant '_ is also removed.

https://doc.rust-lang.org/stable/edition-guide/rust-2024/rpit-lifetime-capture.html#edition-specific-rules-when-no-use-bound-is-present
2025-03-08 01:16:56 +00:00
Ilya Grigoriev
5eae2d92a0 tests: run insta --force-update-snapshots
This is a replacement for #5558.

Thanks to @yuja 's https://github.com/mitsuhiko/insta/pull/722, this is
now easy to generate.
2025-03-06 21:35:08 +00:00
Yuya Nishihara
cff73841ed repo: remove &UserSettings argument from new/rewrite_commit(), use self.settings 2024-12-31 10:51:57 +09:00
Yuya Nishihara
14b52205fb repo: remove &UserSettings argument from start_transaction(), use self.settings 2024-12-31 10:51:57 +09:00
Yuya Nishihara
077bac8be1 annotate: add low-level function to specify starting file content
In "jj absorb", we'll need to calculate annotation from the parent tree. It's
usually identical to the tree of the parent commit, but this is not true for a
merge commit. Since I'm not sure how we'll process conflict trees in general,
this patch adds a minimal API to specify a single file content, not a
MergedTree.
2024-11-12 08:26:42 +09:00
Yuya Nishihara
85e0a8b068 annotate: add option to not search all ancestors of starting commit
The primary use case is to exclude immutable commits when calculating line
ranges to absorb. For example, "jj absorb" will build annotation of @ revision
with domain = mutable().
2024-11-12 08:26:42 +09:00
Yuya Nishihara
ab10b7c0a0 annotate: do not collect result lines into Vec, return Iterator instead
We might want to calculate (commit_id, range) pairs of consecutive lines in
order to "absorb" changes, for example.

This should also be cheaper since Vec<u8> doesn't have to be allocated per line.
2024-10-29 23:33:46 +09:00
Yuya Nishihara
bd1024547d annotate: use sorted Vec<(usize, usize)> to propagate lines to ancestors
This isn't so complicated compared to the HashMap version, and we can handle
multiple (cur, orig1), (cur, orig2) pairs. It's also cheaper to access.
2024-10-29 14:57:57 +09:00
Yuya Nishihara
b485881d50 tests: add basic tests for annotation function 2024-10-27 22:51:54 +09:00