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.
--- 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'):