Patchwork [2,of,3,V2] rebase: add a 'revtodo' constant

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 4, 2014, 3:29 p.m.
Message ID <f1632814e8d3733acec3.1417706996@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7004/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 4, 2014, 3:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1417542380 28800
#      Tue Dec 02 09:46:20 2014 -0800
# Node ID f1632814e8d3733acec372dcc17620ab0a8617bf
# Parent  29392f55598d979e9aa32c1aba7ea8e8cab8ac76
rebase: add a 'revtodo' constant

The state mapping is using '-1' to mark revision that have not been rebased yet.
We introduce and use a constant for that purpose. This will help emphasising the
fact the value mean something else than nullrev.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -21,10 +21,11 @@  from mercurial.commands import templateo
 from mercurial.node import nullrev
 from mercurial.lock import release
 from mercurial.i18n import _
 import os, errno
 
+revtodo = -1
 nullmerge = -2
 revignored = -3
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -365,11 +366,11 @@  def rebase(ui, repo, **opts):
         sortedstate = sorted(state)
         total = len(sortedstate)
         pos = 0
         for rev in sortedstate:
             pos += 1
-            if state[rev] == -1:
+            if state[rev] == revtodo:
                 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, repo[rev])),
                             _('changesets'), total)
                 p1, p2 = defineparents(repo, rev, target, state,
                                                         targetancestors)
                 storestatus(repo, originalwd, target, state, collapsef, keepf,
@@ -781,11 +782,11 @@  def restorestatus(repo):
         skipped = set()
         # recompute the set of skipped revs
         if not collapse:
             seen = set([target])
             for old, new in sorted(state.items()):
-                if new != nullrev and new in seen:
+                if new != revtodo and new in seen:
                     skipped.add(old)
                 seen.add(new)
         repo.ui.debug('computed skipped revs: %s\n' %
                       (' '.join(str(r) for r in sorted(skipped)) or None))
         repo.ui.debug('rebase status resumed\n')
@@ -873,11 +874,11 @@  def buildstate(repo, dest, rebaseset, co
             if not collapse and samebranch and root in dest.children():
                 repo.ui.debug('source is a child of destination\n')
                 return None
 
         repo.ui.debug('rebase onto %d starting from %s\n' % (dest, root))
-        state.update(dict.fromkeys(rebaseset, nullrev))
+        state.update(dict.fromkeys(rebaseset, revtodo))
         # Rebase tries to turn <dest> into a parent of <root> while
         # preserving the number of parents of rebased changesets:
         #
         # - A changeset with a single parent will always be rebased as a
         #   changeset with a single parent.