Patchwork [1,of,2] update: ignore commands.update.requiredest if HGPLAIN=1

login
register
mail settings
Submitter via Mercurial-devel
Date March 22, 2017, 4:27 a.m.
Message ID <2558f3d814f50681641f.1490156840@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/19547/
State Changes Requested
Headers show

Comments

via Mercurial-devel - March 22, 2017, 4:27 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1490156520 25200
#      Tue Mar 21 21:22:00 2017 -0700
# Node ID 2558f3d814f50681641fff9815d30129de2ab5ad
# Parent  13dc00c233b7e374a6fa0b9846510a94c2615671
update: ignore commands.update.requiredest if HGPLAIN=1
Yuya Nishihara - March 22, 2017, 1:09 p.m.
On Tue, 21 Mar 2017 21:27:20 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1490156520 25200
> #      Tue Mar 21 21:22:00 2017 -0700
> # Node ID 2558f3d814f50681641fff9815d30129de2ab5ad
> # Parent  13dc00c233b7e374a6fa0b9846510a94c2615671
> update: ignore commands.update.requiredest if HGPLAIN=1
> 
> diff -r 13dc00c233b7 -r 2558f3d814f5 mercurial/commands.py
> --- a/mercurial/commands.py	Tue Mar 14 17:43:44 2017 -0700
> +++ b/mercurial/commands.py	Tue Mar 21 21:22:00 2017 -0700
> @@ -5349,7 +5349,8 @@
>      if rev and node:
>          raise error.Abort(_("please specify just one revision"))
>  
> -    if ui.configbool('commands', 'update.requiredest', False):
> +    if (not ui.plain() and
> +        ui.configbool('commands', 'update.requiredest', False)):
>          if not node and not rev and not date:
>              raise error.Abort(_('you must specify a destination'),
>                                hint=_('for example: hg update ".::"'))

Perhaps it will be better to handle this kind of HGPLAIN stuff in ui.py
like how 'defaults' section is ignored.
via Mercurial-devel - March 22, 2017, 3:33 p.m.
On Wed, Mar 22, 2017 at 6:09 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Tue, 21 Mar 2017 21:27:20 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz@google.com>
>> # Date 1490156520 25200
>> #      Tue Mar 21 21:22:00 2017 -0700
>> # Node ID 2558f3d814f50681641fff9815d30129de2ab5ad
>> # Parent  13dc00c233b7e374a6fa0b9846510a94c2615671
>> update: ignore commands.update.requiredest if HGPLAIN=1
>>
>> diff -r 13dc00c233b7 -r 2558f3d814f5 mercurial/commands.py
>> --- a/mercurial/commands.py   Tue Mar 14 17:43:44 2017 -0700
>> +++ b/mercurial/commands.py   Tue Mar 21 21:22:00 2017 -0700
>> @@ -5349,7 +5349,8 @@
>>      if rev and node:
>>          raise error.Abort(_("please specify just one revision"))
>>
>> -    if ui.configbool('commands', 'update.requiredest', False):
>> +    if (not ui.plain() and
>> +        ui.configbool('commands', 'update.requiredest', False)):
>>          if not node and not rev and not date:
>>              raise error.Abort(_('you must specify a destination'),
>>                                hint=_('for example: hg update ".::"'))
>
> Perhaps it will be better to handle this kind of HGPLAIN stuff in ui.py
> like how 'defaults' section is ignored.

Makes sense. I'll just check that "HGPLAIN=1 hg --config
commands.update.requiredest=1 up" does not fail (I assume HGPLAIN
should also make it ignore commands.* configs provided via --config).
via Mercurial-devel - March 22, 2017, 3:47 p.m.
On Wed, Mar 22, 2017 at 8:33 AM, Martin von Zweigbergk
<martinvonz@google.com> wrote:
> On Wed, Mar 22, 2017 at 6:09 AM, Yuya Nishihara <yuya@tcha.org> wrote:
>> On Tue, 21 Mar 2017 21:27:20 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
>>> # HG changeset patch
>>> # User Martin von Zweigbergk <martinvonz@google.com>
>>> # Date 1490156520 25200
>>> #      Tue Mar 21 21:22:00 2017 -0700
>>> # Node ID 2558f3d814f50681641fff9815d30129de2ab5ad
>>> # Parent  13dc00c233b7e374a6fa0b9846510a94c2615671
>>> update: ignore commands.update.requiredest if HGPLAIN=1
>>>
>>> diff -r 13dc00c233b7 -r 2558f3d814f5 mercurial/commands.py
>>> --- a/mercurial/commands.py   Tue Mar 14 17:43:44 2017 -0700
>>> +++ b/mercurial/commands.py   Tue Mar 21 21:22:00 2017 -0700
>>> @@ -5349,7 +5349,8 @@
>>>      if rev and node:
>>>          raise error.Abort(_("please specify just one revision"))
>>>
>>> -    if ui.configbool('commands', 'update.requiredest', False):
>>> +    if (not ui.plain() and
>>> +        ui.configbool('commands', 'update.requiredest', False)):
>>>          if not node and not rev and not date:
>>>              raise error.Abort(_('you must specify a destination'),
>>>                                hint=_('for example: hg update ".::"'))
>>
>> Perhaps it will be better to handle this kind of HGPLAIN stuff in ui.py
>> like how 'defaults' section is ignored.
>
> Makes sense. I'll just check that "HGPLAIN=1 hg --config
> commands.update.requiredest=1 up" does not fail (I assume HGPLAIN
> should also make it ignore commands.* configs provided via --config).

Looks like my assumption was wrong, in the sense that that's not how
it currently works for the other flags. For example:

$ hg id
facd5b0862f1 tip
$ HGPLAIN=1 hg --config ui.quiet=1 id
facd5b0862f1

So I guess we should stick to that pattern for [commands]. That also
makes sense because it is similar to how HGRCPATH=/dev/null works;
config options can be added onto the otherwise empty config.

I'll just need to update the test case I included in this patch to
actually write the config to file.

Patch

diff -r 13dc00c233b7 -r 2558f3d814f5 mercurial/commands.py
--- a/mercurial/commands.py	Tue Mar 14 17:43:44 2017 -0700
+++ b/mercurial/commands.py	Tue Mar 21 21:22:00 2017 -0700
@@ -5349,7 +5349,8 @@ 
     if rev and node:
         raise error.Abort(_("please specify just one revision"))
 
-    if ui.configbool('commands', 'update.requiredest', False):
+    if (not ui.plain() and
+        ui.configbool('commands', 'update.requiredest', False)):
         if not node and not rev and not date:
             raise error.Abort(_('you must specify a destination'),
                               hint=_('for example: hg update ".::"'))
diff -r 13dc00c233b7 -r 2558f3d814f5 tests/test-update-names.t
--- a/tests/test-update-names.t	Tue Mar 14 17:43:44 2017 -0700
+++ b/tests/test-update-names.t	Tue Mar 21 21:22:00 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