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