context: add a followfirst flag to blockancestors
authorDenis Laxalde <denis.laxalde@logilab.fr>
Mon, 16 Jan 2017 17:08:25 +0100
changeset 31075 21f1f97ab212
parent 31074 2912b06905dc
child 31076 0e07855e6054
context: add a followfirst flag to blockancestors
mercurial/context.py
--- a/mercurial/context.py	Mon Feb 20 18:40:42 2017 +0530
+++ b/mercurial/context.py	Mon Jan 16 17:08:25 2017 +0100
@@ -1166,7 +1166,7 @@
     diffinrange = any(stype == '!' for _, stype in filteredblocks)
     return diffinrange, linerange1
 
-def blockancestors(fctx, fromline, toline):
+def blockancestors(fctx, fromline, toline, followfirst=False):
     """Yield ancestors of `fctx` with respect to the block of lines within
     `fromline`-`toline` range.
     """
@@ -1175,6 +1175,8 @@
     while visit:
         c, linerange2 = visit.pop(max(visit))
         pl = c.parents()
+        if followfirst:
+            pl = pl[:1]
         if not pl:
             # The block originates from the initial revision.
             yield c