[PATCH 12 of 18] phases: add a secret states

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Oct 10 07:28:08 CDT 2011


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1318206230 -7200
# Node ID 22819d45ed2b8cf781a484b745a28ebe299b41b6
# Parent  c28e325a7325a284626665cc147bde7d34aa729e
phases: add a secret states

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -11,20 +11,20 @@ import os
 from operator import add
 
 import util
 from node import nullid, hex, bin
 
-allphases = range(2)
+allphases = range(3)
 trackedphases = allphases[:-1]
 
 ### I/O code
 ############
 
 def readheads(repo):
     """Read phrases head from disk"""
     try:
-        heads = [set()]
+        heads = [set(), set()]
         f = repo.sopener('phrases-heads')
         try:
             for line in f:
                 phrase, nh = line.strip().split()
                 heads[int(phrase)].add(bin(nh))
@@ -32,10 +32,12 @@ def readheads(repo):
             f.close()
     except IOError:
         pass # gracefully filled bellow
     if not heads[0]:
         heads[0].add(nullid)
+    if not heads[1]:
+        heads[1].update(repo.heads())
     return heads
 
 def writeheads(repo):
     """Write phrases head on disk
     Also invalidate the phases cache.
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -22,16 +22,16 @@
 
 check wrong argument
 --------------------
   $ hg phase -r1
   abort: no phase specifed
-  (use --phase option with one of: [0, 1])
+  (use --phase option with one of: [0, 1, 2])
   [255]
 
   $ hg phase -p alain -r1
   abort: unknown phase: alain
-  (use one of: [0, 1])
+  (use one of: [0, 1, 2])
   [255]
 
   $ hg phase -p1
   abort: phase requires at least one changeset
   [255]


More information about the Mercurial-devel mailing list