##// END OF EJS Templates
bookmarks: use context managers for locks and transaction in pushbookmark()...
Martin von Zweigbergk -
r35595:ac7ee75e default
parent child Browse files
Show More
@@ -20,7 +20,6 b' from .node import ('
20 from . import (
20 from . import (
21 encoding,
21 encoding,
22 error,
22 error,
23 lock as lockmod,
24 obsutil,
23 obsutil,
25 pycompat,
24 pycompat,
26 scmutil,
25 scmutil,
@@ -414,11 +413,7 b' def listbookmarks(repo):'
414 return d
413 return d
415
414
416 def pushbookmark(repo, key, old, new):
415 def pushbookmark(repo, key, old, new):
417 w = l = tr = None
416 with repo.wlock(), repo.lock(), repo.transaction('bookmarks') as tr:
418 try:
419 w = repo.wlock()
420 l = repo.lock()
421 tr = repo.transaction('bookmarks')
422 marks = repo._bookmarks
417 marks = repo._bookmarks
423 existing = hex(marks.get(key, ''))
418 existing = hex(marks.get(key, ''))
424 if existing != old and existing != new:
419 if existing != old and existing != new:
@@ -430,10 +425,7 b' def pushbookmark(repo, key, old, new):'
430 return False
425 return False
431 changes = [(key, repo[new].node())]
426 changes = [(key, repo[new].node())]
432 marks.applychanges(repo, tr, changes)
427 marks.applychanges(repo, tr, changes)
433 tr.close()
434 return True
428 return True
435 finally:
436 lockmod.release(tr, l, w)
437
429
438 def comparebookmarks(repo, srcmarks, dstmarks, targets=None):
430 def comparebookmarks(repo, srcmarks, dstmarks, targets=None):
439 '''Compare bookmarks between srcmarks and dstmarks
431 '''Compare bookmarks between srcmarks and dstmarks
General Comments 0
You need to be logged in to leave comments. Login now