changeset 52782:a49d6f3c971b

annotate: add test for ancestor check starting revision Python hg annotate currently calls .introfilectx() and uses that for all ancestor checks. This is an unnecessary extra step, and it results in unstable output as shown in the test. It should instead behave like rhg annotate and use the starting revision passed on the command line for ancestor checks. This was discovered here: https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/1179#note_380887
author Mitchell Kember <mkember@janestreet.com>
date Fri, 07 Feb 2025 16:40:22 -0500
parents 6183949219b2
children b3349f6cded9
files tests/test-annotate.t
diffstat 1 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-annotate.t	Fri Jan 24 12:01:12 2025 -0500
+++ b/tests/test-annotate.t	Fri Feb 07 16:40:22 2025 -0500
@@ -1217,6 +1217,60 @@
 
   $ cd ..
 
+Annotate should use the starting revision (-r) as base for ancestor checks.
+TODO: Fix Python, which calls introfilectx() first and uses that for ancestor checks.
+
+  $ hg init repo-base
+  $ cd repo-base
+  $ echo A > file
+  $ hg commit -Am "initial"
+  adding file
+  $ echo B >> file
+  $ hg commit -m "linkrev"
+  $ hg up 0
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo B >> file
+  $ hg ci -m "linkrev alias"
+  created new head
+  $ echo C >> file
+  $ hg commit -m "change"
+  $ hg merge 1 --tool :local
+  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg commit -m "merge"
+  $ hg debugindex file
+     rev linkrev       nodeid    p1-nodeid    p2-nodeid
+       0       0 45f17b21388f 000000000000 000000000000
+       1       1 e338fefefb89 45f17b21388f 000000000000
+       2       3 b2f3b2eded93 e338fefefb89 000000000000
+  $ hg log -G --template '{rev}: {desc}'
+  @    4: merge
+  |\
+  | o  3: change
+  | |
+  | o  2: linkrev alias
+  | |
+  o |  1: linkrev
+  |/
+  o  0: initial
+  
+Line B should be attributed to the linkrev 1, because we base ancestor checks
+from 4 (starting revision), not from 3 (most recent change to the file).
+  $ hg annotate file
+  0: A
+  2: B (no-rhg known-bad-output !)
+  1: B (rhg !)
+  3: C
+  $ echo D >> file
+  $ hg commit -m "another change"
+  $ hg annotate file
+  0: A
+  1: B
+  3: C
+  5: D
+
+  $ cd ..
+
 Issue5360: Deleted chunk in p1 of a merge changeset
 
   $ hg init repo-5360