# HG changeset patch # User Pierre-Yves David # Date 2014-08-07 21:41:00 # Node ID 5dcc58649b1a18ad89dce2e75bbf8be3e73619d8 # Parent feb4797c676e6d1af5eb993e08cc1cb53c1b528d phase: extract the phaseroots serialization in a dedicated method In most case, the file creation logic will be handled by the transaction itself. The write method has to stay around for the case where the 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 @@ -196,11 +196,14 @@ class phasecache(object): 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):