diff -r a5eae47aa1f8 -r 6ad5e134ef2e mercurial/commands.py --- a/mercurial/commands.py Fri Jan 15 13:14:46 2016 -0800 +++ b/mercurial/commands.py Fri Jan 15 13:14:46 2016 -0800 @@ -3386,13 +3386,10 @@ r1 = scmutil.revsingle(repo, rev1).node() r2 = scmutil.revsingle(repo, rev2, 'null').node() - wlock = repo.wlock() - try: + with repo.wlock(): repo.dirstate.beginparentchange() repo.setparents(r1, r2) repo.dirstate.endparentchange() - finally: - wlock.release() @command('debugdirstate|debugstate', [('', 'nodates', None, _('do not display the saved mtime')),