# HG changeset patch # User Denis Laxalde # Date 2017-01-16 16:08:25 # Node ID 21f1f97ab2123c27b2d09b9f9dc2e68af3fe10a9 # Parent 2912b06905dceb4fd668cd0a8d815ac9a001664b context: add a followfirst flag to blockancestors diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1166,7 +1166,7 @@ def _changesrange(fctx1, fctx2, linerang 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 @@ def blockancestors(fctx, fromline, tolin 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