# HG changeset patch # User Pierre-Yves David # Date 1411812633 25200 # Node ID 6bd685d2a2de7815e0d0593103bb1753e80b3e90 # Parent 4c6198737ad8fd0d3c4aaedb347355649de35599 bookmarks: split bookmark serialization and file handling If we want to handle bookmarks in a transaction we need to decouple the file handling and the actual production of the content. This is similar to how we handle phases in transaction. diff -r 4c6198737ad8 -r 6bd685d2a2de mercurial/bookmarks.py --- a/mercurial/bookmarks.py Sun Sep 28 00:36:42 2014 -0700 +++ b/mercurial/bookmarks.py Sat Sep 27 03:10:33 2014 -0700 @@ -64,8 +64,7 @@ try: file = repo.vfs('bookmarks', 'w', atomictemp=True) - for name, node in self.iteritems(): - file.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) + self._write(file) file.close() # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) @@ -77,6 +76,10 @@ finally: wlock.release() + def _write(self, fp): + for name, node in self.iteritems(): + fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) + def readcurrent(repo): '''Get the current bookmark