Mercurial > evolve
comparison hgext/evolve.py @ 1423:ecd669c36c12
evolve: non recursive implementation for _aspiringdescendants
We switch from a N squared recursive implementation for _aspiringdescendants
to a more efficient algorithm in O(len(unstable)).
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 23 Jun 2015 00:00:03 -0700 |
parents | c868a69c29c5 |
children | 6db55f28c965 |
comparison
equal
deleted
inserted
replaced
1422:c868a69c29c5 | 1423:ecd669c36c12 |
---|---|
1630 def _aspiringdescendant(repo, revs): | 1630 def _aspiringdescendant(repo, revs): |
1631 """Return a list of changectx which can be stabilized on top of pctx or | 1631 """Return a list of changectx which can be stabilized on top of pctx or |
1632 one of its descendants recursively. Empty list if none can be found.""" | 1632 one of its descendants recursively. Empty list if none can be found.""" |
1633 target = set(revs) | 1633 target = set(revs) |
1634 result = set(target) | 1634 result = set(target) |
1635 sizeresult = 0 | 1635 paths = collections.defaultdict(set) |
1636 while sizeresult != len(result): | 1636 for r in repo.revs('unstable() - %ld', revs): |
1637 sizeresult = len(result) | 1637 for d in _possibledestination(repo, r): |
1638 result.update(_aspiringchildren(repo, result)) | 1638 paths[d].add(r) |
1639 | |
1640 result = set(target) | |
1641 tovisit = list(revs) | |
1642 while tovisit: | |
1643 base = tovisit.pop() | |
1644 for unstable in paths[base]: | |
1645 if unstable not in result: | |
1646 tovisit.append(unstable) | |
1647 result.add(unstable) | |
1639 return sorted(result - target) | 1648 return sorted(result - target) |
1640 | 1649 |
1641 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False, | 1650 def _solveunstable(ui, repo, orig, dryrun=False, confirm=False, |
1642 progresscb=None): | 1651 progresscb=None): |
1643 """Stabilize a unstable changeset""" | 1652 """Stabilize a unstable changeset""" |