context: add a followfirst flag to blockancestors

This commit is contained in:
Denis Laxalde 2017-01-16 17:08:25 +01:00
parent 22dbb9466c
commit d3bcba7d25

View File

@ -1166,7 +1166,7 @@ def _changesrange(fctx1, fctx2, linerange2, diffopts):
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, toline):
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