Mercurial > hg
changeset 32921:5694311db6ed
amend: use context manager for locking
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 19 Jun 2017 11:21:37 -0700 |
parents | 8dbcb66ac160 |
children | eb84b4ad41e5 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 2 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Jun 19 11:20:29 2017 -0700 +++ b/mercurial/cmdutil.py Mon Jun 19 11:21:37 2017 -0700 @@ -30,7 +30,6 @@ error, formatter, graphmod, - lock as lockmod, match as matchmod, obsolete, patch, @@ -2730,10 +2729,8 @@ base = old.p1() createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt) - wlock = lock = newid = None - try: - wlock = repo.wlock() - lock = repo.lock() + newid = None + with repo.wlock(), repo.lock(): with repo.transaction('amend') as tr: # See if we got a message from -m or -l, if not, open the editor # with the message of the changeset to amend @@ -2896,8 +2893,6 @@ ui.note(_('stripping intermediate changeset %s\n') % ctx) ui.note(_('stripping amended changeset %s\n') % old) repair.strip(ui, repo, old.node(), topic='amend-backup') - finally: - lockmod.release(lock, wlock) return newid def commiteditor(repo, ctx, subs, editform=''):