Mercurial > hg > config
diff python/hgrc.py @ 904:30006a5583fa
fix hgrc.py for python3
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Thu, 11 Apr 2024 08:23:38 -0700 |
parents | 6da7d26e257b |
children |
line wrap: on
line diff
--- 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: