rebase: minor refactoring of _computeobsoletenotrebased
This patch is a refactoring of the code skipping obsolete changesets already
present in destination. It makes the following patches more legible.
Instead of passing all the revs to be rebased to _computeobsoletenotrebased,
we only pass the obsolete revisions of the rebaseset.
--- a/hgext/rebase.py Wed Jan 13 00:09:26 2016 -0500
+++ b/hgext/rebase.py Wed Jan 06 12:55:56 2016 -0800
@@ -343,8 +343,10 @@
obsoletenotrebased = {}
if ui.configbool('experimental', 'rebaseskipobsolete'):
rebasesetrevs = set(rebaseset)
+ rebaseobsrevs = set(r for r in rebasesetrevs
+ if repo[r].obsolete())
obsoletenotrebased = _computeobsoletenotrebased(repo,
- rebasesetrevs,
+ rebaseobsrevs,
dest)
# - plain prune (no successor) changesets are rebased
@@ -1174,7 +1176,7 @@
blockers.update(getattr(repo, '_rebaseset', ()))
return blockers
-def _computeobsoletenotrebased(repo, rebasesetrevs, dest):
+def _computeobsoletenotrebased(repo, rebaseobsrevs, dest):
"""return a mapping obsolete => successor for all obsolete nodes to be
rebased that have a successors in the destination
@@ -1185,15 +1187,13 @@
# nodes to be rebased
allsuccessors = {}
cl = repo.changelog
- for r in rebasesetrevs:
- n = repo[r]
- if n.obsolete():
- node = cl.node(r)
- for s in obsolete.allsuccessors(repo.obsstore, [node]):
- try:
- allsuccessors[cl.rev(s)] = cl.rev(node)
- except LookupError:
- pass
+ for r in rebaseobsrevs:
+ node = cl.node(r)
+ for s in obsolete.allsuccessors(repo.obsstore, [node]):
+ try:
+ allsuccessors[cl.rev(s)] = cl.rev(node)
+ except LookupError:
+ pass
if allsuccessors:
# Look for successors of obsolete nodes to be rebased among