[PATCH 1 of 8] test-log: test that fctx.ancestors() can't index parents only by linkrev

Yuya Nishihara yuya at tcha.org
Wed Dec 6 10:05:45 EST 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1474527129 -32400
#      Thu Sep 22 15:52:09 2016 +0900
# Node ID 1bccb52bee2a1c8fee2d208f28c25a9e063aaf61
# Parent  cb0df5a3affba6e8f1789de337230cbeecda9c5a
test-log: test that fctx.ancestors() can't index parents only by linkrev

This covers a possible bug that could be caused by the following change:

  --- a/mercurial/context.py
  +++ b/mercurial/context.py
  @@ -1047,7 +1047,7 @@ class basefilectx(object):

           while True:
               for parent in c.parents()[:cut]:
  -                visit[(parent.linkrev(), parent.filenode())] = parent
  +                visit[parent.linkrev()] = parent
               if not visit:
                   break
               c = visit.pop(max(visit))

diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1009,6 +1009,77 @@ log --follow --patch FILE in repository 
 
   $ cd ..
 
+Multiple copy sources of a file:
+
+  $ hg init follow-multi
+  $ cd follow-multi
+  $ echo 0 >> a
+  $ hg ci -qAm 'a'
+  $ hg cp a b
+  $ hg ci -m 'a->b'
+  $ echo 2 >> a
+  $ hg ci -m 'a'
+  $ echo 3 >> b
+  $ hg ci -m 'b'
+  $ echo 4 >> a
+  $ echo 4 >> b
+  $ hg ci -m 'a,b'
+  $ echo 5 >> a
+  $ hg ci -m 'a0'
+  $ echo 6 >> b
+  $ hg ci -m 'b0'
+  $ hg up -q 4
+  $ echo 7 >> b
+  $ hg ci -m 'b1'
+  created new head
+  $ echo 8 >> a
+  $ hg ci -m 'a1'
+  $ hg rm a
+  $ hg mv b a
+  $ hg ci -m 'b1->a1'
+  $ hg merge -qt :local
+  $ hg ci -m '(a0,b1->a1)->a'
+
+  $ hg log -GT '{rev}: {desc}\n'
+  @    10: (a0,b1->a1)->a
+  |\
+  | o  9: b1->a1
+  | |
+  | o  8: a1
+  | |
+  | o  7: b1
+  | |
+  o |  6: b0
+  | |
+  o |  5: a0
+  |/
+  o  4: a,b
+  |
+  o  3: b
+  |
+  o  2: a
+  |
+  o  1: a->b
+  |
+  o  0: a
+  
+
+ since file 'a' has multiple copy sources at the revision 4, ancestors can't
+ be indexed solely by fctx.linkrev().
+
+  $ hg log -T '{rev}: {desc}\n' -f a
+  10: (a0,b1->a1)->a
+  9: b1->a1
+  7: b1
+  5: a0
+  4: a,b
+  3: b
+  2: a
+  1: a->b
+  0: a
+
+  $ cd ..
+
 Test that log should respect the order of -rREV even if multiple OR conditions
 are specified (issue5100):
 


More information about the Mercurial-devel mailing list