[PATCH 7 of 9 phases] phase: add a targetphasedata method to context

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Jan 4 19:25:44 CST 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1325725338 -3600
# Node ID a315d2fcbcf1c46152f4df3c57dbd41559f512df
# Parent  14124d106c8873e80ffcdb8e3332f277e53534dc
phase: add a targetphasedata method to context

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -7,7 +7,7 @@
 
 from node import nullid, nullrev, short, hex
 from i18n import _
-from phases import public, draft, phasenames
+from phases import public, draft, phasenames, dirstatephase
 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding
 import match as matchmod
 import os, errno, stat
@@ -131,6 +131,13 @@
         return self._repo._phaserev[self._rev] > public
     def hidden(self):
         return self._rev in self._repo.changelog.hiddenrevs
+    def targetphasedata(self):
+        """return a (phase, forced) tuple
+
+        phase: a valid phase integer
+        forced: if true, target phase is exactly <phase> not a minimum"""
+        phase, pfrom = dirstatephase(self._repo)
+        return phase, pfrom == 'forced'
 
     def parents(self):
         """return contexts for each parent changeset"""
@@ -1073,6 +1080,9 @@
         if self._extra.get('branch', '') == '':
             self._extra['branch'] = 'default'
 
+        self._targetphase = repo.ui.configint('phases', 'new-commit', draft)
+        self._forcephase = False
+
     def __str__(self):
         return str(self._parents[0]) + "+"
 
@@ -1119,6 +1129,9 @@
     def flags(self, f):
         return self[f].flags()
 
+    def targetphasedata(self):
+        return self._targetphase, self._forcephase
+
     def parents(self):
         """return contexts for each parent changeset"""
         return self._parents
@@ -1131,6 +1144,7 @@
         """commit context to the repo"""
         return self._repo.commitctx(self)
 
+
 class memfilectx(object):
     """memfilectx represents an in-memory file to commit.
 


More information about the Mercurial-devel mailing list