Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
31954:e518192d6bac | 31955:4c2c30bc38b4 |
---|---|
1215 diffopts = patch.diffopts(fctx._repo.ui) | 1215 diffopts = patch.diffopts(fctx._repo.ui) |
1216 fl = fctx.filelog() | 1216 fl = fctx.filelog() |
1217 seen = {fctx.filerev(): (fctx, (fromline, toline))} | 1217 seen = {fctx.filerev(): (fctx, (fromline, toline))} |
1218 for i in fl.descendants([fctx.filerev()]): | 1218 for i in fl.descendants([fctx.filerev()]): |
1219 c = fctx.filectx(i) | 1219 c = fctx.filectx(i) |
1220 inrange = False | |
1220 for x in fl.parentrevs(i): | 1221 for x in fl.parentrevs(i): |
1221 try: | 1222 try: |
1222 p, linerange2 = seen.pop(x) | 1223 p, linerange2 = seen[x] |
1223 except KeyError: | 1224 except KeyError: |
1224 # nullrev or other branch | 1225 # nullrev or other branch |
1225 continue | 1226 continue |
1226 inrange, linerange1 = _changesrange(c, p, linerange2, diffopts) | 1227 inrangep, linerange1 = _changesrange(c, p, linerange2, diffopts) |
1227 if inrange: | 1228 inrange = inrange or inrangep |
1228 yield c, linerange1 | |
1229 seen[i] = c, linerange1 | 1229 seen[i] = c, linerange1 |
1230 if inrange: | |
1231 yield c, linerange1 | |
1230 | 1232 |
1231 class committablectx(basectx): | 1233 class committablectx(basectx): |
1232 """A committablectx object provides common functionality for a context that | 1234 """A committablectx object provides common functionality for a context that |
1233 wants the ability to commit, e.g. workingctx or memctx.""" | 1235 wants the ability to commit, e.g. workingctx or memctx.""" |
1234 def __init__(self, repo, text="", user=None, date=None, extra=None, | 1236 def __init__(self, repo, text="", user=None, date=None, extra=None, |