Mercurial > hg
diff mercurial/localrepo.py @ 41364:0132221c25cd
localrepo: use context manager for lock and transaction in commitctx()
Differential Revision: https://phab.mercurial-scm.org/D5624
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 24 Sep 2018 14:46:37 -0700 |
parents | b87a009d1b3b |
children | 876494fd967d |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Jan 16 17:34:59 2019 -0800 +++ b/mercurial/localrepo.py Mon Sep 24 14:46:37 2018 -0700 @@ -2502,13 +2502,10 @@ from p1 or p2 are excluded from the committed ctx.files(). """ - tr = None p1, p2 = ctx.p1(), ctx.p2() user = ctx.user() - lock = self.lock() - try: - tr = self.transaction("commit") + with self.lock(), self.transaction("commit") as tr: trp = weakref.proxy(tr) if ctx.manifestnode(): @@ -2605,12 +2602,7 @@ # # if minimal phase was 0 we don't need to retract anything phases.registernew(self, tr, targetphase, [n]) - tr.close() return n - finally: - if tr: - tr.release() - lock.release() @unfilteredmethod def destroying(self):