Show More
@@ -1,67 +1,75 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | from __future__ import absolute_import | ||
3 | from mercurial import demandimport |
|
|||
4 | demandimport.enable() |
|
|||
5 |
|
3 | |||
6 | import getopt |
|
4 | import getopt | |
7 | import sys |
|
5 | import sys | |
|
6 | ||||
|
7 | import hgdemandimport | |||
|
8 | hgdemandimport.enable() | |||
|
9 | ||||
8 | from mercurial.i18n import _ |
|
10 | from mercurial.i18n import _ | |
9 | from mercurial import error, simplemerge, fancyopts, util, ui |
|
11 | from mercurial import ( | |
|
12 | error, | |||
|
13 | fancyopts, | |||
|
14 | simplemerge, | |||
|
15 | ui as uimod, | |||
|
16 | util, | |||
|
17 | ) | |||
10 |
|
18 | |||
11 | options = [('L', 'label', [], _('labels to use on conflict markers')), |
|
19 | options = [('L', 'label', [], _('labels to use on conflict markers')), | |
12 | ('a', 'text', None, _('treat all files as text')), |
|
20 | ('a', 'text', None, _('treat all files as text')), | |
13 | ('p', 'print', None, |
|
21 | ('p', 'print', None, | |
14 | _('print results instead of overwriting LOCAL')), |
|
22 | _('print results instead of overwriting LOCAL')), | |
15 | ('', 'no-minimal', None, _('no effect (DEPRECATED)')), |
|
23 | ('', 'no-minimal', None, _('no effect (DEPRECATED)')), | |
16 | ('h', 'help', None, _('display help and exit')), |
|
24 | ('h', 'help', None, _('display help and exit')), | |
17 | ('q', 'quiet', None, _('suppress output'))] |
|
25 | ('q', 'quiet', None, _('suppress output'))] | |
18 |
|
26 | |||
19 | usage = _('''simplemerge [OPTS] LOCAL BASE OTHER |
|
27 | usage = _('''simplemerge [OPTS] LOCAL BASE OTHER | |
20 |
|
28 | |||
21 | Simple three-way file merge utility with a minimal feature set. |
|
29 | Simple three-way file merge utility with a minimal feature set. | |
22 |
|
30 | |||
23 | Apply to LOCAL the changes necessary to go from BASE to OTHER. |
|
31 | Apply to LOCAL the changes necessary to go from BASE to OTHER. | |
24 |
|
32 | |||
25 | By default, LOCAL is overwritten with the results of this operation. |
|
33 | By default, LOCAL is overwritten with the results of this operation. | |
26 | ''') |
|
34 | ''') | |
27 |
|
35 | |||
28 | class ParseError(Exception): |
|
36 | class ParseError(Exception): | |
29 | """Exception raised on errors in parsing the command line.""" |
|
37 | """Exception raised on errors in parsing the command line.""" | |
30 |
|
38 | |||
31 | def showhelp(): |
|
39 | def showhelp(): | |
32 | sys.stdout.write(usage) |
|
40 | sys.stdout.write(usage) | |
33 | sys.stdout.write('\noptions:\n') |
|
41 | sys.stdout.write('\noptions:\n') | |
34 |
|
42 | |||
35 | out_opts = [] |
|
43 | out_opts = [] | |
36 | for shortopt, longopt, default, desc in options: |
|
44 | for shortopt, longopt, default, desc in options: | |
37 | out_opts.append(('%2s%s' % (shortopt and '-%s' % shortopt, |
|
45 | out_opts.append(('%2s%s' % (shortopt and '-%s' % shortopt, | |
38 | longopt and ' --%s' % longopt), |
|
46 | longopt and ' --%s' % longopt), | |
39 | '%s' % desc)) |
|
47 | '%s' % desc)) | |
40 | opts_len = max([len(opt[0]) for opt in out_opts]) |
|
48 | opts_len = max([len(opt[0]) for opt in out_opts]) | |
41 | for first, second in out_opts: |
|
49 | for first, second in out_opts: | |
42 | sys.stdout.write(' %-*s %s\n' % (opts_len, first, second)) |
|
50 | sys.stdout.write(' %-*s %s\n' % (opts_len, first, second)) | |
43 |
|
51 | |||
44 | try: |
|
52 | try: | |
45 | for fp in (sys.stdin, sys.stdout, sys.stderr): |
|
53 | for fp in (sys.stdin, sys.stdout, sys.stderr): | |
46 | util.setbinary(fp) |
|
54 | util.setbinary(fp) | |
47 |
|
55 | |||
48 | opts = {} |
|
56 | opts = {} | |
49 | try: |
|
57 | try: | |
50 | args = fancyopts.fancyopts(sys.argv[1:], options, opts) |
|
58 | args = fancyopts.fancyopts(sys.argv[1:], options, opts) | |
51 | except getopt.GetoptError as e: |
|
59 | except getopt.GetoptError as e: | |
52 | raise ParseError(e) |
|
60 | raise ParseError(e) | |
53 | if opts['help']: |
|
61 | if opts['help']: | |
54 | showhelp() |
|
62 | showhelp() | |
55 | sys.exit(0) |
|
63 | sys.exit(0) | |
56 | if len(args) != 3: |
|
64 | if len(args) != 3: | |
57 | raise ParseError(_('wrong number of arguments')) |
|
65 | raise ParseError(_('wrong number of arguments')) | |
58 | sys.exit(simplemerge.simplemerge(ui.ui.load(), *args, **opts)) |
|
66 | sys.exit(simplemerge.simplemerge(uimod.ui.load(), *args, **opts)) | |
59 | except ParseError as e: |
|
67 | except ParseError as e: | |
60 | sys.stdout.write("%s: %s\n" % (sys.argv[0], e)) |
|
68 | sys.stdout.write("%s: %s\n" % (sys.argv[0], e)) | |
61 | showhelp() |
|
69 | showhelp() | |
62 | sys.exit(1) |
|
70 | sys.exit(1) | |
63 | except error.Abort as e: |
|
71 | except error.Abort as e: | |
64 | sys.stderr.write("abort: %s\n" % e) |
|
72 | sys.stderr.write("abort: %s\n" % e) | |
65 | sys.exit(255) |
|
73 | sys.exit(255) | |
66 | except KeyboardInterrupt: |
|
74 | except KeyboardInterrupt: | |
67 | sys.exit(255) |
|
75 | sys.exit(255) |
General Comments 0
You need to be logged in to leave comments.
Login now