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

login
register
mail settings
Submitter Laurent Charignon
Date Jan. 14, 2016, 7:53 p.m.
Message ID <8a8ee8338e6d6e938e4d.1452801220@lcharignon-mbp.dhcp.thefacebook.com>
Download mbox | patch
Permalink /patch/12765/
State Accepted
Headers show

Comments

Laurent Charignon - Jan. 14, 2016, 7:53 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@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.
Martin von Zweigbergk - Jan. 15, 2016, 5:40 a.m.
On Thu, Jan 14, 2016 at 11:53 AM, Laurent Charignon <lcharignon@fb.com> wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@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

Thanks, I've verified that this fixes the broken evolve extension
together with the fix to the extension. Pushed to the clowncopter.

Patch

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