Patchwork [V3] backout: commit changeset by default (BC)

login
register
mail settings
Submitter Ruslan Sayfutdinov
Date Jan. 15, 2016, 9:48 p.m.
Message ID <3c06509bafbf491cfcd3.1452894501@dev8998.prn1.facebook.com>
Download mbox | patch
Permalink /patch/12790/
State Accepted
Headers show

Comments

Ruslan Sayfutdinov - Jan. 15, 2016, 9:48 p.m.
# HG changeset patch
# User Ruslan Sayfutdinov <sayfutdinov@fb.com>
# Date 1452894393 28800
#      Fri Jan 15 13:46:33 2016 -0800
# Node ID 3c06509bafbf491cfcd3d6f31e4f533b9ef9c532
# Parent  2916ebaef3129451bfd4f9f62487e70f74124d46
backout: commit changeset by default (BC)

Add --no-commit flag to prevent it. This should make the hg user experience a little better.
Some discussion can be found here: http://markmail.org/message/7jm7ro2ias6hxywy
Yuya Nishihara - Jan. 17, 2016, 2:56 p.m.
On Fri, 15 Jan 2016 13:48:21 -0800, Ruslan Sayfutdinov wrote:
> # HG changeset patch
> # User Ruslan Sayfutdinov <sayfutdinov@fb.com>
> # Date 1452894393 28800
> #      Fri Jan 15 13:46:33 2016 -0800
> # Node ID 3c06509bafbf491cfcd3d6f31e4f533b9ef9c532
> # Parent  2916ebaef3129451bfd4f9f62487e70f74124d46
> backout: commit changeset by default (BC)
> 
> Add --no-commit flag to prevent it. This should make the hg user experience a little better.
> Some discussion can be found here: http://markmail.org/message/7jm7ro2ias6hxywy

Looks good to me, but can't be applied on the current tip. Can you rebase and
resend it?

> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -522,22 +522,24 @@
>  
>  @command('backout',
>      [('', 'merge', None, _('merge with old dirstate parent after backout')),
> -    ('', 'commit', None, _('commit if no conflicts were encountered')),
> +    ('', 'commit', None,
> +     _('commit if no conflicts were encountered (DEPRECATED)')),
> +    ('', 'no-commit', None, _('do not commit')),
>      ('', 'parent', '',
>       _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
>      ('r', 'rev', '', _('revision to backout'), _('REV')),
>      ('e', 'edit', False, _('invoke editor on commit messages')),
>      ] + mergetoolopts + walkopts + commitopts + commitopts2,
>      _('[OPTION]... [-r] REV'))
> -def backout(ui, repo, node=None, rev=None, commit=False, **opts):
> +def backout(ui, repo, node=None, rev=None, **opts):

> -def _dobackout(ui, repo, node=None, rev=None, commit=False, **opts):
> +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"))

This check can be done before taking locks, but that isn't a big concern.
Matt Mackall - Jan. 18, 2016, 1:37 a.m.
On Fri, 2016-01-15 at 13:48 -0800, Ruslan Sayfutdinov wrote:
> # HG changeset patch
> # User Ruslan Sayfutdinov <sayfutdinov@fb.com>
> # Date 1452894393 28800
> #      Fri Jan 15 13:46:33 2016 -0800
> # Node ID 3c06509bafbf491cfcd3d6f31e4f533b9ef9c532
> # Parent  2916ebaef3129451bfd4f9f62487e70f74124d46
> backout: commit changeset by default (BC)

Queued for default, thanks.
-- 
Mathematics is the supreme nostalgia of our time.
Ruslan Sayfutdinov - Jan. 18, 2016, 12:48 p.m.
It looks like you already merged previous version of this patch without saving old flag. Shall I create new one which will add this change?




On 1/18/16, 1:37 AM, "Matt Mackall" <mpm@selenic.com> wrote:

>On Fri, 2016-01-15 at 13:48 -0800, Ruslan Sayfutdinov wrote:

>> # HG changeset patch

>> # User Ruslan Sayfutdinov <sayfutdinov@fb.com>

>> # Date 1452894393 28800

>> #      Fri Jan 15 13:46:33 2016 -0800

>> # Node ID 3c06509bafbf491cfcd3d6f31e4f533b9ef9c532

>> # Parent  2916ebaef3129451bfd4f9f62487e70f74124d46

>> backout: commit changeset by default (BC)

>

>Queued for default, thanks.

>-- 

>Mathematics is the supreme nostalgia of our time.

>
Matt Mackall - Jan. 18, 2016, 3:01 p.m.
On Mon, 2016-01-18 at 12:48 +0000, Ruslan Sayfutdinov wrote:
> It looks like you already merged previous version of this patch without saving
> old flag.

??

$ hg help backout --debug | grep -- -commit
    committed automatically (unless --no-commit is specified).
        hg backout -r 23 --no-commit
    --commit              commit if no conflicts were encountered (DEPRECATED)
    --no-commit           do not commit


You'll have to forgive me if I'm forgetting something. I've reviewed a couple
hundred patches this weekend.

-- 
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
@@ -522,22 +522,24 @@ 
 
 @command('backout',
     [('', 'merge', None, _('merge with old dirstate parent after backout')),
-    ('', 'commit', None, _('commit if no conflicts were encountered')),
+    ('', 'commit', None,
+     _('commit if no conflicts were encountered (DEPRECATED)')),
+    ('', 'no-commit', None, _('do not commit')),
     ('', 'parent', '',
      _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
     ('r', 'rev', '', _('revision to backout'), _('REV')),
     ('e', 'edit', False, _('invoke editor on commit messages')),
     ] + mergetoolopts + walkopts + commitopts + commitopts2,
     _('[OPTION]... [-r] REV'))
-def backout(ui, repo, node=None, rev=None, commit=False, **opts):
+def backout(ui, repo, node=None, rev=None, **opts):
     '''reverse effect of earlier changeset
 
     Prepare a new changeset with the effect of REV undone in the
-    current working directory.
+    current working directory. If no conflicts were encountered,
+    it will be committed immediately.
 
     If REV is the parent of the working directory, then this new changeset
-    is committed automatically. Otherwise, hg needs to merge the
-    changes and the merged result is left uncommitted.
+    is committed automatically (unless --no-commit is specified).
 
     .. note::
 
@@ -556,13 +558,13 @@ 
       - Reverse the effect of previous bad revision 23::
 
           hg backout -r 23
+
+      - Reverse the effect of previous bad revision 23 and
+        leave changes uncommitted::
+
+          hg backout -r 23 --no-commit
           hg commit -m "Backout revision 23"
 
-      - Reverse the effect of previous bad revision 23 and
-        commit the backout immediately::
-
-          hg backout -r 23 --commit
-
       By default, the pending changeset will have one parent,
       maintaining a linear history. With --merge, the pending
       changeset will instead have two parents: the old parent of the
@@ -585,11 +587,14 @@ 
     try:
         wlock = repo.wlock()
         lock = repo.lock()
-        return _dobackout(ui, repo, node, rev, commit, **opts)
+        return _dobackout(ui, repo, node, rev, **opts)
     finally:
         release(lock, wlock)
 
-def _dobackout(ui, repo, node=None, rev=None, commit=False, **opts):
+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 rev and node:
         raise error.Abort(_("please specify just one revision"))
 
@@ -645,7 +650,7 @@ 
                     repo.ui.status(_("use 'hg resolve' to retry unresolved "
                                      "file merges\n"))
                     return 1
-                elif not commit:
+                elif opts.get('no_commit'):
                     msg = _("changeset %s backed out, "
                             "don't forget to commit.\n")
                     ui.status(msg % short(node))
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -61,7 +61,7 @@ 
   $ echo grapes >> a
   $ hg commit -d '2 0' -m grapes
 
-  $ hg backout --commit -d '4 0' 1 --tool=:fail
+  $ hg backout -d '4 0' 1 --tool=:fail
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   changeset 3:1c2161e97c0a backs out changeset 1:22cb4f70d813
   $ hg summary
@@ -75,7 +75,7 @@ 
   $ echo ypples > a
   $ hg commit -d '5 0' -m ypples
 
-  $ hg backout --commit -d '6 0' 2 --tool=:fail
+  $ hg backout -d '6 0' 2 --tool=:fail
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges
   [1]
@@ -371,7 +371,7 @@ 
   phases: 3 draft
 
 without --merge
-  $ hg backout -d '3 0' 1 --tool=true
+  $ hg backout --no-commit -d '3 0' 1 --tool=true
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   changeset 22bca4c721e5 backed out, don't forget to commit.
   $ hg locate b
@@ -511,7 +511,7 @@ 
   adding file2
 
 without --merge
-  $ hg backout -r 1 --tool=true
+  $ hg backout --no-commit -r 1 --tool=true
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   changeset bf1602f437f3 backed out, don't forget to commit.
   $ hg branch
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -224,7 +224,7 @@ 
   update: clean, check, date, rev, tool
   addremove: similarity, subrepos, include, exclude, dry-run
   archive: no-decode, prefix, rev, type, subrepos, include, exclude
-  backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
+  backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
   bisect: reset, good, bad, skip, extend, command, noupdate
   bookmarks: force, rev, delete, rename, inactive, template
   branch: force, clean
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -1288,7 +1288,7 @@ 
 
 Test restricted mode with backout
 
-  $ hg backout -q 11
+  $ hg backout -q 11 --no-commit
   $ hg diff a
   diff -r 01a68de1003a a
   --- a/a	Thu Jan 01 00:00:00 1970 +0000
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -671,7 +671,7 @@ 
 backout calls revert internally with minimal opts, which should not raise
 KeyError
 
-  $ hg backout ".^"
+  $ hg backout ".^" --no-commit
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   changeset c373c8102e68 backed out, don't forget to commit.