[PATCH 5 of 9 phases] phase: add mechanism to store phase data into dirstate
Matt Mackall
mpm at selenic.com
Thu Jan 5 22:09:28 CST 2012
On Thu, 2012-01-05 at 02:25 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1325725382 -3600
> # Node ID 9bedf170a2c4753b01296db5f8dc8141cd3a64ed
> # Parent 6b460b7a2e2a2788031c4c5e8dd37160ddbd7ad8
> phase: add mechanism to store phase data into dirstate
(store IN)
Ok, what happens when I'm working on my secret branch and then switch to
the development tip and commit?
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -7,7 +7,7 @@
>
> from node import nullid
> from i18n import _
> -import scmutil, util, ignore, osutil, parsers, encoding
> +import scmutil, util, ignore, osutil, parsers, encoding, phases
> import struct, os, stat, errno
> import cStringIO
>
> @@ -220,6 +220,27 @@
> def branch(self):
> return encoding.tolocal(self._branch)
>
> + @propertycache
> + def phasedata(self):
> + """a two tuple attributs (phase, force)
> +
> + phase is any phase we wish the commit of this state to be in.
> +
> + When force is True, the next commit is required to be exactly in the
> + specified phase.
???
I really don't like the idea of stashing away a force switch for an
indefinite period of time.
> + """
> + try:
> + content = self._opener.read("phase").strip()
> + except IOError:
We allow all IOErrors?
> + content = ''
> + if content:
> + phase, force = content.split()
> + phase = int(phase)
> + force = bool(int(force))
> + else:
> + phase, force = None, False
> + return phase, force
> +
> def setparents(self, p1, p2=nullid):
> self._dirty = self._dirtypl = True
> self._pl = p1, p2
> @@ -230,6 +251,25 @@
> self._branch = encoding.fromlocal(branch)
> self._opener.write("branch", self._branch + '\n')
>
> + def setphase(self, phase, force=False):
> + """Set phase data to be used for next commit
> +
> + phase a valid phase index or None
> +
> + if force is false, the next commit will be at least in the provided
> + phase but other factor as new-commit option or parent phase may result
> + in higher used phase.
> + """
> + if phase in phases.allphases:
> + self.phasedata = (phase, force)
> + self._opener.write('phase', '%i %i\n' % self.phasedata)
> + elif phase is None:
> + self._opener.write('phase', '')
> + else:
> + raise ValueError('Invalid phase %r' % phase)
> +
> +
> +
> def _read(self):
> self._map = {}
> self._copymap = {}
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list