changeset 17611:910123eac887

rebase: extract final changesets cleanup logic in a dedicated function At the end of the rebase, rebased changesets are currently stripped. This behavior will be eventually dropped in favor of obsolescence marker creation. The main rebase function is already big and branchy enough. This changeset move the clean-up logic in a dedicated function before we make it more complex.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 18 Sep 2012 22:58:12 +0200
parents d0afa149e059
children fc2a6114f0a0
files hgext/rebase.py
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Sep 18 14:37:32 2012 -0700
+++ b/hgext/rebase.py	Tue Sep 18 22:58:12 2012 +0200
@@ -310,15 +310,7 @@
                     nstate[repo[k].node()] = repo[v].node()
 
         if not keepf:
-            # Remove no more useful revisions
-            rebased = [rev for rev in state if state[rev] != nullmerge]
-            if rebased:
-                if set(repo.changelog.descendants([min(rebased)])) - set(state):
-                    ui.warn(_("warning: new changesets detected "
-                              "on source branch, not stripping\n"))
-                else:
-                    # backup the old csets by default
-                    repair.strip(ui, repo, repo[min(rebased)].node(), "all")
+            clearrebased(ui, repo, state)
 
         if currentbookmarks:
             updatebookmarks(repo, nstate, currentbookmarks, **opts)
@@ -664,6 +656,18 @@
         state.update(dict.fromkeys(detachset, nullmerge))
     return repo['.'].rev(), dest.rev(), state
 
+def clearrebased(ui, repo, state):
+    """dispose of rebased revision at the end of the rebase"""
+    rebased = [rev for rev in state if state[rev] != nullmerge]
+    if rebased:
+        if set(repo.changelog.descendants([min(rebased)])) - set(state):
+            ui.warn(_("warning: new changesets detected "
+                      "on source branch, not stripping\n"))
+        else:
+            # backup the old csets by default
+            repair.strip(ui, repo, repo[min(rebased)].node(), "all")
+
+
 def pullrebase(orig, ui, repo, *args, **opts):
     'Call rebase after pull if the latter has been invoked with --rebase'
     if opts.get('rebase'):