Show More
@@ -64,10 +64,14 b' def write(repo, refs):' | |||
|
64 | 64 | util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks')) |
|
65 | 65 | if current(repo) not in refs: |
|
66 | 66 | setcurrent(repo, None) |
|
67 | file = repo.opener('bookmarks', 'w+') | |
|
67 | wlock = repo.wlock() | |
|
68 | try: | |
|
69 | file = repo.opener('bookmarks', 'w', atomictemp=True) | |
|
68 | 70 | for refspec, node in refs.iteritems(): |
|
69 | 71 | file.write("%s %s\n" % (hex(node), refspec)) |
|
70 |
file. |
|
|
72 | file.rename() | |
|
73 | finally: | |
|
74 | wlock.release() | |
|
71 | 75 | |
|
72 | 76 | def current(repo): |
|
73 | 77 | '''Get the current bookmark |
@@ -106,9 +110,13 b' def setcurrent(repo, mark):' | |||
|
106 | 110 | return |
|
107 | 111 | if mark not in refs: |
|
108 | 112 | mark = '' |
|
109 | file = repo.opener('bookmarks.current', 'w+') | |
|
113 | wlock = repo.wlock() | |
|
114 | try: | |
|
115 | file = repo.opener('bookmarks.current', 'w', atomictemp=True) | |
|
110 | 116 | file.write(mark) |
|
111 |
file. |
|
|
117 | file.rename() | |
|
118 | finally: | |
|
119 | wlock.release() | |
|
112 | 120 | repo._bookmarkcurrent = mark |
|
113 | 121 | |
|
114 | 122 | def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, rename=None): |
@@ -242,6 +250,8 b' def reposetup(ui, repo):' | |||
|
242 | 250 | def commit(self, *k, **kw): |
|
243 | 251 | """Add a revision to the repository and |
|
244 | 252 | move the bookmark""" |
|
253 | wlock = self.wlock() # do both commit and bookmark with lock held | |
|
254 | try: | |
|
245 | 255 | node = super(bookmark_repo, self).commit(*k, **kw) |
|
246 | 256 | if node is None: |
|
247 | 257 | return None |
@@ -262,6 +272,8 b' def reposetup(ui, repo):' | |||
|
262 | 272 | if update: |
|
263 | 273 | write(repo, marks) |
|
264 | 274 | return node |
|
275 | finally: | |
|
276 | wlock.release() | |
|
265 | 277 | |
|
266 | 278 | def addchangegroup(self, source, srctype, url, emptyok=False): |
|
267 | 279 | parents = repo.dirstate.parents() |
General Comments 0
You need to be logged in to leave comments.
Login now