--- a/mercurial/subrepo.py Mon Dec 16 12:59:32 2013 -0600
+++ b/mercurial/subrepo.py Wed Nov 13 15:55:30 2013 +0900
@@ -10,6 +10,7 @@
import stat, subprocess, tarfile
from i18n import _
import config, util, node, error, cmdutil, bookmarks, match as matchmod
+import phases
import pathutil
hg = None
propertycache = util.propertycache
@@ -351,6 +352,37 @@
raise util.Abort(_('unknown subrepo type %s') % state[2])
return types[state[2]](ctx, path, state[:2])
+def newcommitphase(ui, ctx):
+ commitphase = phases.newcommitphase(ui)
+ substate = getattr(ctx, "substate", None)
+ if not substate:
+ return commitphase
+ check = ui.config('phases', 'checksubrepos', 'follow')
+ if check not in ('ignore', 'follow', 'abort'):
+ raise util.Abort(_('invalid phases.checksubrepos configuration: %s')
+ % (check))
+ if check == 'ignore':
+ return commitphase
+ maxphase = phases.public
+ maxsub = None
+ for s in sorted(substate):
+ sub = ctx.sub(s)
+ subphase = sub.phase(substate[s][1])
+ if maxphase < subphase:
+ maxphase = subphase
+ maxsub = s
+ if commitphase < maxphase:
+ if check == 'abort':
+ raise util.Abort(_("can't commit in %s phase"
+ " conflicting %s from subrepository %s") %
+ (phases.phasenames[commitphase],
+ phases.phasenames[maxphase], maxsub))
+ ui.warn(_("warning: changes are committed in"
+ " %s phase from subrepository %s\n") %
+ (phases.phasenames[maxphase], maxsub))
+ return maxphase
+ return commitphase
+
# subrepo classes need to implement the following abstract class:
class abstractsubrepo(object):
@@ -385,6 +417,11 @@
"""
raise NotImplementedError
+ def phase(self, state):
+ """returns phase of specified state in the subrepository.
+ """
+ return phases.public
+
def remove(self):
"""remove the subrepo
@@ -652,6 +689,10 @@
return node.hex(n)
@annotatesubrepoerror
+ def phase(self, state):
+ return self._repo[state].phase()
+
+ @annotatesubrepoerror
def remove(self):
# we can't fully delete the repository as it may contain
# local-only history