Show More
@@ -41,8 +41,8 b' class ParseError(Exception):' | |||||
41 | """Exception raised on errors in parsing the command line.""" |
|
41 | """Exception raised on errors in parsing the command line.""" | |
42 |
|
42 | |||
43 | def showhelp(): |
|
43 | def showhelp(): | |
44 |
|
|
44 | pycompat.stdout.write(usage.encode('utf8')) | |
45 |
|
|
45 | pycompat.stdout.write(b'\noptions:\n') | |
46 |
|
46 | |||
47 | out_opts = [] |
|
47 | out_opts = [] | |
48 | for shortopt, longopt, default, desc in options: |
|
48 | for shortopt, longopt, default, desc in options: | |
@@ -51,22 +51,23 b' def showhelp():' | |||||
51 | b'%s' % desc)) |
|
51 | b'%s' % desc)) | |
52 | opts_len = max([len(opt[0]) for opt in out_opts]) |
|
52 | opts_len = max([len(opt[0]) for opt in out_opts]) | |
53 | for first, second in out_opts: |
|
53 | for first, second in out_opts: | |
54 |
|
|
54 | pycompat.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) | |
55 |
|
55 | |||
56 | try: |
|
56 | try: | |
57 |
for fp in (sys.stdin, |
|
57 | for fp in (sys.stdin, pycompat.stdout, sys.stderr): | |
58 | procutil.setbinary(fp) |
|
58 | procutil.setbinary(fp) | |
59 |
|
59 | |||
60 | opts = {} |
|
60 | opts = {} | |
61 | try: |
|
61 | try: | |
62 | args = fancyopts.fancyopts(sys.argv[1:], options, opts) |
|
62 | bargv = [a.encode('utf8') for a in sys.argv[1:]] | |
|
63 | args = fancyopts.fancyopts(bargv, options, opts) | |||
63 | except getopt.GetoptError as e: |
|
64 | except getopt.GetoptError as e: | |
64 | raise ParseError(e) |
|
65 | raise ParseError(e) | |
65 | if opts[b'help']: |
|
66 | if opts[b'help']: | |
66 | showhelp() |
|
67 | showhelp() | |
67 | sys.exit(0) |
|
68 | sys.exit(0) | |
68 | if len(args) != 3: |
|
69 | if len(args) != 3: | |
69 | raise ParseError(_(b'wrong number of arguments')) |
|
70 | raise ParseError(_(b'wrong number of arguments').decode('utf8')) | |
70 | local, base, other = args |
|
71 | local, base, other = args | |
71 | sys.exit(simplemerge.simplemerge(uimod.ui.load(), |
|
72 | sys.exit(simplemerge.simplemerge(uimod.ui.load(), | |
72 | context.arbitraryfilectx(local), |
|
73 | context.arbitraryfilectx(local), | |
@@ -74,11 +75,13 b' try:' | |||||
74 | context.arbitraryfilectx(other), |
|
75 | context.arbitraryfilectx(other), | |
75 | **pycompat.strkwargs(opts))) |
|
76 | **pycompat.strkwargs(opts))) | |
76 | except ParseError as e: |
|
77 | except ParseError as e: | |
77 | sys.stdout.write(b"%s: %s\n" % (sys.argv[0], e)) |
|
78 | if pycompat.ispy3: | |
|
79 | e = str(e).encode('utf8') | |||
|
80 | pycompat.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) | |||
78 | showhelp() |
|
81 | showhelp() | |
79 | sys.exit(1) |
|
82 | sys.exit(1) | |
80 | except error.Abort as e: |
|
83 | except error.Abort as e: | |
81 |
|
|
84 | pycompat.stderr.write(b"abort: %s\n" % e) | |
82 | sys.exit(255) |
|
85 | sys.exit(255) | |
83 | except KeyboardInterrupt: |
|
86 | except KeyboardInterrupt: | |
84 | sys.exit(255) |
|
87 | sys.exit(255) |
General Comments 0
You need to be logged in to leave comments.
Login now