Mercurial > public > mercurial-scm > hg-stable
diff mercurial/context.py @ 31955:4c2c30bc38b4
context: follow all branches in blockdescendants()
In the initial implementation of blockdescendants (and thus followlines(...,
descend=True) revset), only the first branch encountered in descending
direction was followed.
Update the algorithm so that all children of a revision ('x' in code) are
considered. Accordingly, we need to prevent a child revision to be yielded
multiple times when it gets visited through different path, so we skip 'i'
when this occurs. Finally, since we now consider all parents of a possible
child touching a given line range, we take care of yielding the child if it
has a diff in specified line range with at least one of its parent (same logic
as blockancestors()).
author | Denis Laxalde <denis@laxalde.org> |
---|---|
date | Fri, 14 Apr 2017 08:55:18 +0200 |
parents | 826e600605f6 |
children | 55987fc8aba1 |
line wrap: on
line diff
--- a/mercurial/context.py Thu Apr 13 08:27:19 2017 -0700 +++ b/mercurial/context.py Fri Apr 14 08:55:18 2017 +0200 @@ -1217,16 +1217,18 @@ seen = {fctx.filerev(): (fctx, (fromline, toline))} for i in fl.descendants([fctx.filerev()]): c = fctx.filectx(i) + inrange = False for x in fl.parentrevs(i): try: - p, linerange2 = seen.pop(x) + p, linerange2 = seen[x] except KeyError: # nullrev or other branch continue - inrange, linerange1 = _changesrange(c, p, linerange2, diffopts) - if inrange: - yield c, linerange1 + inrangep, linerange1 = _changesrange(c, p, linerange2, diffopts) + inrange = inrange or inrangep seen[i] = c, linerange1 + if inrange: + yield c, linerange1 class committablectx(basectx): """A committablectx object provides common functionality for a context that