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