changeset 22080:37f46575d9c2

phase: attach phase to the transaction instead of the lock The phase cache file is no longer written on lock release, it is now handled by the transaction (as changesets and obsolescence markers are). (Hooray) As we stop relying on the lock to write phase, repos with no existing phase information will need to wait for a phase move or a strip to happen in order to get the first write in the `phaseroots` file. This explain the change in test-inherit-mode.t. This should not have any side effects but in very obscure cases where people interact with pre-2.1 and post-2.1 versions of Mercurial on the same repo while having MQ patches applied but the MQ extension disabled from time to time. A case unlikely enough to not be worth preserving the old behavior with awful hacks.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 07 Aug 2014 14:11:36 -0700
parents 5dcc58649b1a
children ed426b011612
files mercurial/localrepo.py mercurial/phases.py tests/test-inherit-mode.t
diffstat 3 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Aug 07 14:41:00 2014 -0700
+++ b/mercurial/localrepo.py	Thu Aug 07 14:11:36 2014 -0700
@@ -1089,8 +1089,6 @@
             return l
 
         def unlock():
-            if hasunfilteredcache(self, '_phasecache'):
-                self._phasecache.write()
             for k, ce in self._filecache.items():
                 if k == 'dirstate' or k not in self.__dict__:
                     continue
--- a/mercurial/phases.py	Thu Aug 07 14:41:00 2014 -0700
+++ b/mercurial/phases.py	Thu Aug 07 14:11:36 2014 -0700
@@ -206,11 +206,13 @@
                 fp.write('%i %s\n' % (phase, hex(h)))
         self.dirty = False
 
-    def _updateroots(self, phase, newroots):
+    def _updateroots(self, phase, newroots, tr):
         self.phaseroots[phase] = newroots
         self._phaserevs = None
         self.dirty = True
 
+        tr.addfilegenerator('phase', ('phaseroots',), self._write)
+
     def advanceboundary(self, repo, tr, targetphase, nodes):
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
@@ -227,7 +229,7 @@
             roots = set(ctx.node() for ctx in repo.set(
                     'roots((%ln::) - (%ln::%ln))', olds, olds, nodes))
             if olds != roots:
-                self._updateroots(phase, roots)
+                self._updateroots(phase, roots, tr)
                 # some roots may need to be declared for lower phases
                 delroots.extend(olds - roots)
             # declare deleted root in the target phase
@@ -250,7 +252,7 @@
             currentroots.update(newroots)
             ctxs = repo.set('roots(%ln::)', currentroots)
             currentroots.intersection_update(ctx.node() for ctx in ctxs)
-            self._updateroots(targetphase, currentroots)
+            self._updateroots(targetphase, currentroots, tr)
         repo.invalidatevolatilesets()
 
     def filterunknown(self, repo):
--- a/tests/test-inherit-mode.t	Thu Aug 07 14:41:00 2014 -0700
+++ b/tests/test-inherit-mode.t	Thu Aug 07 14:11:36 2014 -0700
@@ -120,7 +120,6 @@
   00660 ../push/.hg/store/data/dir/bar.i
   00660 ../push/.hg/store/data/foo.i
   00660 ../push/.hg/store/fncache
-  00660 ../push/.hg/store/phaseroots
   00660 ../push/.hg/store/undo
   00660 ../push/.hg/store/undo.phaseroots
   00660 ../push/.hg/undo.bookmarks