Patchwork [V2] config: honour the trusted flag in ui.configint

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2017, 6:38 p.m.
Message ID <6D6FA065-4EAF-4AC0-A5DC-27AAD894DDBF@durin42.com>
Download mbox | patch
Permalink /patch/19198/
State Changes Requested
Headers show

Comments

Augie Fackler - March 12, 2017, 6:38 p.m.
> On Mar 12, 2017, at 11:36, Augie Fackler <raf@durin42.com> wrote:
> 
> On Sun, Mar 12, 2017 at 10:34:33AM -0700, Martijn Pieters wrote:
>> # HG changeset patch
>> # User Martijn Pieters <mjpieters@fb.com>
>> # Date 1489340031 25200
>> #      Sun Mar 12 10:33:51 2017 -0700
>> # Node ID 55a2a84cb75e7bbfb9dcd510b686de417fb9dfab
>> # Parent  abf029200e198878a4576a87e095bd8d77d9cea9
>> config: honour the trusted flag in ui.configint
> 
> Queued, thanks.

Tests say hi:



> 
>> 
>> diff --git a/mercurial/ui.py b/mercurial/ui.py
>> --- a/mercurial/ui.py
>> +++ b/mercurial/ui.py
>> @@ -452,7 +452,7 @@
>>         ConfigError: foo.invalid is not a byte quantity ('somevalue')
>>         """
>> 
>> -        value = self.config(section, name)
>> +        value = self.config(section, name, None, untrusted)
>>         if value is None:
>>             if not isinstance(default, str):
>>                 return default
>> diff --git a/tests/test-trusted.py b/tests/test-trusted.py
>> --- a/tests/test-trusted.py
>> +++ b/tests/test-trusted.py
>> @@ -201,3 +201,38 @@
>>     testui(debug=True, silent=True)
>> except error.ParseError as inst:
>>     print(inst)
>> +
>> +
>> +print()
>> +print('# access typed information')
>> +with open('.hg/hgrc', 'w') as f:
>> +    f.write('''\
>> +[foo]
>> +sub=main
>> +sub:one=one
>> +sub:two=two
>> +path=monty/python
>> +bool=true
>> +int=42
>> +bytes=81mb
>> +list=spam,ham,eggs
>> +''')
>> +u = testui(user='abc', group='def', cuser='foo', silent=True)
>> +print('# suboptions, trusted and untrusted')
>> +print(u.configsuboptions('foo', 'sub'), u.configsuboptions('foo', 'sub', untrusted=True))
>> +print('# path, trusted and untrusted')
>> +print(u.configpath('foo', 'path'), u.configpath('foo', 'path', untrusted=True))
>> +print('# bool, trusted and untrusted')
>> +print(u.configbool('foo', 'bool'), u.configbool('foo', 'bool', untrusted=True))
>> +print('# int, trusted and untrusted')
>> +print(
>> +    u.configint('foo', 'int', 0),
>> +    u.configint('foo', 'int', 0, untrusted=True))
>> +print('# bytes, trusted and untrusted')
>> +print(
>> +    u.configbytes('foo', 'bytes', 0),
>> +    u.configbytes('foo', 'bytes', 0, untrusted=True))
>> +print('# list, trusted and untrusted')
>> +print(
>> +    u.configlist('foo', 'list', []),
>> +    u.configlist('foo', 'list', [], untrusted=True))
>> diff --git a/tests/test-trusted.py.out b/tests/test-trusted.py.out
>> --- a/tests/test-trusted.py.out
>> +++ b/tests/test-trusted.py.out
>> @@ -177,3 +177,19 @@
>> ('foo', '.hg/hgrc:1')
>> # same user, same group
>> ('foo', '.hg/hgrc:1')
>> +
>> +# access typed information
>> +# different user, different group
>> +not trusting file .hg/hgrc from untrusted user abc, group def
>> +# suboptions, trusted and untrusted
>> +(None, {}) ('main', {'two': 'two', 'one': 'one'})
>> +# path, trusted and untrusted
>> +None .hg/monty/python
>> +# bool, trusted and untrusted
>> +False True
>> +# int, trusted and untrusted
>> +0 42
>> +# bytes, trusted and untrusted
>> +0 84934656
>> +# list, trusted and untrusted
>> +[] ['spam', 'ham', 'eggs']
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

--- /home/augie/hg/tests/test-check-commit.t
+++ /home/augie/hg/tests/test-check-commit.t.err
@@ -17,5 +17,10 @@ 
   >        echo
   >   fi
   > done
+  Revision 4fc3340f1c7a does not comply with rules
+  ------------------------------------------------------
+  28: adds double empty line
+   +
+

--- /home/augie/hg/tests/test-trusted.py.out
+++ /home/augie/hg/tests/test-trusted.py.err
@@ -182,7 +182,7 @@ 
 # different user, different group
 not trusting file .hg/hgrc from untrusted user abc, group def
 # suboptions, trusted and untrusted
-(None, {}) ('main', {'two': 'two', 'one': 'one'})
+(None, {}) ('main', {'one': 'one', 'two': 'two'})
 # path, trusted and untrusted
 None .hg/monty/python
 # bool, trusted and untrusted

--- /home/augie/hg/tests/test-check-code.t
+++ /home/augie/hg/tests/test-check-code.t.err
@@ -31,6 +31,9 @@ 
    > policy = os.environ.get('HGMODULEPOLICY', policy)
    use encoding.environ instead (py3)
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
+  tests/test-trusted.py:222:
+   > print(u.configsuboptions('foo', 'sub'), u.configsuboptions('foo', 'sub', untrusted=True))
+   line too long
   [1]

 @commands in debugcommands.py should be in alphabetical order.