rebase: extract final changesets cleanup logic in a dedicated function
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 18 Sep 2012 22:58:12 +0200
changeset 17611 910123eac887
parent 17610 d0afa149e059
child 17612 fc2a6114f0a0
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.
hgext/rebase.py
--- 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'):