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+') | |
|
68 | for refspec, node in refs.iteritems(): | |
|
69 | file.write("%s %s\n" % (hex(node), refspec)) | |
|
70 | file.close() | |
|
67 | wlock = repo.wlock() | |
|
68 | try: | |
|
69 | file = repo.opener('bookmarks', 'w', atomictemp=True) | |
|
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 | 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+') | |
|
110 | file.write(mark) | |
|
111 | file.close() | |
|
113 | wlock = repo.wlock() | |
|
114 | try: | |
|
115 | file = repo.opener('bookmarks.current', 'w', atomictemp=True) | |
|
116 | file.write(mark) | |
|
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,26 +250,30 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""" |
|
245 | node = super(bookmark_repo, self).commit(*k, **kw) | |
|
246 | if node is None: | |
|
247 | return None | |
|
248 | parents = repo.changelog.parents(node) | |
|
249 | if parents[1] == nullid: | |
|
250 |
parents = ( |
|
|
251 | marks = parse(repo) | |
|
252 | update = False | |
|
253 |
|
|
|
254 | if ui.configbool('bookmarks', 'track.current'): | |
|
255 |
|
|
|
256 | marks[mark] = node | |
|
257 | update = True | |
|
258 | else: | |
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 | if update: | |
|
263 | write(repo, marks) | |
|
264 | return node | |
|
253 | wlock = self.wlock() # do both commit and bookmark with lock held | |
|
254 | try: | |
|
255 | node = super(bookmark_repo, self).commit(*k, **kw) | |
|
256 | if node is None: | |
|
257 | return None | |
|
258 | parents = repo.changelog.parents(node) | |
|
259 | if parents[1] == nullid: | |
|
260 | parents = (parents[0],) | |
|
261 | marks = parse(repo) | |
|
262 | update = False | |
|
263 | for mark, n in marks.items(): | |
|
264 | if ui.configbool('bookmarks', 'track.current'): | |
|
265 | if mark == current(repo) and n in parents: | |
|
266 | marks[mark] = node | |
|
267 | update = True | |
|
268 | else: | |
|
269 | if n in parents: | |
|
270 | marks[mark] = node | |
|
271 | update = True | |
|
272 | if update: | |
|
273 | write(repo, marks) | |
|
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