D899: annotate: track whether a particular annotation was the result of a skip

sid0 (Siddharth Agarwal) phabricator at mercurial-scm.org
Mon Oct 2 09:35:35 UTC 2017


sid0 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We're going to expose this information in the UI in an upcoming patch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D899

AFFECTED FILES
  mercurial/context.py
  tests/test-annotate.py

CHANGE DETAILS

diff --git a/tests/test-annotate.py b/tests/test-annotate.py
--- a/tests/test-annotate.py
+++ b/tests/test-annotate.py
@@ -80,20 +80,20 @@
                                  diffopts)
         self.assertEqual(childann[0], [
             annotateline('old', 1),
-            annotateline('old', 2),
-            annotateline('p2', 2),
-            annotateline('p2', 2),
+            annotateline('old', 2, True),
+            annotateline('p2', 2, True),
+            annotateline('p2', 2, True),
             annotateline('p2', 3),
         ])
 
         childann = decorate(childdata, childfctx)
         childann = _annotatepair([p2ann, p1ann], childfctx, childann, True,
                                  diffopts)
         self.assertEqual(childann[0], [
             annotateline('old', 1),
-            annotateline('old', 2),
-            annotateline('p1', 3),
-            annotateline('p1', 3),
+            annotateline('old', 2, True),
+            annotateline('p1', 3, True),
+            annotateline('p1', 3, True),
             annotateline('p2', 3),
         ])
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1111,6 +1111,8 @@
 class annotateline(object):
     fctx = attr.ib()
     lineno = attr.ib(default=False)
+    # Whether this annotation was the result of a skip-annotate.
+    skip = attr.ib(default=False)
 
 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
     r'''
@@ -1160,6 +1162,7 @@
                         if child[0][bk].fctx == childfctx:
                             ak = min(a1 + (bk - b1), a2 - 1)
                             child[0][bk] = parent[0][ak]
+                            child[0][bk].skip = True
                 else:
                     remaining[idx][1].append((a1, a2, b1, b2))
 
@@ -1171,6 +1174,7 @@
                     if child[0][bk].fctx == childfctx:
                         ak = min(a1 + (bk - b1), a2 - 1)
                         child[0][bk] = parent[0][ak]
+                        child[0][bk].skip = True
     return child
 
 class filectx(basefilectx):



To: sid0, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list