Mercurial > hg
diff contrib/simplemerge @ 43659:99e231afc29c
black: blacken scripts
test-check-format.t doesn't appear to detect Python scripts with shebangs.
But my editor which is configured to auto run black on Python files does
and it appears some files are not blackened.
This commit blackens scripts that need it.
# skip-blame reformatting
Differential Revision: https://phab.mercurial-scm.org/D7420
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 14 Nov 2019 20:35:11 -0800 |
parents | 3c2799cbace4 |
children | 4c1b4805db57 |
line wrap: on
line diff
--- a/contrib/simplemerge Tue Nov 12 10:17:59 2019 -0500 +++ b/contrib/simplemerge Thu Nov 14 20:35:11 2019 -0800 @@ -5,6 +5,7 @@ import sys import hgdemandimport + hgdemandimport.enable() from mercurial.i18n import _ @@ -16,44 +17,54 @@ simplemerge, ui as uimod, ) -from mercurial.utils import ( - procutil, - stringutil -) +from mercurial.utils import procutil, stringutil -options = [(b'L', b'label', [], _(b'labels to use on conflict markers')), - (b'a', b'text', None, _(b'treat all files as text')), - (b'p', b'print', None, - _(b'print results instead of overwriting LOCAL')), - (b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')), - (b'h', b'help', None, _(b'display help and exit')), - (b'q', b'quiet', None, _(b'suppress output'))] +options = [ + (b'L', b'label', [], _(b'labels to use on conflict markers')), + (b'a', b'text', None, _(b'treat all files as text')), + (b'p', b'print', None, _(b'print results instead of overwriting LOCAL')), + (b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')), + (b'h', b'help', None, _(b'display help and exit')), + (b'q', b'quiet', None, _(b'suppress output')), +] -usage = _(b'''simplemerge [OPTS] LOCAL BASE OTHER +usage = _( + b'''simplemerge [OPTS] LOCAL BASE OTHER Simple three-way file merge utility with a minimal feature set. Apply to LOCAL the changes necessary to go from BASE to OTHER. By default, LOCAL is overwritten with the results of this operation. -''') +''' +) + class ParseError(Exception): """Exception raised on errors in parsing the command line.""" + def showhelp(): pycompat.stdout.write(usage) pycompat.stdout.write(b'\noptions:\n') out_opts = [] for shortopt, longopt, default, desc in options: - out_opts.append((b'%2s%s' % (shortopt and b'-%s' % shortopt, - longopt and b' --%s' % longopt), - b'%s' % desc)) + out_opts.append( + ( + b'%2s%s' + % ( + shortopt and b'-%s' % shortopt, + longopt and b' --%s' % longopt, + ), + b'%s' % desc, + ) + ) opts_len = max([len(opt[0]) for opt in out_opts]) for first, second in out_opts: pycompat.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) + try: for fp in (sys.stdin, pycompat.stdout, sys.stderr): procutil.setbinary(fp) @@ -68,13 +79,17 @@ showhelp() sys.exit(0) if len(args) != 3: - raise ParseError(_(b'wrong number of arguments').decode('utf8')) + raise ParseError(_(b'wrong number of arguments').decode('utf8')) local, base, other = args - sys.exit(simplemerge.simplemerge(uimod.ui.load(), - context.arbitraryfilectx(local), - context.arbitraryfilectx(base), - context.arbitraryfilectx(other), - **pycompat.strkwargs(opts))) + sys.exit( + simplemerge.simplemerge( + uimod.ui.load(), + context.arbitraryfilectx(local), + context.arbitraryfilectx(base), + context.arbitraryfilectx(other), + **pycompat.strkwargs(opts) + ) + ) except ParseError as e: e = stringutil.forcebytestr(e) pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e))