# HG changeset patch # User Pierre-Yves David # Date 1432441127 25200 # Node ID 678d0bfdd31a1f74fddc399c3ee07013efa9a652 # Parent 4f07fb1d7fbbf3e07f8f41bf87377acae747684f repair: forbid strip from inside a transaction Stripping inside a transaction will (at best) crash or (at worst) result in very unexpected results. We explicitly forbid it early. diff -r 4f07fb1d7fbb -r 678d0bfdd31a mercurial/repair.py --- a/mercurial/repair.py Wed May 27 12:14:10 2015 -0400 +++ b/mercurial/repair.py Sat May 23 21:18:47 2015 -0700 @@ -151,6 +151,12 @@ mfst = repo.manifest + curtr = repo.currenttransaction() + if curtr is not None: + del curtr # avoid carrying reference to transaction for nothing + msg = _('programming error: cannot strip from inside a transaction') + raise util.Abort(msg, hint=_('contact your extension maintainer')) + tr = repo.transaction("strip") offset = len(tr.entries) diff -r 4f07fb1d7fbb -r 678d0bfdd31a tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t Wed May 27 12:14:10 2015 -0400 +++ b/tests/test-devel-warnings.t Sat May 23 21:18:47 2015 -0700 @@ -3,7 +3,7 @@ > """A small extension that acquire locks in the wrong order > """ > - > from mercurial import cmdutil + > from mercurial import cmdutil, repair > > cmdtable = {} > command = cmdutil.command(cmdtable) @@ -38,6 +38,15 @@ > wl = repo.wlock(wait=False) > wl.release() > lo.release() + > + > @command('stripintr', [], '') + > def stripintr(ui, repo): + > lo = repo.lock() + > tr = repo.transaction('foobar') + > try: + > repair.strip(repo.ui, repo, [repo['.'].node()]) + > finally: + > lo.release() > EOF $ cat << EOF >> $HGRCPATH @@ -87,4 +96,14 @@ $TESTTMP/buggylocking.py:* in buggylocking (glob) $ hg properlocking $ hg nowaitlocking + + $ echo a > a + $ hg add a + $ hg commit -m a + $ hg stripintr + saved backup bundle to $TESTTMP/lock-checker/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob) + abort: programming error: cannot strip from inside a transaction + (contact your extension maintainer) + [255] + $ cd ..