Mercurial > public > mercurial-scm > hg
diff contrib/genosxversion.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 197e7326b8b8 |
children | 148d177a4f2d |
line wrap: on
line diff
--- a/contrib/genosxversion.py Sat Oct 05 10:29:34 2019 -0400 +++ b/contrib/genosxversion.py Sun Oct 06 09:45:02 2019 -0400 @@ -7,21 +7,25 @@ import sys # Always load hg libraries from the hg we can find on $PATH. -hglib = subprocess.check_output( - ['hg', 'debuginstall', '-T', '{hgmodules}']) +hglib = subprocess.check_output(['hg', 'debuginstall', '-T', '{hgmodules}']) sys.path.insert(0, os.path.dirname(hglib)) from mercurial import util ap = argparse.ArgumentParser() -ap.add_argument('--paranoid', - action='store_true', - help=("Be paranoid about how version numbers compare and " - "produce something that's more likely to sort " - "reasonably.")) +ap.add_argument( + '--paranoid', + action='store_true', + help=( + "Be paranoid about how version numbers compare and " + "produce something that's more likely to sort " + "reasonably." + ), +) ap.add_argument('--selftest', action='store_true', help='Run self-tests.') ap.add_argument('versionfile', help='Path to a valid mercurial __version__.py') + def paranoidver(ver): """Given an hg version produce something that distutils can sort. @@ -108,22 +112,25 @@ extra = '' return '%d.%d.%d%s' % (major, minor, micro, extra) + def main(argv): opts = ap.parse_args(argv[1:]) if opts.selftest: import doctest + doctest.testmod() return with open(opts.versionfile) as f: for l in f: if l.startswith('version = b'): # version number is entire line minus the quotes - ver = l[len('version = b') + 1:-2] + ver = l[len('version = b') + 1 : -2] break if opts.paranoid: print(paranoidver(ver)) else: print(ver) + if __name__ == '__main__': main(sys.argv)