Patchwork transaction: display data about why the transaction failed to rollback

login
register
mail settings
Submitter Boris Feld
Date Nov. 9, 2018, 10:45 p.m.
Message ID <73479612de7345e9ba40.1541803532@localhost.localdomain>
Download mbox | patch
Permalink /patch/36495/
State Accepted
Headers show

Comments

Boris Feld - Nov. 9, 2018, 10:45 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1541617178 -3600
#      Wed Nov 07 19:59:38 2018 +0100
# Node ID 73479612de7345e9ba400e3178315ab578de2c54
# Parent  a2c4502e409b72b22053fc31772368416c876b66
# EXP-Topic explain-failure
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 73479612de73
transaction: display data about why the transaction failed to rollback

We saw more of these a while back. Having more data available would be nice.
Yuya Nishihara - Nov. 10, 2018, 3:12 a.m.
On Fri, 09 Nov 2018 23:45:32 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1541617178 -3600
> #      Wed Nov 07 19:59:38 2018 +0100
> # Node ID 73479612de7345e9ba400e3178315ab578de2c54
> # Parent  a2c4502e409b72b22053fc31772368416c876b66
> # EXP-Topic explain-failure
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 73479612de73
> transaction: display data about why the transaction failed to rollback

Queued, thanks.

> +            except BaseException as exc:
>                  self._report(_("rollback failed - please run hg recover\n"))
> +                self._report(_("(failure reason: %s)\n") % exc)

Wrapped with forcebytestr() for py3 compatibility.

Patch

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -582,8 +582,9 @@  class transaction(util.transactional):
                           self._vfsmap, self._entries, self._backupentries,
                           False, checkambigfiles=self._checkambigfiles)
                 self._report(_("rollback completed\n"))
-            except BaseException:
+            except BaseException as exc:
                 self._report(_("rollback failed - please run hg recover\n"))
+                self._report(_("(failure reason: %s)\n") % exc)
         finally:
             self._journal = None
             self._releasefn(self, False) # notify failure of transaction
diff --git a/tests/test-repair-strip.t b/tests/test-repair-strip.t
--- a/tests/test-repair-strip.t
+++ b/tests/test-repair-strip.t
@@ -51,6 +51,7 @@ 
   transaction abort!
   failed to truncate data/b.i
   rollback failed - please run hg recover
+  (failure reason: [Errno 13] Permission denied .hg/store/data/b.i')
   strip failed, backup bundle
   abort: Permission denied .hg/store/data/b.i
   % after update 0, strip 2
@@ -104,6 +105,7 @@ 
   transaction abort!
   failed to truncate 00manifest.i
   rollback failed - please run hg recover
+  (failure reason: [Errno 13] Permission denied .hg/store/00manifest.i')
   strip failed, backup bundle
   abort: Permission denied .hg/store/00manifest.i
   % after update 0, strip 2