# HG changeset patch # User Martin von Zweigbergk # Date 1497903480 25200 # Node ID f044295cdb7afa3078eb542a720500a5621e46e8 # Parent e413609659cf26fa2cd544a9258dbde463234c3a 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. diff -r e413609659cf -r f044295cdb7a mercurial/repair.py --- 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) diff -r e413609659cf -r f044295cdb7a tests/test-devel-warnings.t --- 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