rebase: minor refactoring of _computeobsoletenotrebased
authorLaurent Charignon <lcharignon@fb.com>
Wed, 06 Jan 2016 12:55:56 -0800
changeset 27744 f2b8b4e2de20
parent 27743 5dcadc6c5aed
child 27745 d3a128e8604a
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.
hgext/rebase.py
--- 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