[PATCH 3 of 3] phase: make if abort on nullid for the good reason

Patrick Mezard patrick at mezard.eu
Fri May 11 17:49:50 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1336775047 -7200
# Node ID ad1538cbd9f3a8d70981b010a63dc4f4de5045c7
# Parent  a15de64e5817ca7bf105e6b56c2ffa37cd20c42b
phase: make if abort on nullid for the good reason

The good reason being you cannot call retractboundary() on nullid, not
revset.set() cannot resolve '-1'.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4349,9 +4349,9 @@
         lock = repo.lock()
         try:
             # set phase
-            nodes = [ctx.node() for ctx in repo.set('%ld', revs)]
-            if not nodes:
-                raise util.Abort(_('empty revision set'))
+            if not revs:
+                 raise util.Abort(_('empty revision set'))
+            nodes = [repo[r].node() for r in revs]
             olddata = repo._phasecache.getphaserevs(repo)[:]
             phases.advanceboundary(repo, targetphase, nodes)
             if opts['force']:
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -101,6 +101,7 @@
 import errno
 from node import nullid, nullrev, bin, hex, short
 from i18n import _
+import util
 
 allphases = public, draft, secret = range(3)
 trackedphases = allphases[1:]
@@ -250,6 +251,8 @@
         newroots = [n for n in nodes
                     if self.phase(repo, repo[n].rev()) < targetphase]
         if newroots:
+            if nullid in newroots:
+                raise util.Abort(_('cannot change null revision phase'))
             currentroots = currentroots.copy()
             currentroots.update(newroots)
             ctxs = repo.set('roots(%ln::)', currentroots)
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -13,7 +13,7 @@
 Cannot change null revision phase
 
   $ hg phase --force --secret null
-  abort: unknown revision '-1'!
+  abort: cannot change null revision phase
   [255]
   $ hg phase null
   -1: public


More information about the Mercurial-devel mailing list