Mercurial > hg
comparison mercurial/bookmarks.py @ 22664:6bd685d2a2de
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.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 27 Sep 2014 03:10:33 -0700 |
parents | 798185707833 |
children | 8319f7e78395 |
comparison
equal
deleted
inserted
replaced
22663:4c6198737ad8 | 22664:6bd685d2a2de |
---|---|
62 | 62 |
63 wlock = repo.wlock() | 63 wlock = repo.wlock() |
64 try: | 64 try: |
65 | 65 |
66 file = repo.vfs('bookmarks', 'w', atomictemp=True) | 66 file = repo.vfs('bookmarks', 'w', atomictemp=True) |
67 for name, node in self.iteritems(): | 67 self._write(file) |
68 file.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) | |
69 file.close() | 68 file.close() |
70 | 69 |
71 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) | 70 # touch 00changelog.i so hgweb reloads bookmarks (no lock needed) |
72 try: | 71 try: |
73 repo.svfs.utime('00changelog.i', None) | 72 repo.svfs.utime('00changelog.i', None) |
74 except OSError: | 73 except OSError: |
75 pass | 74 pass |
76 | 75 |
77 finally: | 76 finally: |
78 wlock.release() | 77 wlock.release() |
78 | |
79 def _write(self, fp): | |
80 for name, node in self.iteritems(): | |
81 fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name))) | |
79 | 82 |
80 def readcurrent(repo): | 83 def readcurrent(repo): |
81 '''Get the current bookmark | 84 '''Get the current bookmark |
82 | 85 |
83 If we use gittish branches we have a current bookmark that | 86 If we use gittish branches we have a current bookmark that |