Patchwork [1,of,2,V2] plain: ignore [commands] config

login
register
mail settings
Submitter via Mercurial-devel
Date March 22, 2017, 4:25 p.m.
Message ID <1ed5ec882c49934a1642.1490199924@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/19580/
State Accepted
Headers show

Comments

via Mercurial-devel - March 22, 2017, 4:25 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1490156812 25200
#      Tue Mar 21 21:26:52 2017 -0700
# Node ID 1ed5ec882c49934a16428fc72e7a366f39747cc5
# Parent  55c6788c54e2faf80ec14f2b0844bfe429012bc3
plain: ignore [commands] config

We only have commands.{update,rebase}.requiredest so far. We should
clearly ignore those two if HGPLAIN is in effect, and it seems like we
should ignore any future config that will be added in [commands] since
that is about changing the behavior of commands.

Thanks to Yuya for suggesting to centralize the code in ui.py.

While at it, remove the unnecessary False values passed to
ui.configbool() for the aforementioned config options.

Patch

diff -r 55c6788c54e2 -r 1ed5ec882c49 hgext/rebase.py
--- a/hgext/rebase.py	Tue Mar 21 22:47:49 2017 -0700
+++ b/hgext/rebase.py	Tue Mar 21 21:26:52 2017 -0700
@@ -686,7 +686,7 @@ 
         # Validate input and define rebasing points
         destf = opts.get('dest', None)
 
-        if ui.config('commands', 'rebase.requiredest', False):
+        if ui.config('commands', 'rebase.requiredest'):
             if not destf:
                 raise error.Abort(_('you must specify a destination'),
                                   hint=_('use: hg rebase -d REV'))
diff -r 55c6788c54e2 -r 1ed5ec882c49 mercurial/commands.py
--- a/mercurial/commands.py	Tue Mar 21 22:47:49 2017 -0700
+++ b/mercurial/commands.py	Tue Mar 21 21:26:52 2017 -0700
@@ -5349,7 +5349,7 @@ 
     if rev and node:
         raise error.Abort(_("please specify just one revision"))
 
-    if ui.configbool('commands', 'update.requiredest', False):
+    if ui.configbool('commands', 'update.requiredest'):
         if not node and not rev and not date:
             raise error.Abort(_('you must specify a destination'),
                               hint=_('for example: hg update ".::"'))
diff -r 55c6788c54e2 -r 1ed5ec882c49 mercurial/ui.py
--- a/mercurial/ui.py	Tue Mar 21 22:47:49 2017 -0700
+++ b/mercurial/ui.py	Tue Mar 21 21:26:52 2017 -0700
@@ -284,6 +284,8 @@ 
                     del cfg['ui'][k]
             for k, v in cfg.items('defaults'):
                 del cfg['defaults'][k]
+            for k, v in cfg.items('commands'):
+                del cfg['commands'][k]
         # Don't remove aliases from the configuration if in the exceptionlist
         if self.plain('alias'):
             for k, v in cfg.items('alias'):
diff -r 55c6788c54e2 -r 1ed5ec882c49 tests/test-rebase-base.t
--- a/tests/test-rebase-base.t	Tue Mar 21 22:47:49 2017 -0700
+++ b/tests/test-rebase-base.t	Tue Mar 21 21:26:52 2017 -0700
@@ -413,3 +413,7 @@ 
   $ hg rebase -d 1
   rebasing 2:5db65b93a12b "cc" (tip)
   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/5db65b93a12b-4fb789ec-backup.hg (glob)
+  $ hg rebase -d 0 -r . -q
+  $ HGPLAIN=1 hg rebase
+  rebasing 2:889b0bc6a730 "cc" (tip)
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/889b0bc6a730-41ec4f81-backup.hg (glob)
diff -r 55c6788c54e2 -r 1ed5ec882c49 tests/test-update-names.t
--- a/tests/test-update-names.t	Tue Mar 21 22:47:49 2017 -0700
+++ b/tests/test-update-names.t	Tue Mar 21 21:26:52 2017 -0700
@@ -104,3 +104,5 @@ 
   [255]
   $ hg up .
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ HGPLAIN=1 hg up
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved