[PATCH V2] rebase: small refactoring to allow better extensibility from extensions

Laurent Charignon lcharignon at fb.com
Thu Jan 14 19:53:40 UTC 2016


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1452801028 28800
#      Thu Jan 14 11:50:28 2016 -0800
# Node ID 8a8ee8338e6d6e938e4d714beb5ecf559c8532c2
# Parent  443848eece189002c542339dc1cf84f49a94c824
rebase: small refactoring to allow better extensibility from extensions

Inhibit, one of evolve's extension, would like to change the way rebase works
with obsolete changesets. During a rebase with inhibit, the inhibition of the
obsolescence markers should be lifted for the rebase.
With this small refactoring, inhibit and can wrap the _filterobsoleterevs
function to lift inhibition cleanly and at the same time this change makes
rebases' code more legible.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -343,8 +343,7 @@ 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())
+                rebaseobsrevs = _filterobsoleterevs(repo, rebasesetrevs)
                 obsoletenotrebased = _computeobsoletenotrebased(repo,
                                                                 rebaseobsrevs,
                                                                 dest)
@@ -1188,6 +1187,10 @@ def _rebasedvisible(orig, repo):
     blockers.update(getattr(repo, '_rebaseset', ()))
     return blockers
 
+def _filterobsoleterevs(repo, revs):
+    """returns a set of the obsolete revisions in revs"""
+    return set(r for r in revs if repo[r].obsolete())
+
 def _computeobsoletenotrebased(repo, rebaseobsrevs, dest):
     """return a mapping obsolete => successor for all obsolete nodes to be
     rebased that have a successors in the destination


More information about the Mercurial-devel mailing list