[PATCH 1 of 2] histedit: dropmissing: abort on empty plan

Mateusz Kwapich mitrandir at fb.com
Sun Mar 13 23:48:06 UTC 2016


# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1457912809 25200
#      Sun Mar 13 16:46:49 2016 -0700
# Node ID 397475d74e19176c668b80ebc7054310fb544418
# Parent  ffd3ac07b1d79dda7f57bd826208fdaf92a76717
histedit: dropmissing: abort on empty plan

We noticed that many users have the intuition of laving the editor empty when
they want to abort the operation. The fact that dropmissing allows user to
delete all edited commits is not intuitive even for users that asked for it.

Let's prevent people from this footgun.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1377,6 +1377,10 @@ def verifyactions(actions, state, ctxs):
     missing = sorted(expected - seen)  # sort to stabilize output
 
     if state.repo.ui.configbool('histedit', 'dropmissing'):
+        if len(actions) == 0:
+            raise error.ParseError(_('no rules provided'),
+                    hint=_('use strip extension to remove commits'))
+
         drops = [drop(state, node.bin(n)) for n in missing]
         # put the in the beginning so they execute immediately and
         # don't show in the edit-plan in the future
diff --git a/tests/test-histedit-drop.t b/tests/test-histedit-drop.t
--- a/tests/test-histedit-drop.t
+++ b/tests/test-histedit-drop.t
@@ -153,6 +153,10 @@ Drop the last changeset
   hg: parse error: missing rules for changeset a4f7421b80f7
   (use "drop a4f7421b80f7" to discard, see also: "hg help -e histedit.config")
   $ hg --config histedit.dropmissing=True histedit  cb9a9f314b8b --commands - 2>&1 << EOF | fixbundle
+  > EOF
+  hg: parse error: no rules provided
+  (use strip extension to remove commits)
+  $ hg --config histedit.dropmissing=True histedit  cb9a9f314b8b --commands - 2>&1 << EOF | fixbundle
   > pick cb9a9f314b8b a
   > pick ee283cb5f2d5 e
   > EOF


More information about the Mercurial-devel mailing list