changeset 31075:21f1f97ab212

context: add a followfirst flag to blockancestors
author Denis Laxalde <denis.laxalde@logilab.fr>
date Mon, 16 Jan 2017 17:08:25 +0100
parents 2912b06905dc
children 0e07855e6054
files mercurial/context.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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