# HG changeset patch # User Martin von Zweigbergk # Date 1515609136 28800 # Node ID 5574629d5d455f7267d717d4d51f81d9a493ed96 # Parent 8b729856ca031780ddb74ee39ff8cada8e9d7578 obsolete: use context manager for lock in pushmarker() Differential Revision: https://phab.mercurial-scm.org/D1836 diff -r 8b729856ca03 -r 5574629d5d45 mercurial/obsolete.py --- a/mercurial/obsolete.py Wed Jan 10 10:30:51 2018 -0800 +++ b/mercurial/obsolete.py Wed Jan 10 10:32:16 2018 -0800 @@ -838,8 +838,7 @@ repo.ui.warn(_('unexpected old value for %r') % key) return False data = util.b85decode(new) - lock = repo.lock() - try: + with repo.lock(): tr = repo.transaction('pushkey: obsolete markers') try: repo.obsstore.mergemarkers(tr, data) @@ -848,8 +847,6 @@ return True finally: tr.release() - finally: - lock.release() # keep compatibility for the 4.3 cycle def allprecursors(obsstore, nodes, ignoreflags=0):