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