# HG changeset patch # User Jeff Hammel # Date 1712849018 25200 # Node ID 30006a5583fa3022d65b286925640b76177c7c29 # Parent 08da6a1bb4c94fe2513306df46bcb0d3eb49f77b fix hgrc.py for python3 diff -r 08da6a1bb4c9 -r 30006a5583fa python/hgrc.py --- a/python/hgrc.py Sat Nov 18 13:24:26 2023 -0800 +++ b/python/hgrc.py Thu Apr 11 08:23:38 2024 -0700 @@ -40,6 +40,7 @@ """is path an {http,https}:// URL?""" return urlparse.urlsplit(path)[0] in ('http', 'https') + class section(object): def __init__(self, section_name, *section_names): self.sections = [section_name] @@ -58,6 +59,7 @@ """set [paths]:default""" parser.set('paths', 'default', default) + @section('paths') def set_default_push(parser, default_push): """ @@ -65,6 +67,7 @@ """ parser.set('paths', 'default-push', default_push) + def set_default_push_to_ssh(parser): """ set `[paths]:default-push` to that given by `[paths]:default` but @@ -175,10 +178,12 @@ hgrc.append(path) # raise errors if encountered - if filter(None, errors.values()): + _errors = list(filter(None, errors.values())) + if _errors: + print('errors encountered: {}'.format(_errors)) for key, value in errors.items(): if value: - print ('%s: %s' % (key, ', '.join(value))) + print('%s: %s' % (key, ', '.join(value))) parser.exit(1) # construct ConfigParser objects and @@ -186,7 +191,7 @@ config = {} for path in hgrc: config[path] = ConfigParser() - if isinstance(path, basestring): + if isinstance(path, str): if os.path.exists(path): config[path].read(path) elif path in urls: