changeset 32942:f044295cdb7a

repair: move check for existing transaction earlier Several benefits: * Gets close the comment describing it * Splits off unrelated comment about "backup" argument * Error checking is customarily done early * If we added an early return to the method, it would still consistently fail if there was an existing transaction (so we would find and fix that case quickly) One test needs updating with for this change, because we no longer create the backup bundle before we fail. I don't see much reason to create that backup bundle. If some command was adding content and then trying to strip it as well within the transaction, we would have a backup for the user, but the risk of that not being discovered in development seems very small.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 19 Jun 2017 13:18:00 -0700
parents e413609659cf
children 4c6e4a4486a0
files mercurial/repair.py tests/test-devel-warnings.t
diffstat 2 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repair.py	Mon Jun 19 13:13:28 2017 -0700
+++ b/mercurial/repair.py	Mon Jun 19 13:18:00 2017 -0700
@@ -79,6 +79,9 @@
     # This function requires the caller to lock the repo, but it operates
     # within a transaction of its own, and thus requires there to be no current
     # transaction when it is called.
+    if repo.currenttransaction() is not None:
+        raise error.ProgrammingError('cannot strip from inside a transaction')
+
     # Simple way to maintain backwards compatibility for this
     # argument.
     if backup in ['none', 'strip']:
@@ -168,9 +171,6 @@
 
     mfst = repo.manifestlog._revlog
 
-    if repo.currenttransaction() is not None:
-        raise error.ProgrammingError('cannot strip from inside a transaction')
-
     try:
         with repo.transaction("strip") as tr:
             offset = len(tr.entries)
--- a/tests/test-devel-warnings.t	Mon Jun 19 13:13:28 2017 -0700
+++ b/tests/test-devel-warnings.t	Mon Jun 19 13:18:00 2017 -0700
@@ -108,7 +108,6 @@
   $ hg add a
   $ hg commit -m a
   $ hg stripintr 2>&1 | egrep -v '^(\*\*|  )'
-  saved backup bundle to $TESTTMP/lock-checker/.hg/strip-backup/*-backup.hg (glob)
   Traceback (most recent call last):
   mercurial.error.ProgrammingError: cannot strip from inside a transaction