D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes

2018-10-13 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5519697b71b3: contrib: fix up output in check-config.py to 
use strs to avoid b prefixes (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5059?vs=12071=12086

REVISION DETAIL
  https://phab.mercurial-scm.org/D5059

AFFECTED FILES
  contrib/check-config.py
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -59,6 +59,7 @@
 test-changelog-exec.t
 test-check-code.t
 test-check-commit.t
+test-check-config.py
 test-check-execute.t
 test-check-interfaces.py
 test-check-module-imports.t
diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -42,6 +42,14 @@
 config:\s(?P\S+\.\S+)$
 ''', re.VERBOSE | re.MULTILINE)
 
+if sys.version_info[0] > 2:
+def mkstr(b):
+if isinstance(b, str):
+return b
+return b.decode('utf8')
+else:
+mkstr = lambda x: x
+
 def main(args):
 for f in args:
 sect = b''
@@ -92,7 +100,7 @@
 # look for ignore markers
 m = ignorere.search(l)
 if m:
-if m.group('reason') == 'inconsistent':
+if m.group('reason') == b'inconsistent':
 allowinconsistent.add(m.group('config'))
 else:
 documented[m.group('config')] = 1
@@ -106,16 +114,20 @@
 ctype = 'str'
 name = m.group('section') + b"." + m.group('option')
 default = m.group('default')
-if default in (None, 'False', 'None', '0', '[]', '""', "''"):
+if default in (
+None, b'False', b'None', b'0', b'[]', b'""', b"''"):
 default = b''
 if re.match(b'[a-z.]+$', default):
 default = b''
 if (name in foundopts and (ctype, default) != foundopts[name]
 and name not in allowinconsistent):
-print(l.rstrip())
-print("conflict on %s: %r != %r" % (name, (ctype, default),
-foundopts[name]))
-print("at %s:%d:" % (f, linenum))
+print(mkstr(l.rstrip()))
+fctype, fdefault = foundopts[name]
+print("conflict on %s: %r != %r" % (
+mkstr(name),
+(mkstr(ctype), mkstr(default)),
+(mkstr(fctype), mkstr(fdefault
+print("at %s:%d:" % (mkstr(f), linenum))
 foundopts[name] = (ctype, default)
 carryover = b''
 else:
@@ -132,8 +144,13 @@
 name.startswith(b"debug.")):
 ctype, default = foundopts[name]
 if default:
+if isinstance(default, bytes):
+default = mkstr(default)
 default = ' [%s]' % default
-print("undocumented: %s (%s)%s" % (name, ctype, default))
+elif isinstance(default, bytes):
+default = mkstr(default)
+print("undocumented: %s (%s)%s" % (
+mkstr(name), mkstr(ctype), default))
 
 if __name__ == "__main__":
 if len(sys.argv) > 1:



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes

2018-10-13 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 12071.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5059?vs=12049=12071

REVISION DETAIL
  https://phab.mercurial-scm.org/D5059

AFFECTED FILES
  contrib/check-config.py
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -59,6 +59,7 @@
 test-changelog-exec.t
 test-check-code.t
 test-check-commit.t
+test-check-config.py
 test-check-execute.t
 test-check-interfaces.py
 test-check-module-imports.t
diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -42,6 +42,14 @@
 config:\s(?P\S+\.\S+)$
 ''', re.VERBOSE | re.MULTILINE)
 
+if sys.version_info[0] > 2:
+def mkstr(b):
+if isinstance(b, str):
+return b
+return b.decode('utf8')
+else:
+mkstr = lambda x: x
+
 def main(args):
 for f in args:
 sect = b''
@@ -92,7 +100,7 @@
 # look for ignore markers
 m = ignorere.search(l)
 if m:
-if m.group('reason') == 'inconsistent':
+if m.group('reason') == b'inconsistent':
 allowinconsistent.add(m.group('config'))
 else:
 documented[m.group('config')] = 1
@@ -106,16 +114,20 @@
 ctype = 'str'
 name = m.group('section') + b"." + m.group('option')
 default = m.group('default')
-if default in (None, 'False', 'None', '0', '[]', '""', "''"):
+if default in (
+None, b'False', b'None', b'0', b'[]', b'""', b"''"):
 default = b''
 if re.match(b'[a-z.]+$', default):
 default = b''
 if (name in foundopts and (ctype, default) != foundopts[name]
 and name not in allowinconsistent):
-print(l.rstrip())
-print("conflict on %s: %r != %r" % (name, (ctype, default),
-foundopts[name]))
-print("at %s:%d:" % (f, linenum))
+print(mkstr(l.rstrip()))
+fctype, fdefault = foundopts[name]
+print("conflict on %s: %r != %r" % (
+mkstr(name),
+(mkstr(ctype), mkstr(default)),
+(mkstr(fctype), mkstr(fdefault
+print("at %s:%d:" % (mkstr(f), linenum))
 foundopts[name] = (ctype, default)
 carryover = b''
 else:
@@ -132,8 +144,13 @@
 name.startswith(b"debug.")):
 ctype, default = foundopts[name]
 if default:
+if isinstance(default, bytes):
+default = mkstr(default)
 default = ' [%s]' % default
-print("undocumented: %s (%s)%s" % (name, ctype, default))
+elif isinstance(default, bytes):
+default = mkstr(default)
+print("undocumented: %s (%s)%s" % (
+mkstr(name), mkstr(ctype), default))
 
 if __name__ == "__main__":
 if len(sys.argv) > 1:



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes

2018-10-13 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 12049.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5059?vs=12027=12049

REVISION DETAIL
  https://phab.mercurial-scm.org/D5059

AFFECTED FILES
  contrib/check-config.py
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -58,6 +58,7 @@
 test-changelog-exec.t
 test-check-code.t
 test-check-commit.t
+test-check-config.py
 test-check-execute.t
 test-check-interfaces.py
 test-check-module-imports.t
diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -42,6 +42,14 @@
 config:\s(?P\S+\.\S+)$
 ''', re.VERBOSE | re.MULTILINE)
 
+if sys.version_info[0] > 2:
+def mkstr(b):
+if isinstance(b, str):
+return b
+return b.decode('utf8')
+else:
+mkstr = lambda x: x
+
 def main(args):
 for f in args:
 sect = b''
@@ -92,7 +100,7 @@
 # look for ignore markers
 m = ignorere.search(l)
 if m:
-if m.group('reason') == 'inconsistent':
+if m.group('reason') == b'inconsistent':
 allowinconsistent.add(m.group('config'))
 else:
 documented[m.group('config')] = 1
@@ -106,16 +114,20 @@
 ctype = 'str'
 name = m.group('section') + b"." + m.group('option')
 default = m.group('default')
-if default in (None, 'False', 'None', '0', '[]', '""', "''"):
+if default in (
+None, b'False', b'None', b'0', b'[]', b'""', b"''"):
 default = b''
 if re.match(b'[a-z.]+$', default):
 default = b''
 if (name in foundopts and (ctype, default) != foundopts[name]
 and name not in allowinconsistent):
-print(l.rstrip())
-print("conflict on %s: %r != %r" % (name, (ctype, default),
-foundopts[name]))
-print("at %s:%d:" % (f, linenum))
+print(mkstr(l.rstrip()))
+fctype, fdefault = foundopts[name]
+print("conflict on %s: %r != %r" % (
+mkstr(name),
+(mkstr(ctype), mkstr(default)),
+(mkstr(fctype), mkstr(fdefault
+print("at %s:%d:" % (mkstr(f), linenum))
 foundopts[name] = (ctype, default)
 carryover = b''
 else:
@@ -132,8 +144,13 @@
 name.startswith(b"debug.")):
 ctype, default = foundopts[name]
 if default:
+if isinstance(default, bytes):
+default = mkstr(default)
 default = ' [%s]' % default
-print("undocumented: %s (%s)%s" % (name, ctype, default))
+elif isinstance(default, bytes):
+default = mkstr(default)
+print("undocumented: %s (%s)%s" % (
+mkstr(name), mkstr(ctype), default))
 
 if __name__ == "__main__":
 if len(sys.argv) > 1:



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes

2018-10-13 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 12027.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5059?vs=12017=12027

REVISION DETAIL
  https://phab.mercurial-scm.org/D5059

AFFECTED FILES
  contrib/check-config.py
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -58,6 +58,7 @@
 test-changelog-exec.t
 test-check-code.t
 test-check-commit.t
+test-check-config.py
 test-check-execute.t
 test-check-interfaces.py
 test-check-module-imports.t
diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -42,6 +42,14 @@
 config:\s(?P\S+\.\S+)$
 ''', re.VERBOSE | re.MULTILINE)
 
+if sys.version_info[0] > 2:
+def mkstr(b):
+if isinstance(b, str):
+return b
+return b.decode('utf8')
+else:
+mkstr = lambda x: x
+
 def main(args):
 for f in args:
 sect = b''
@@ -92,7 +100,7 @@
 # look for ignore markers
 m = ignorere.search(l)
 if m:
-if m.group('reason') == 'inconsistent':
+if m.group('reason') == b'inconsistent':
 allowinconsistent.add(m.group('config'))
 else:
 documented[m.group('config')] = 1
@@ -106,16 +114,20 @@
 ctype = 'str'
 name = m.group('section') + b"." + m.group('option')
 default = m.group('default')
-if default in (None, 'False', 'None', '0', '[]', '""', "''"):
+if default in (
+None, b'False', b'None', b'0', b'[]', b'""', b"''"):
 default = b''
 if re.match(b'[a-z.]+$', default):
 default = b''
 if (name in foundopts and (ctype, default) != foundopts[name]
 and name not in allowinconsistent):
-print(l.rstrip())
-print("conflict on %s: %r != %r" % (name, (ctype, default),
-foundopts[name]))
-print("at %s:%d:" % (f, linenum))
+print(mkstr(l.rstrip()))
+fctype, fdefault = foundopts[name]
+print("conflict on %s: %r != %r" % (
+mkstr(name),
+(mkstr(ctype), mkstr(default)),
+(mkstr(fctype), mkstr(fdefault
+print("at %s:%d:" % (mkstr(f), linenum))
 foundopts[name] = (ctype, default)
 carryover = b''
 else:
@@ -132,8 +144,13 @@
 name.startswith(b"debug.")):
 ctype, default = foundopts[name]
 if default:
+if isinstance(default, bytes):
+default = mkstr(default)
 default = ' [%s]' % default
-print("undocumented: %s (%s)%s" % (name, ctype, default))
+elif isinstance(default, bytes):
+default = mkstr(default)
+print("undocumented: %s (%s)%s" % (
+mkstr(name), mkstr(ctype), default))
 
 if __name__ == "__main__":
 if len(sys.argv) > 1:



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5059: contrib: fix up output in check-config.py to use strs to avoid b prefixes

2018-10-13 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a reviewer: pulkit.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5059

AFFECTED FILES
  contrib/check-config.py
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -57,6 +57,7 @@
 test-changelog-exec.t
 test-check-code.t
 test-check-commit.t
+test-check-config.py
 test-check-execute.t
 test-check-interfaces.py
 test-check-module-imports.t
diff --git a/contrib/check-config.py b/contrib/check-config.py
--- a/contrib/check-config.py
+++ b/contrib/check-config.py
@@ -42,6 +42,14 @@
 config:\s(?P\S+\.\S+)$
 ''', re.VERBOSE | re.MULTILINE)
 
+if sys.version_info[0] > 2:
+def mkstr(b):
+if isinstance(b, str):
+return b
+return b.decode('utf8')
+else:
+mkstr = lambda x: x
+
 def main(args):
 for f in args:
 sect = b''
@@ -92,7 +100,7 @@
 # look for ignore markers
 m = ignorere.search(l)
 if m:
-if m.group('reason') == 'inconsistent':
+if m.group('reason') == b'inconsistent':
 allowinconsistent.add(m.group('config'))
 else:
 documented[m.group('config')] = 1
@@ -106,16 +114,20 @@
 ctype = 'str'
 name = m.group('section') + b"." + m.group('option')
 default = m.group('default')
-if default in (None, 'False', 'None', '0', '[]', '""', "''"):
+if default in (
+None, b'False', b'None', b'0', b'[]', b'""', b"''"):
 default = b''
 if re.match(b'[a-z.]+$', default):
 default = b''
 if (name in foundopts and (ctype, default) != foundopts[name]
 and name not in allowinconsistent):
-print(l.rstrip())
-print("conflict on %s: %r != %r" % (name, (ctype, default),
-foundopts[name]))
-print("at %s:%d:" % (f, linenum))
+print(mkstr(l.rstrip()))
+fctype, fdefault = foundopts[name]
+print("conflict on %s: %r != %r" % (
+mkstr(name),
+(mkstr(ctype), mkstr(default)),
+(mkstr(fctype), mkstr(fdefault
+print("at %s:%d:" % (mkstr(f), linenum))
 foundopts[name] = (ctype, default)
 carryover = b''
 else:
@@ -132,8 +144,13 @@
 name.startswith(b"debug.")):
 ctype, default = foundopts[name]
 if default:
+if isinstance(default, bytes):
+default = mkstr(default)
 default = ' [%s]' % default
-print("undocumented: %s (%s)%s" % (name, ctype, default))
+elif isinstance(default, bytes):
+default = mkstr(default)
+print("undocumented: %s (%s)%s" % (
+mkstr(name), mkstr(ctype), default))
 
 if __name__ == "__main__":
 if len(sys.argv) > 1:



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel