rebase: handle revtodo as a special value when storing/restoring state
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 02 Dec 2014 12:23:12 -0800
changeset 23491 9972758ab4c5
parent 23490 102f144f6e02
child 23492 da733837cdd0
rebase: handle revtodo as a special value when storing/restoring state Revtodo happens to share its value with nullrev, but this is an implementation details, so we move away from it. After this changeset one can successfully change the values for all the constants and the tests still pass, but doing so would require more refactoring if we want to avoid breaking backward compatibility on the state file.
hgext/rebase.py
--- a/hgext/rebase.py	Tue Dec 02 09:46:20 2014 -0800
+++ b/hgext/rebase.py	Tue Dec 02 12:23:12 2014 -0800
@@ -18,7 +18,7 @@
 from mercurial import extensions, patch, scmutil, phases, obsolete, error
 from mercurial import copies
 from mercurial.commands import templateopts
-from mercurial.node import nullrev
+from mercurial.node import nullrev, nullid, hex
 from mercurial.lock import release
 from mercurial.i18n import _
 import os, errno
@@ -737,8 +737,12 @@
     f.write('%s\n' % (activebookmark or ''))
     for d, v in state.iteritems():
         oldrev = repo[d].hex()
-        if v > nullmerge:
+        if v >= 0:
             newrev = repo[v].hex()
+        elif v == revtodo:
+            # To maintain format compatibility, we have to use nullid.
+            # Please do remove this special case when upgrading the format.
+            newrev = hex(nullid)
         else:
             newrev = v
         f.write("%s:%s\n" % (oldrev, newrev))
@@ -780,6 +784,9 @@
                 oldrev, newrev = l.split(':')
                 if newrev in (str(nullmerge), str(revignored)):
                     state[repo[oldrev].rev()] = int(newrev)
+                elif newrev == nullid:
+                    state[repo[oldrev].rev()] = revtodo
+                    # Legacy compat special case
                 else:
                     state[repo[oldrev].rev()] = repo[newrev].rev()