--- a/mercurial/ui.py Thu Sep 07 22:36:54 2017 +0900
+++ b/mercurial/ui.py Sun Sep 03 14:32:11 2017 +0900
@@ -531,19 +531,19 @@
def configbool(self, section, name, default=_unset, untrusted=False):
"""parse a configuration element as a boolean
- >>> u = ui(); s = 'foo'
- >>> u.setconfig(s, 'true', 'yes')
- >>> u.configbool(s, 'true')
+ >>> u = ui(); s = b'foo'
+ >>> u.setconfig(s, b'true', b'yes')
+ >>> u.configbool(s, b'true')
True
- >>> u.setconfig(s, 'false', 'no')
- >>> u.configbool(s, 'false')
+ >>> u.setconfig(s, b'false', b'no')
+ >>> u.configbool(s, b'false')
False
- >>> u.configbool(s, 'unknown')
+ >>> u.configbool(s, b'unknown')
False
- >>> u.configbool(s, 'unknown', True)
+ >>> u.configbool(s, b'unknown', True)
True
- >>> u.setconfig(s, 'invalid', 'somevalue')
- >>> u.configbool(s, 'invalid')
+ >>> u.setconfig(s, b'invalid', b'somevalue')
+ >>> u.configbool(s, b'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a boolean ('somevalue')
@@ -568,21 +568,21 @@
desc=None, untrusted=False):
"""parse a configuration element with a conversion function
- >>> u = ui(); s = 'foo'
- >>> u.setconfig(s, 'float1', '42')
- >>> u.configwith(float, s, 'float1')
+ >>> u = ui(); s = b'foo'
+ >>> u.setconfig(s, b'float1', b'42')
+ >>> u.configwith(float, s, b'float1')
42.0
- >>> u.setconfig(s, 'float2', '-4.25')
- >>> u.configwith(float, s, 'float2')
+ >>> u.setconfig(s, b'float2', b'-4.25')
+ >>> u.configwith(float, s, b'float2')
-4.25
- >>> u.configwith(float, s, 'unknown', 7)
+ >>> u.configwith(float, s, b'unknown', 7)
7.0
- >>> u.setconfig(s, 'invalid', 'somevalue')
- >>> u.configwith(float, s, 'invalid')
+ >>> u.setconfig(s, b'invalid', b'somevalue')
+ >>> u.configwith(float, s, b'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a valid float ('somevalue')
- >>> u.configwith(float, s, 'invalid', desc='womble')
+ >>> u.configwith(float, s, b'invalid', desc=b'womble')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a valid womble ('somevalue')
@@ -602,17 +602,17 @@
def configint(self, section, name, default=_unset, untrusted=False):
"""parse a configuration element as an integer
- >>> u = ui(); s = 'foo'
- >>> u.setconfig(s, 'int1', '42')
- >>> u.configint(s, 'int1')
+ >>> u = ui(); s = b'foo'
+ >>> u.setconfig(s, b'int1', b'42')
+ >>> u.configint(s, b'int1')
42
- >>> u.setconfig(s, 'int2', '-42')
- >>> u.configint(s, 'int2')
+ >>> u.setconfig(s, b'int2', b'-42')
+ >>> u.configint(s, b'int2')
-42
- >>> u.configint(s, 'unknown', 7)
+ >>> u.configint(s, b'unknown', 7)
7
- >>> u.setconfig(s, 'invalid', 'somevalue')
- >>> u.configint(s, 'invalid')
+ >>> u.setconfig(s, b'invalid', b'somevalue')
+ >>> u.configint(s, b'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a valid integer ('somevalue')
@@ -627,17 +627,17 @@
Units can be specified as b (bytes), k or kb (kilobytes), m or
mb (megabytes), g or gb (gigabytes).
- >>> u = ui(); s = 'foo'
- >>> u.setconfig(s, 'val1', '42')
- >>> u.configbytes(s, 'val1')
+ >>> u = ui(); s = b'foo'
+ >>> u.setconfig(s, b'val1', b'42')
+ >>> u.configbytes(s, b'val1')
42
- >>> u.setconfig(s, 'val2', '42.5 kb')
- >>> u.configbytes(s, 'val2')
+ >>> u.setconfig(s, b'val2', b'42.5 kb')
+ >>> u.configbytes(s, b'val2')
43520
- >>> u.configbytes(s, 'unknown', '7 MB')
+ >>> u.configbytes(s, b'unknown', b'7 MB')
7340032
- >>> u.setconfig(s, 'invalid', 'somevalue')
- >>> u.configbytes(s, 'invalid')
+ >>> u.setconfig(s, b'invalid', b'somevalue')
+ >>> u.configbytes(s, b'invalid')
Traceback (most recent call last):
...
ConfigError: foo.invalid is not a byte quantity ('somevalue')
@@ -660,9 +660,9 @@
"""parse a configuration element as a list of comma/space separated
strings
- >>> u = ui(); s = 'foo'
- >>> u.setconfig(s, 'list1', 'this,is "a small" ,test')
- >>> u.configlist(s, 'list1')
+ >>> u = ui(); s = b'foo'
+ >>> u.setconfig(s, b'list1', b'this,is "a small" ,test')
+ >>> u.configlist(s, b'list1')
['this', 'is', 'a small', 'test']
"""
# default is not always a list
@@ -677,9 +677,9 @@
def configdate(self, section, name, default=_unset, untrusted=False):
"""parse a configuration element as a tuple of ints
- >>> u = ui(); s = 'foo'
- >>> u.setconfig(s, 'date', '0 0')
- >>> u.configdate(s, 'date')
+ >>> u = ui(); s = b'foo'
+ >>> u.setconfig(s, b'date', b'0 0')
+ >>> u.configdate(s, b'date')
(0, 0)
"""
if self.config(section, name, default, untrusted):
@@ -1256,11 +1256,11 @@
This returns tuple "(message, choices)", and "choices" is the
list of tuple "(response character, text without &)".
- >>> ui.extractchoices("awake? $$ &Yes $$ &No")
+ >>> ui.extractchoices(b"awake? $$ &Yes $$ &No")
('awake? ', [('y', 'Yes'), ('n', 'No')])
- >>> ui.extractchoices("line\\nbreak? $$ &Yes $$ &No")
+ >>> ui.extractchoices(b"line\\nbreak? $$ &Yes $$ &No")
('line\\nbreak? ', [('y', 'Yes'), ('n', 'No')])
- >>> ui.extractchoices("want lots of $$money$$?$$Ye&s$$N&o")
+ >>> ui.extractchoices(b"want lots of $$money$$?$$Ye&s$$N&o")
('want lots of $$money$$?', [('s', 'Yes'), ('o', 'No')])
"""