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.
--- 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