[PATCH 4 of 5] phase: extract the phaseroots serialisation in a dedicated method
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Aug 7 17:52:02 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1407447660 25200
# Thu Aug 07 14:41:00 2014 -0700
# Node ID ed5766a5d48982f9794683f594625ce663ca8f90
# Parent db950150e34324daa2985b2f51ddc8d0ef6b4705
phase: extract the phaseroots serialisation in a dedicated method
In most case, the file creation logic will be handled by the transaction
itself. The write method have to stay around for case were repository is
modified outside a transaction (strip).
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -194,15 +194,18 @@ class phasecache(object):
def write(self):
if not self.dirty:
return
f = self.opener('phaseroots', 'w', atomictemp=True)
try:
- for phase, roots in enumerate(self.phaseroots):
- for h in roots:
- f.write('%i %s\n' % (phase, hex(h)))
+ self._write(f)
finally:
f.close()
+
+ def _write(self, fp):
+ for phase, roots in enumerate(self.phaseroots):
+ for h in roots:
+ fp.write('%i %s\n' % (phase, hex(h)))
self.dirty = False
def _updateroots(self, phase, newroots):
self.phaseroots[phase] = newroots
self._phaserevs = None
More information about the Mercurial-devel
mailing list