Patchwork [STABLE] backout: disable --merge with --no-commit (issue4874)

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 31, 2016, 9:08 a.m.
Message ID <47391d008d3c7b7acad3.1454231323@mimosa>
Download mbox | patch
Permalink /patch/12913/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 31, 2016, 9:08 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1454144411 -32400
#      Sat Jan 30 18:00:11 2016 +0900
# Branch stable
# Node ID 47391d008d3c7b7acad3b0bb7a1a11ce81eaaee2
# Parent  29451a59eefaea35be57c4fb5a30a2a848ccc667
backout: disable --merge with --no-commit (issue4874)

Because "backout --merge" have to make a commit before merging, it doesn't
work with --no-commit. We could change "backout --merge" to make a merge
commit automatically, and --no-commit to bypass a merge commit, but that
change would be undesirable because:

 a) it's hard to fix bad merges in general
 b) two commits would be created with the same --message

So, this patch simply disables "--merge --no-commit".
Pierre-Yves David - Feb. 1, 2016, 11:55 a.m.
On 01/31/2016 09:08 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1454144411 -32400
> #      Sat Jan 30 18:00:11 2016 +0900
> # Branch stable
> # Node ID 47391d008d3c7b7acad3b0bb7a1a11ce81eaaee2
> # Parent  29451a59eefaea35be57c4fb5a30a2a848ccc667
> backout: disable --merge with --no-commit (issue4874)

Pushed to the clowncopter thanks.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -598,6 +598,8 @@  def backout(ui, repo, node=None, rev=Non
 def _dobackout(ui, repo, node=None, rev=None, **opts):
     if opts.get('commit') and opts.get('no_commit'):
         raise error.Abort(_("cannot use --commit with --no-commit"))
+    if opts.get('merge') and opts.get('no_commit'):
+        raise error.Abort(_("cannot use --merge with --no-commit"))
 
     if rev and node:
         raise error.Abort(_("please specify just one revision"))
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -753,3 +753,10 @@  Test usage of `hg resolve` in case of co
   $ hg backout --no-commit .
   removing 3
   changeset cccc23d9d68f backed out, don't forget to commit.
+  $ hg revert -aq
+
+--no-commit can't be used with --merge
+
+  $ hg backout --merge --no-commit 2
+  abort: cannot use --merge with --no-commit
+  [255]