diff -r 8c81975fe145 -r 09820fb88e14 mercurial/context.py --- a/mercurial/context.py Fri Jan 15 13:14:46 2016 -0800 +++ b/mercurial/context.py Fri Jan 15 13:14:46 2016 -0800 @@ -1461,8 +1461,7 @@ def undelete(self, list): pctxs = self.parents() - wlock = self._repo.wlock() - try: + with self._repo.wlock(): for f in list: if self._repo.dirstate[f] != 'r': self._repo.ui.warn(_("%s not removed!\n") % f) @@ -1471,8 +1470,6 @@ t = fctx.data() self._repo.wwrite(f, t, fctx.flags()) self._repo.dirstate.normal(f) - finally: - wlock.release() def copy(self, source, dest): try: