changeset 42144:013de80bf90e

recover: add a --[no-]verify flag For trivial cases, the cost of the verify run after `hg recover` is getting in the way. In addition for very large repositories, the cost is simply too high to be paid, making `hg recover` an unusable commands. We introduce a --verify flag, set by default. If is automatically associated with a --no-verify flag that one can use to skip the verify step. We might consider changing the default behavior in the future. However this is out of scope for this series.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 17 Apr 2019 00:37:00 +0200
parents 29569f2db929
children 607a0de9bae3
files mercurial/commands.py tests/test-completion.t tests/test-journal-exists.t
diffstat 3 files changed, 42 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Apr 02 19:48:31 2019 +0200
+++ b/mercurial/commands.py	Wed Apr 17 00:37:00 2019 +0200
@@ -4655,8 +4655,11 @@
 
     return result
 
-@command('recover', [], helpcategory=command.CATEGORY_MAINTENANCE)
-def recover(ui, repo):
+@command('recover',
+    [('','verify', True, "run `hg verify` after succesful recover"),
+    ],
+    helpcategory=command.CATEGORY_MAINTENANCE)
+def recover(ui, repo, **opts):
     """roll back an interrupted transaction
 
     Recover from an interrupted commit or pull.
@@ -4667,8 +4670,15 @@
 
     Returns 0 if successful, 1 if nothing to recover or verify fails.
     """
-    if repo.recover():
-        return hg.verify(repo)
+    ret = repo.recover()
+    if ret:
+        if opts['verify']:
+            return hg.verify(repo)
+        else:
+            msg = _("(verify step skipped, run  `hg verify` to check your "
+                    "repository content)\n")
+            ui.warn(msg)
+            return 0
     return 1
 
 @command('remove|rm',
--- a/tests/test-completion.t	Tue Apr 02 19:48:31 2019 +0200
+++ b/tests/test-completion.t	Wed Apr 17 00:37:00 2019 +0200
@@ -332,7 +332,7 @@
   phase: public, draft, secret, force, rev
   pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
   push: force, rev, bookmark, branch, new-branch, pushvars, publish, ssh, remotecmd, insecure
-  recover: 
+  recover: verify
   remove: after, force, subrepos, include, exclude, dry-run
   rename: after, force, include, exclude, dry-run
   resolve: all, list, mark, unmark, no-status, re-merge, tool, include, exclude, template
--- a/tests/test-journal-exists.t	Tue Apr 02 19:48:31 2019 +0200
+++ b/tests/test-journal-exists.t	Wed Apr 17 00:37:00 2019 +0200
@@ -21,6 +21,33 @@
   checking files
   checked 1 changesets with 1 changes to 1 files
 
+recover, explicite verify
+
+  $ touch .hg/store/journal
+  $ hg ci -Am0
+  abort: abandoned transaction found!
+  (run 'hg recover' to clean up transaction)
+  [255]
+  $ hg recover --verify
+  rolling back interrupted transaction
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 1 changesets with 1 changes to 1 files
+
+recover, no verify
+
+  $ touch .hg/store/journal
+  $ hg ci -Am0
+  abort: abandoned transaction found!
+  (run 'hg recover' to clean up transaction)
+  [255]
+  $ hg recover --no-verify
+  rolling back interrupted transaction
+  (verify step skipped, run  `hg verify` to check your repository content)
+
+
 Check that zero-size journals are correctly aborted:
 
 #if unix-permissions no-root