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) diffinrange = any(stype == '!' for _, stype in filteredblocks)
return diffinrange, linerange1 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 """Yield ancestors of `fctx` with respect to the block of lines within
`fromline`-`toline` range. `fromline`-`toline` range.
""" """
@ -1175,6 +1175,8 @@ def blockancestors(fctx, fromline, toline):
while visit: while visit:
c, linerange2 = visit.pop(max(visit)) c, linerange2 = visit.pop(max(visit))
pl = c.parents() pl = c.parents()
if followfirst:
pl = pl[:1]
if not pl: if not pl:
# The block originates from the initial revision. # The block originates from the initial revision.
yield c yield c