Patchwork backout: fix --no-commit option (bug5054)

login
register
mail settings
Submitter Ruslan Sayfutdinov
Date Jan. 20, 2016, 4:18 p.m.
Message ID <3b0f347f9f266696307a.1453306722@dev1166.lla1.facebook.com>
Download mbox | patch
Permalink /patch/12842/
State Accepted
Headers show

Comments

Ruslan Sayfutdinov - Jan. 20, 2016, 4:18 p.m.
# HG changeset patch
# User Ruslan Sayfutdinov <sayfutdinov@fb.com>
# Date 1453306618 28800
#      Wed Jan 20 08:16:58 2016 -0800
# Branch stable
# Node ID 3b0f347f9f266696307ad86a11452ace169d4985
# Parent  d2c5ad3deccb5a504e2553652b66a4110db68afb
backout: fix --no-commit option (bug5054)
Matt Mackall - Jan. 20, 2016, 6:43 p.m.
On Wed, 2016-01-20 at 08:18 -0800, Ruslan Sayfutdinov wrote:
> # HG changeset patch
> # User Ruslan Sayfutdinov <sayfutdinov@fb.com>
> # Date 1453306618 28800
> #      Wed Jan 20 08:16:58 2016 -0800
> # Branch stable
> # Node ID 3b0f347f9f266696307ad86a11452ace169d4985
> # Parent  d2c5ad3deccb5a504e2553652b66a4110db68afb
> backout: fix --no-commit option (bug5054)
                                   ^^^^^^^

Looks good. The robots have two complaints though:

1) contrib/check-commit says you need to write (issueXXXX), not (bugXXXX)
2) contrib/check-code says you can't use seq in the test suite

I've fixed both of those issues and queued your patch for stable.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -653,11 +653,6 @@ 
                 repo.ui.status(_("use 'hg resolve' to retry unresolved "
                                  "file merges\n"))
                 return 1
-            elif opts.get('no_commit'):
-                msg = _("changeset %s backed out, "
-                        "don't forget to commit.\n")
-                ui.status(msg % short(node))
-                return 0
         finally:
             ui.setconfig('ui', 'forcemerge', '', '')
             lockmod.release(dsguard)
@@ -666,6 +661,11 @@ 
         repo.dirstate.setbranch(branch)
         cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
 
+    if opts.get('no_commit'):
+        msg = _("changeset %s backed out, "
+                "don't forget to commit.\n")
+        ui.status(msg % short(node))
+        return 0
 
     def commitfunc(ui, repo, message, match, opts):
         editform = 'backout'
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -739,4 +739,17 @@ 
   nine
   TEN
 
+--no-commit shouldn't commit
 
+  $ hg init a
+  $ cd a
+  $ for i in `seq 3`; do
+  >   touch $i
+  >   hg ci -Am $i
+  > done
+  adding 1
+  adding 2
+  adding 3
+  $ hg backout --no-commit .
+  removing 3
+  changeset cccc23d9d68f backed out, don't forget to commit.