# HG changeset patch # User Pierre-Yves David # Date 2012-09-18 20:58:12 # Node ID 910123eac887ad65430cc0a454f9c7640a9f9c31 # Parent d0afa149e059cea15ffe245ff5307a4a905f7e38 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. diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -310,15 +310,7 @@ def rebase(ui, repo, **opts): 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 @@ def buildstate(repo, dest, rebaseset, co 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'):