Patchwork [1,of,3,V3] rebase: minor refactoring of _computeobsoletenotrebased

login
register
mail settings
Submitter Laurent Charignon
Date Jan. 12, 2016, 9:44 p.m.
Message ID <b268c1df481854a6dcb6.1452635063@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/12710/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Laurent Charignon - Jan. 12, 2016, 9:44 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1452113756 28800
#      Wed Jan 06 12:55:56 2016 -0800
# Node ID b268c1df481854a6dcb6ac3ec7bb30a6c24ba7e9
# Parent  b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a
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.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -343,8 +343,10 @@  def rebase(ui, repo, **opts):
             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 @@  def _rebasedvisible(orig, repo):
     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 @@  def _computeobsoletenotrebased(repo, reb
     # 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