author | Pierre-Yves David <pierre-yves.david@octobus.net> |
Mon, 29 May 2023 04:24:29 +0200 | |
changeset 50632 | 786443bd3bc1 |
parent 48875 | 6000f5b25c9b |
permissions | -rw-r--r-- |
45830
c102b704edb5
global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
45055
diff
changeset
|
1 |
#!/usr/bin/env python3 |
4362
465b9ea02868
Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
2 |
|
30576
541949a10a68
fancyopts: switch from fancyopts.getopt.* to getopt.*
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30559
diff
changeset
|
3 |
import getopt |
19378
9de689d20230
cleanup: drop unused variables and an unused import
Simon Heimberg <simohe@besonet.ch>
parents:
19022
diff
changeset
|
4 |
import sys |
33895
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
5 |
|
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
6 |
import hgdemandimport |
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
7 |
|
33895
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
8 |
hgdemandimport.enable() |
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
9 |
|
4363
2e3c54fb79a3
actually port simplemerge to hg
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4362
diff
changeset
|
10 |
from mercurial.i18n import _ |
33895
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
11 |
from mercurial import ( |
34051
d2fc88426d21
context: add arbitraryfilectx, which can represent files outside the workdir
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
12 |
context, |
33895
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
13 |
error, |
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
14 |
fancyopts, |
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
15 |
simplemerge, |
aed91971d88c
simplemerge: update to conform with modern import conventions
Augie Fackler <raf@durin42.com>
parents:
30576
diff
changeset
|
16 |
ui as uimod, |
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
17 |
util, |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34051
diff
changeset
|
18 |
) |
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
19 |
from mercurial.utils import procutil, stringutil |
4362
465b9ea02868
Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
20 |
|
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
21 |
options = [ |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
22 |
(b'L', b'label', [], _(b'labels to use on conflict markers')), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
23 |
(b'a', b'text', None, _(b'treat all files as text')), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
24 |
(b'p', b'print', None, _(b'print results instead of overwriting LOCAL')), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
25 |
(b'', b'no-minimal', None, _(b'no effect (DEPRECATED)')), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
26 |
(b'h', b'help', None, _(b'display help and exit')), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
27 |
(b'q', b'quiet', None, _(b'suppress output')), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
28 |
] |
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
29 |
|
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
30 |
usage = _( |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
31 |
b'''simplemerge [OPTS] LOCAL BASE OTHER |
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
32 |
|
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
33 |
Simple three-way file merge utility with a minimal feature set. |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4408
diff
changeset
|
34 |
|
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
35 |
Apply to LOCAL the changes necessary to go from BASE to OTHER. |
5081
ea7b982b6c08
Remove trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4408
diff
changeset
|
36 |
|
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
37 |
By default, LOCAL is overwritten with the results of this operation. |
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
38 |
''' |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
39 |
) |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
40 |
|
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
41 |
|
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
42 |
class ParseError(Exception): |
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
43 |
"""Exception raised on errors in parsing the command line.""" |
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
44 |
|
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
45 |
|
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
46 |
def showhelp(): |
45055
4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents:
43659
diff
changeset
|
47 |
procutil.stdout.write(usage) |
4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents:
43659
diff
changeset
|
48 |
procutil.stdout.write(b'\noptions:\n') |
4362
465b9ea02868
Import 3-way merge code from bzr
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
49 |
|
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
50 |
out_opts = [] |
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
51 |
for shortopt, longopt, default, desc in options: |
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
52 |
out_opts.append( |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
53 |
( |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
54 |
b'%2s%s' |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
55 |
% ( |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
56 |
shortopt and b'-%s' % shortopt, |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
57 |
longopt and b' --%s' % longopt, |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
58 |
), |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
59 |
b'%s' % desc, |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
60 |
) |
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
61 |
) |
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
62 |
opts_len = max([len(opt[0]) for opt in out_opts]) |
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
63 |
for first, second in out_opts: |
45055
4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents:
43659
diff
changeset
|
64 |
procutil.stdout.write(b' %-*s %s\n' % (opts_len, first, second)) |
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
65 |
|
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
66 |
|
48752
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
67 |
def _verifytext(input, ui, quiet=False, allow_binary=False): |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
68 |
"""verifies that text is non-binary (unless opts[text] is passed, |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
69 |
then we just warn)""" |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
70 |
if stringutil.binary(input.text()): |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
71 |
msg = _(b"%s looks like a binary file.") % input.fctx.path() |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
72 |
if not quiet: |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
73 |
ui.warn(_(b'warning: %s\n') % msg) |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
74 |
if not allow_binary: |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
75 |
sys.exit(1) |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
76 |
|
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
77 |
|
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
78 |
try: |
45055
4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents:
43659
diff
changeset
|
79 |
for fp in (sys.stdin, procutil.stdout, sys.stderr): |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
34051
diff
changeset
|
80 |
procutil.setbinary(fp) |
19022
cba222f01056
tests: run check-code on Python files without .py extension
Mads Kiilerich <madski@unity3d.com>
parents:
14233
diff
changeset
|
81 |
|
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
82 |
opts = {} |
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
83 |
try: |
40260
b54d93fc3ba8
simplemerge: port to Python 3
Augie Fackler <augie@google.com>
parents:
39791
diff
changeset
|
84 |
bargv = [a.encode('utf8') for a in sys.argv[1:]] |
b54d93fc3ba8
simplemerge: port to Python 3
Augie Fackler <augie@google.com>
parents:
39791
diff
changeset
|
85 |
args = fancyopts.fancyopts(bargv, options, opts) |
30576
541949a10a68
fancyopts: switch from fancyopts.getopt.* to getopt.*
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30559
diff
changeset
|
86 |
except getopt.GetoptError as e: |
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
87 |
raise ParseError(e) |
39790
d3e940a32be0
py3: add b'' prefixes in contrib/simplemerge
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
37120
diff
changeset
|
88 |
if opts[b'help']: |
4364
d5c3a70f8422
polish the simplemerge command; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4363
diff
changeset
|
89 |
showhelp() |
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
90 |
sys.exit(0) |
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
91 |
if len(args) != 3: |
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
92 |
raise ParseError(_(b'wrong number of arguments').decode('utf8')) |
48749
9ee70e175fed
simplemerge: replace `**opts` passed to `simplemerge()` by keyword arguments
Martin von Zweigbergk <martinvonz@google.com>
parents:
48578
diff
changeset
|
93 |
mode = b'merge' |
48555
c91418480cb0
simplemerge: use 3-way markers if mode=='merge3', ignoring number of labels
Martin von Zweigbergk <martinvonz@google.com>
parents:
45830
diff
changeset
|
94 |
if len(opts[b'label']) > 2: |
48749
9ee70e175fed
simplemerge: replace `**opts` passed to `simplemerge()` by keyword arguments
Martin von Zweigbergk <martinvonz@google.com>
parents:
48578
diff
changeset
|
95 |
mode = b'merge3' |
33903
ed6f64173121
contrib: make simplemerge script pass context-like objects
Phil Cohen <phillco@fb.com>
parents:
33895
diff
changeset
|
96 |
local, base, other = args |
48560
6ad70879d2bd
simplemerge: move default labels to simplemerge extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48555
diff
changeset
|
97 |
overrides = opts[b'label'] |
48578
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
98 |
if len(overrides) > 3: |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
99 |
raise error.InputError(b'can only specify three labels.') |
48560
6ad70879d2bd
simplemerge: move default labels to simplemerge extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48555
diff
changeset
|
100 |
labels = [local, other, base] |
6ad70879d2bd
simplemerge: move default labels to simplemerge extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48555
diff
changeset
|
101 |
labels[: len(overrides)] = overrides |
48578
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
102 |
local_input = simplemerge.MergeInput( |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
103 |
context.arbitraryfilectx(local), labels[0] |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
104 |
) |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
105 |
other_input = simplemerge.MergeInput( |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
106 |
context.arbitraryfilectx(other), labels[1] |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
107 |
) |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
108 |
base_input = simplemerge.MergeInput( |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
109 |
context.arbitraryfilectx(base), labels[2] |
77e24ee8994b
simplemerge: take arguments as annotated context objects
Martin von Zweigbergk <martinvonz@google.com>
parents:
48560
diff
changeset
|
110 |
) |
48752
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
111 |
|
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
112 |
quiet = opts.get(b'quiet') |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
113 |
allow_binary = opts.get(b'text') |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
114 |
ui = uimod.ui.load() |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
115 |
_verifytext(local_input, ui, quiet=quiet, allow_binary=allow_binary) |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
116 |
_verifytext(base_input, ui, quiet=quiet, allow_binary=allow_binary) |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
117 |
_verifytext(other_input, ui, quiet=quiet, allow_binary=allow_binary) |
109fec7bf7de
simplemerge: let extension check for binary inputs (unless `--text`)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48749
diff
changeset
|
118 |
|
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
119 |
merged_text, conflicts = simplemerge.simplemerge( |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
120 |
local_input, |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
121 |
base_input, |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
122 |
other_input, |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
123 |
mode, |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
124 |
allow_binary=allow_binary, |
43659
99e231afc29c
black: blacken scripts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43367
diff
changeset
|
125 |
) |
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
126 |
if opts.get(b'print'): |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
127 |
ui.fout.write(merged_text) |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
128 |
else: |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
129 |
util.writefile(local, merged_text) |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48752
diff
changeset
|
130 |
sys.exit(1 if conflicts else 0) |
28047
863075fd4cd0
misc: use modern exception syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26587
diff
changeset
|
131 |
except ParseError as e: |
43367
3c2799cbace4
py3: fix exception display encoding in contrib/simplemerge.py
Emmanuel Leblond <emmanuel.leblond@gmail.com>
parents:
40265
diff
changeset
|
132 |
e = stringutil.forcebytestr(e) |
45055
4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents:
43659
diff
changeset
|
133 |
procutil.stdout.write(b"%s: %s\n" % (sys.argv[0].encode('utf8'), e)) |
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
134 |
showhelp() |
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
135 |
sys.exit(1) |
28047
863075fd4cd0
misc: use modern exception syntax
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
26587
diff
changeset
|
136 |
except error.Abort as e: |
45055
4c1b4805db57
pycompat: change users of pycompat.{stdin,stdout,stderr} to use procutil.std*
Manuel Jacob <me@manueljacob.de>
parents:
43659
diff
changeset
|
137 |
procutil.stderr.write(b"abort: %s\n" % e) |
6002
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
138 |
sys.exit(255) |
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
139 |
except KeyboardInterrupt: |
abd66eb0889e
merge: move the bulk of simplemerge into core
Matt Mackall <mpm@selenic.com>
parents:
5081
diff
changeset
|
140 |
sys.exit(255) |