Mercurial > hg
annotate mercurial/filemerge.py @ 50076:63c4e9639753
dirstate: generalize the dirstate's invalidation on transaction abort
The previous code was too specific, we should add the invalidation at next to
the `addfilegenerator` in the `write` call.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 16 Feb 2023 02:34:54 +0100 |
parents | 2282d8ac0fa9 |
children | c642c03969ff |
rev | line source |
---|---|
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # filemerge.py - file-level merge handling for Mercurial |
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46496
diff
changeset
|
3 # Copyright 2006, 2007, 2008 Olivia Mackall <olivia@selenic.com> |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8209
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
8 |
36998
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36988
diff
changeset
|
9 import contextlib |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
10 import os |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
11 import re |
36999
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
36998
diff
changeset
|
12 import shutil |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
13 |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
14 from .i18n import _ |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
15 from .node import ( |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
16 hex, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
17 short, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
18 ) |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
19 from .pycompat import ( |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
20 getattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43085
diff
changeset
|
21 ) |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
22 |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
23 from . import ( |
30636
f1c9fafcbf46
py3: replace os.environ with encoding.environ (part 3 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30538
diff
changeset
|
24 encoding, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
25 error, |
28955
78759f78a44e
templater: factor out function that creates templater from string template
Yuya Nishihara <yuya@tcha.org>
parents:
28954
diff
changeset
|
26 formatter, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
27 match, |
30073
aa23c93e636d
py3: make format strings unicodes and not bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29775
diff
changeset
|
28 pycompat, |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
29 registrar, |
27651
07fc2f2134ba
origpath: move from cmdutil to scmutil
Siddharth Agarwal <sid0@fb.com>
parents:
27599
diff
changeset
|
30 scmutil, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
31 simplemerge, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
32 tagmerge, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
33 templatekw, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
34 templater, |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
35 templateutil, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
36 util, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
37 ) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
38 |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37077
diff
changeset
|
39 from .utils import ( |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
40 procutil, |
48753
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
41 stringutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37077
diff
changeset
|
42 ) |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37077
diff
changeset
|
43 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
44 |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
45 def _toolstr(ui, tool, part, *args): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
46 return ui.config(b"merge-tools", tool + b"." + part, *args) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
47 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
48 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
49 def _toolbool(ui, tool, part, *args): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
50 return ui.configbool(b"merge-tools", tool + b"." + part, *args) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
51 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
52 |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
53 def _toollist(ui, tool, part): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
54 return ui.configlist(b"merge-tools", tool + b"." + part) |
11148
a912f26777d3
merge: introduce tool.check parameter
David Champion <dgc@uchicago.edu>
parents:
11146
diff
changeset
|
55 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
56 |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
57 internals = {} |
24099
be83fd9d46d5
help.merge-tools: do not double document merge tools
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23270
diff
changeset
|
58 # Merge tools to document. |
be83fd9d46d5
help.merge-tools: do not double document merge tools
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23270
diff
changeset
|
59 internalsdoc = {} |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
60 |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
61 internaltool = registrar.internalmerge() |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
62 |
26525
abc2327e382a
filemerge: add some merge types
Siddharth Agarwal <sid0@fb.com>
parents:
26519
diff
changeset
|
63 # internal tool merge types |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
64 nomerge = internaltool.nomerge |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
65 mergeonly = internaltool.mergeonly # just the full merge, no premerge |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
66 fullmerge = internaltool.fullmerge # both premerge and merge |
26525
abc2327e382a
filemerge: add some merge types
Siddharth Agarwal <sid0@fb.com>
parents:
26519
diff
changeset
|
67 |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
68 # IMPORTANT: keep the last line of this prompt very short ("What do you want to |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
69 # do?") because of issue6158, ideally to <40 English characters (to allow other |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
70 # languages that may take more columns to still have a chance to fit in an |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
71 # 80-column screen). |
32317
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32255
diff
changeset
|
72 _localchangedotherdeletedmsg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
73 b"file '%(fd)s' was deleted in other%(o)s but was modified in local%(l)s.\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
74 b"You can use (c)hanged version, (d)elete, or leave (u)nresolved.\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
75 b"What do you want to do?" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
76 b"$$ &Changed $$ &Delete $$ &Unresolved" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
77 ) |
32317
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32255
diff
changeset
|
78 |
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32255
diff
changeset
|
79 _otherchangedlocaldeletedmsg = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
80 b"file '%(fd)s' was deleted in local%(l)s but was modified in other%(o)s.\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
81 b"You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
82 b"What do you want to do?" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
83 b"$$ &Changed $$ &Deleted $$ &Unresolved" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
84 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
85 |
32317
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32255
diff
changeset
|
86 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48913
diff
changeset
|
87 class absentfilectx: |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
88 """Represents a file that's ostensibly in a context but is actually not |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
89 present in it. |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
90 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
91 This is here because it's very specific to the filemerge code for now -- |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
92 other code is likely going to break with the values this returns.""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
93 |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
94 def __init__(self, ctx, f): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
95 self._ctx = ctx |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
96 self._f = f |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
97 |
44872
aa790f7c967a
filemerge: add __bytes__ for absentfilectx
Augie Fackler <augie@google.com>
parents:
43846
diff
changeset
|
98 def __bytes__(self): |
aa790f7c967a
filemerge: add __bytes__ for absentfilectx
Augie Fackler <augie@google.com>
parents:
43846
diff
changeset
|
99 return b'absent file %s@%s' % (self._f, self._ctx) |
aa790f7c967a
filemerge: add __bytes__ for absentfilectx
Augie Fackler <augie@google.com>
parents:
43846
diff
changeset
|
100 |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
101 def path(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
102 return self._f |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
103 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
104 def size(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
105 return None |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
106 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
107 def data(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
108 return None |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
109 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
110 def filenode(self): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46819
diff
changeset
|
111 return self._ctx.repo().nullid |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
112 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
113 _customcmp = True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
114 |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
115 def cmp(self, fctx): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
116 """compare with other file context |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
117 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
118 returns True if different from fctx. |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
119 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
120 return not ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
121 fctx.isabsent() |
43846
d5ce99a6db52
filemerge: fix a missing attribute usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
43845
diff
changeset
|
122 and fctx.changectx() == self.changectx() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
123 and fctx.path() == self.path() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
124 ) |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
125 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
126 def flags(self): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
127 return b'' |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
128 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
129 def changectx(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
130 return self._ctx |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
131 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
132 def isbinary(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
133 return False |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
134 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
135 def isabsent(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
136 return True |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
137 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
138 |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
139 def _findtool(ui, tool): |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
140 if tool in internals: |
6522
2b181fb3a70a
use internal merge tool when specified for a merge-pattern in hgrc
Dov Feldstern <dfeldstern@fastimap.com>
parents:
6212
diff
changeset
|
141 return tool |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
142 cmd = _toolstr(ui, tool, b"executable", tool) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
143 if cmd.startswith(b'python:'): |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
144 return cmd |
23148
b405dd6c90bf
filemerge: split the logic for finding an external tool to its own function
Matt Harbison <matt_harbison@yahoo.com>
parents:
22707
diff
changeset
|
145 return findexternaltool(ui, tool) |
b405dd6c90bf
filemerge: split the logic for finding an external tool to its own function
Matt Harbison <matt_harbison@yahoo.com>
parents:
22707
diff
changeset
|
146 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
147 |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
148 def _quotetoolpath(cmd): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
149 if cmd.startswith(b'python:'): |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
150 return cmd |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
151 return procutil.shellquote(cmd) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
152 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
153 |
23148
b405dd6c90bf
filemerge: split the logic for finding an external tool to its own function
Matt Harbison <matt_harbison@yahoo.com>
parents:
22707
diff
changeset
|
154 def findexternaltool(ui, tool): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
155 for kn in (b"regkey", b"regkeyalt"): |
13565
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
156 k = _toolstr(ui, tool, kn) |
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
157 if not k: |
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
158 continue |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
159 p = util.lookupreg(k, _toolstr(ui, tool, b"regname")) |
6006
3c9dbb743d20
merge: add registry look up bits to tool search
Matt Mackall <mpm@selenic.com>
parents:
6005
diff
changeset
|
160 if p: |
49644
5744ceeb9067
configitems: add a default value for "merge-tools.xxx.regappend"
Matt Harbison <matt_harbison@yahoo.com>
parents:
49167
diff
changeset
|
161 p = procutil.findexe(p + _toolstr(ui, tool, b"regappend")) |
6006
3c9dbb743d20
merge: add registry look up bits to tool search
Matt Mackall <mpm@selenic.com>
parents:
6005
diff
changeset
|
162 if p: |
3c9dbb743d20
merge: add registry look up bits to tool search
Matt Mackall <mpm@selenic.com>
parents:
6005
diff
changeset
|
163 return p |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
164 exe = _toolstr(ui, tool, b"executable", tool) |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
165 return procutil.findexe(util.expandpath(exe)) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
166 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
167 |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
168 def _picktool(repo, ui, path, binary, symlink, changedelete): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
169 strictcheck = ui.configbool(b'merge', b'strict-capability-check') |
39125
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39124
diff
changeset
|
170 |
39123
4d7b11877dd0
filemerge: add the function to examine a capability of a internal tool
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39122
diff
changeset
|
171 def hascapability(tool, capability, strict=False): |
39266
82555d7186d0
filemerge: make capability check for internal tools ignore merge-tools section
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39126
diff
changeset
|
172 if tool in internals: |
82555d7186d0
filemerge: make capability check for internal tools ignore merge-tools section
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39126
diff
changeset
|
173 return strict and internals[tool].capabilities.get(capability) |
39123
4d7b11877dd0
filemerge: add the function to examine a capability of a internal tool
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39122
diff
changeset
|
174 return _toolbool(ui, tool, capability) |
4d7b11877dd0
filemerge: add the function to examine a capability of a internal tool
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39122
diff
changeset
|
175 |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
176 def supportscd(tool): |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
177 return tool in internals and internals[tool].mergetype == nomerge |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
178 |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
179 def check(tool, pat, symlink, binary, changedelete): |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
180 tmsg = tool |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
181 if pat: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
182 tmsg = _(b"%s (for pattern %s)") % (tool, pat) |
7397
4c92d8971809
More verbose logging when filemerge searches for merge-tool
Mads Kiilerich <mads@kiilerich.com>
parents:
6762
diff
changeset
|
183 if not _findtool(ui, tool): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
184 if pat: # explicitly requested tool deserves a warning |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
185 ui.warn(_(b"couldn't find merge tool %s\n") % tmsg) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
186 else: # configured but non-existing tools are more silent |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
187 ui.note(_(b"couldn't find merge tool %s\n") % tmsg) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
188 elif symlink and not hascapability(tool, b"symlink", strictcheck): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
189 ui.warn(_(b"tool %s can't handle symlinks\n") % tmsg) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
190 elif binary and not hascapability(tool, b"binary", strictcheck): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
191 ui.warn(_(b"tool %s can't handle binary\n") % tmsg) |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
192 elif changedelete and not supportscd(tool): |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
193 # the nomerge tools are the only tools that support change/delete |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
194 # conflicts |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
195 pass |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
196 elif not procutil.gui() and _toolbool(ui, tool, b"gui"): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
197 ui.warn(_(b"tool %s requires a GUI\n") % tmsg) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
198 else: |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
199 return True |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
200 return False |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
201 |
25835
34ffe4c29782
filemerge: mark internal-only config option
Matt Mackall <mpm@selenic.com>
parents:
24987
diff
changeset
|
202 # internal config: ui.forcemerge |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
203 # forcemerge comes from command line arguments, highest priority |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
204 force = ui.config(b'ui', b'forcemerge') |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
205 if force: |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
206 toolpath = _findtool(ui, force) |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
207 if changedelete and not supportscd(toolpath): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
208 return b":prompt", None |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
209 else: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
210 if toolpath: |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
211 return (force, _quotetoolpath(toolpath)) |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
212 else: |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
213 # mimic HGMERGE if given tool not found |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
214 return (force, force) |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
215 |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
216 # HGMERGE takes next precedence |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
217 hgmerge = encoding.environ.get(b"HGMERGE") |
6025
f2335246e5c7
filemerge: wrap quotes around tool path
Steve Borho <steve@borho.org>
parents:
6016
diff
changeset
|
218 if hgmerge: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
219 if changedelete and not supportscd(hgmerge): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 return b":prompt", None |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
221 else: |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
222 return (hgmerge, hgmerge) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
223 |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
224 # then patterns |
39125
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39124
diff
changeset
|
225 |
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39124
diff
changeset
|
226 # whether binary capability should be checked strictly |
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39124
diff
changeset
|
227 binarycap = binary and strictcheck |
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39124
diff
changeset
|
228 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
229 for pat, tool in ui.configitems(b"merge-patterns"): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
230 mf = match.match(repo.root, b'', [pat]) |
39125
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39124
diff
changeset
|
231 if mf(path) and check(tool, pat, symlink, binarycap, changedelete): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
232 if binary and not hascapability(tool, b"binary", strict=True): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
233 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
234 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
235 b"warning: check merge-patterns configurations," |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
236 b" if %r for binary file %r is unintentional\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
237 b"(see 'hg help merge-tools'" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
238 b" for binary files capability)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
239 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
240 % (pycompat.bytestr(tool), pycompat.bytestr(path)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
241 ) |
10339
23e608f42f2c
fix spaces/identation issues
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
242 toolpath = _findtool(ui, tool) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
243 return (tool, _quotetoolpath(toolpath)) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
244 |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
245 # then merge tools |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
246 tools = {} |
26730
a1e43e85d294
merge-tools: allow marking a mergetool as completely disabled
Augie Fackler <augie@google.com>
parents:
26614
diff
changeset
|
247 disabled = set() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 for k, v in ui.configitems(b"merge-tools"): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
249 t = k.split(b'.')[0] |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
250 if t not in tools: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
251 tools[t] = int(_toolstr(ui, t, b"priority")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 if _toolbool(ui, t, b"disabled"): |
26730
a1e43e85d294
merge-tools: allow marking a mergetool as completely disabled
Augie Fackler <augie@google.com>
parents:
26614
diff
changeset
|
253 disabled.add(t) |
6076
0ee885fea464
filemerge: more backwards compatible behavior for ui.merge
Steve Borho <steve@borho.org>
parents:
6075
diff
changeset
|
254 names = tools.keys() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
255 tools = sorted( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
256 [(-p, tool) for tool, p in tools.items() if tool not in disabled] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
257 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
258 uimerge = ui.config(b"ui", b"merge") |
6076
0ee885fea464
filemerge: more backwards compatible behavior for ui.merge
Steve Borho <steve@borho.org>
parents:
6075
diff
changeset
|
259 if uimerge: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
260 # external tools defined in uimerge won't be able to handle |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
261 # change/delete conflicts |
38952
0e58c5b20745
mergetool: warn if ui.merge points to nonexistent tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
38793
diff
changeset
|
262 if check(uimerge, path, symlink, binary, changedelete): |
0e58c5b20745
mergetool: warn if ui.merge points to nonexistent tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
38793
diff
changeset
|
263 if uimerge not in names and not changedelete: |
0e58c5b20745
mergetool: warn if ui.merge points to nonexistent tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
38793
diff
changeset
|
264 return (uimerge, uimerge) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
265 tools.insert(0, (None, uimerge)) # highest priority |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
266 tools.append((None, b"hgmerge")) # the old default, if found |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
267 for p, t in tools: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
268 if check(t, None, symlink, binary, changedelete): |
7397
4c92d8971809
More verbose logging when filemerge searches for merge-tool
Mads Kiilerich <mads@kiilerich.com>
parents:
6762
diff
changeset
|
269 toolpath = _findtool(ui, t) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
270 return (t, _quotetoolpath(toolpath)) |
16254
c7eef052c9e3
filemerge: restore default prompt for binary/symlink lost in 83925d3a4559
Matt Mackall <mpm@selenic.com>
parents:
16205
diff
changeset
|
271 |
c7eef052c9e3
filemerge: restore default prompt for binary/symlink lost in 83925d3a4559
Matt Mackall <mpm@selenic.com>
parents:
16205
diff
changeset
|
272 # internal merge or prompt as last resort |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
273 if symlink or binary or changedelete: |
32253
7d4ce4b567c5
filemerge: show warning about choice of :prompt only at an actual fallback
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32047
diff
changeset
|
274 if not changedelete and len(tools): |
7d4ce4b567c5
filemerge: show warning about choice of :prompt only at an actual fallback
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32047
diff
changeset
|
275 # any tool is rejected by capability for symlink or binary |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
276 ui.warn(_(b"no tool found to merge %s\n") % path) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
277 return b":prompt", None |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
278 return b":merge", None |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
279 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
280 |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
281 def _eoltype(data): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43503
diff
changeset
|
282 """Guess the EOL type of a file""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
283 if b'\0' in data: # binary |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
284 return None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
285 if b'\r\n' in data: # Windows |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
286 return b'\r\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
287 if b'\r' in data: # Old Mac |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
288 return b'\r' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
289 if b'\n' in data: # UNIX |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
290 return b'\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
291 return None # unknown |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
292 |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
293 |
48503
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
294 def _matcheol(file, backup): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43503
diff
changeset
|
295 """Convert EOL markers in a file to match origfile""" |
48503
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
296 tostyle = _eoltype(backup.data()) # No repo.wread filters? |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
297 if tostyle: |
14168
135e244776f0
prevent transient leaks of file handle by using new helper functions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13565
diff
changeset
|
298 data = util.readfile(file) |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
299 style = _eoltype(data) |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
300 if style: |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
301 newdata = data.replace(style, tostyle) |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
302 if newdata != data: |
14168
135e244776f0
prevent transient leaks of file handle by using new helper functions
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
13565
diff
changeset
|
303 util.writefile(file, newdata) |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
304 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
305 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
306 @internaltool(b'prompt', nomerge) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
307 def _iprompt(repo, mynode, local, other, base, toolconf): |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
308 """Asks the user which of the local `p1()` or the other `p2()` version to |
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
309 keep as the merged version.""" |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
310 ui = repo.ui |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
311 fd = local.fctx.path() |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
312 uipathfn = scmutil.getuipathfn(repo) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
313 |
35282
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35281
diff
changeset
|
314 # Avoid prompting during an in-memory merge since it doesn't support merge |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35281
diff
changeset
|
315 # conflicts. |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
316 if local.fctx.changectx().isinmemory(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
317 raise error.InMemoryMergeConflictsError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
318 b'in-memory merge does not support file conflicts' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
319 ) |
35282
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35281
diff
changeset
|
320 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
321 prompts = partextras([local.label, other.label]) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
322 prompts[b'fd'] = uipathfn(fd) |
26898
33eb8a56d0c9
filemerge: treat EOF at prompt as fail, not abort
Siddharth Agarwal <sid0@fb.com>
parents:
26893
diff
changeset
|
323 try: |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
324 if other.fctx.isabsent(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
325 index = ui.promptchoice(_localchangedotherdeletedmsg % prompts, 2) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
326 choice = [b'local', b'other', b'unresolved'][index] |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
327 elif local.fctx.isabsent(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
328 index = ui.promptchoice(_otherchangedlocaldeletedmsg % prompts, 2) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
329 choice = [b'other', b'local', b'unresolved'][index] |
27038
58a4eb16e722
filemerge: add support for change/delete conflicts to the ':prompt' tool
Siddharth Agarwal <sid0@fb.com>
parents:
27037
diff
changeset
|
330 else: |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
331 # IMPORTANT: keep the last line of this prompt ("What do you want to |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
332 # do?") very short, see comment next to _localchangedotherdeletedmsg |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41600
diff
changeset
|
333 # at the top of the file for details. |
27162
4ab69be0ea15
filemerge: add a 'leave unresolved' option to regular prompts
Siddharth Agarwal <sid0@fb.com>
parents:
27161
diff
changeset
|
334 index = ui.promptchoice( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
335 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
336 b"file '%(fd)s' needs to be resolved.\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
337 b"You can keep (l)ocal%(l)s, take (o)ther%(o)s, or leave " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
338 b"(u)nresolved.\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
339 b"What do you want to do?" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
340 b"$$ &Local $$ &Other $$ &Unresolved" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
341 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
342 % prompts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
343 2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
344 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
345 choice = [b'local', b'other', b'unresolved'][index] |
26851
859f453e8b4e
filemerge.prompt: separate out choice selection and action
Siddharth Agarwal <sid0@fb.com>
parents:
26730
diff
changeset
|
346 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
347 if choice == b'other': |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
348 return _iother(repo, mynode, local, other, base, toolconf) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
349 elif choice == b'local': |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
350 return _ilocal(repo, mynode, local, other, base, toolconf) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
351 elif choice == b'unresolved': |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
352 return _ifail(repo, mynode, local, other, base, toolconf) |
26898
33eb8a56d0c9
filemerge: treat EOF at prompt as fail, not abort
Siddharth Agarwal <sid0@fb.com>
parents:
26893
diff
changeset
|
353 except error.ResponseExpected: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
354 ui.write(b"\n") |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
355 return _ifail(repo, mynode, local, other, base, toolconf) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
356 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
357 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
358 @internaltool(b'local', nomerge) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
359 def _ilocal(repo, mynode, local, other, base, toolconf): |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
360 """Uses the local `p1()` version of files as the merged version.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
361 return 0, local.fctx.isabsent() |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
362 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
363 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
364 @internaltool(b'other', nomerge) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
365 def _iother(repo, mynode, local, other, base, toolconf): |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
366 """Uses the other `p2()` version of files as the merged version.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
367 if other.fctx.isabsent(): |
27037
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
368 # local changed, remote deleted -- 'deleted' picked |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
369 _underlyingfctxifabsent(local.fctx).remove() |
27037
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
370 deleted = True |
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
371 else: |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
372 _underlyingfctxifabsent(local.fctx).write( |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
373 other.fctx.data(), other.fctx.flags() |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
374 ) |
27037
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
375 deleted = False |
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
376 return 0, deleted |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
377 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
378 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
379 @internaltool(b'fail', nomerge) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
380 def _ifail(repo, mynode, local, other, base, toolconf): |
16127
14dc2bbba6d2
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall <mpm@selenic.com>
parents:
16126
diff
changeset
|
381 """ |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
382 Rather than attempting to merge files that were modified on both |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
383 branches, it marks them as unresolved. The resolve command must be |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
384 used to resolve these conflicts.""" |
27123
4dc5951df1e4
filemerge: in ':fail' tool, write out other side if local side is deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27047
diff
changeset
|
385 # for change/delete conflicts write out the changed version, then fail |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
386 if local.fctx.isabsent(): |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
387 _underlyingfctxifabsent(local.fctx).write( |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
388 other.fctx.data(), other.fctx.flags() |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
389 ) |
27032
28ee7af4b685
filemerge: return whether the file is deleted for nomerge internal tools
Siddharth Agarwal <sid0@fb.com>
parents:
26979
diff
changeset
|
390 return 1, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
391 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
392 |
33151
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
393 def _underlyingfctxifabsent(filectx): |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
394 """Sometimes when resolving, our fcd is actually an absentfilectx, but |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
395 we want to write to it (to do the resolve). This helper returns the |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
396 underyling workingfilectx in that case. |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
397 """ |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
398 if filectx.isabsent(): |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
399 return filectx.changectx()[filectx.path()] |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
400 else: |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
401 return filectx |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32873
diff
changeset
|
402 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
403 |
48753
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
404 def _verifytext(input, ui): |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
405 """verifies that text is non-binary""" |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
406 if stringutil.binary(input.text()): |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
407 msg = _(b"%s looks like a binary file.") % input.fctx.path() |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
408 ui.warn(_(b'warning: %s\n') % msg) |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
409 raise error.Abort(msg) |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
410 |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
411 |
48756
86e4b86df932
filemerge: when not keeping premerge, don't write markers to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48755
diff
changeset
|
412 def _premerge(repo, local, other, base, toolconf): |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
413 tool, toolpath, binary, symlink, scriptfn = toolconf |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
414 if symlink or local.fctx.isabsent() or other.fctx.isabsent(): |
18257
a35d0128545e
merge: never do premerge on symlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
18256
diff
changeset
|
415 return 1 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
416 |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
417 ui = repo.ui |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
418 |
46139
3ca5ca380a34
filemerge: add support for the new "mergediff" marker style to premerge
Martin von Zweigbergk <martinvonz@google.com>
parents:
46108
diff
changeset
|
419 validkeep = [b'keep', b'keep-merge3', b'keep-mergediff'] |
22031
b36c60cfe46f
merge-tools: make premerge valid values extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22028
diff
changeset
|
420 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
421 # do we attempt to simplemerge first? |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
422 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
423 premerge = _toolbool(ui, tool, b"premerge", not binary) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
424 except error.ConfigError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
425 premerge = _toolstr(ui, tool, b"premerge", b"").lower() |
22031
b36c60cfe46f
merge-tools: make premerge valid values extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22028
diff
changeset
|
426 if premerge not in validkeep: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
427 _valid = b', '.join([b"'" + v + b"'" for v in validkeep]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
428 raise error.ConfigError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
429 _(b"%s.premerge not valid ('%s' is neither boolean nor %s)") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
430 % (tool, premerge, _valid) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
431 ) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
432 |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
433 if premerge: |
46139
3ca5ca380a34
filemerge: add support for the new "mergediff" marker style to premerge
Martin von Zweigbergk <martinvonz@google.com>
parents:
46108
diff
changeset
|
434 mode = b'merge' |
48555
c91418480cb0
simplemerge: use 3-way markers if mode=='merge3', ignoring number of labels
Martin von Zweigbergk <martinvonz@google.com>
parents:
48509
diff
changeset
|
435 if premerge == b'keep-mergediff': |
c91418480cb0
simplemerge: use 3-way markers if mode=='merge3', ignoring number of labels
Martin von Zweigbergk <martinvonz@google.com>
parents:
48509
diff
changeset
|
436 mode = b'mergediff' |
c91418480cb0
simplemerge: use 3-way markers if mode=='merge3', ignoring number of labels
Martin von Zweigbergk <martinvonz@google.com>
parents:
48509
diff
changeset
|
437 elif premerge == b'keep-merge3': |
c91418480cb0
simplemerge: use 3-way markers if mode=='merge3', ignoring number of labels
Martin von Zweigbergk <martinvonz@google.com>
parents:
48509
diff
changeset
|
438 mode = b'merge3' |
48753
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
439 if any( |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
440 stringutil.binary(input.text()) for input in (local, base, other) |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
441 ): |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
442 return 1 # continue merging |
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
443 merged_text, conflicts = simplemerge.simplemerge( |
48758
7dad4665d223
simplemerge: remove now-unused arguments
Martin von Zweigbergk <martinvonz@google.com>
parents:
48756
diff
changeset
|
444 local, base, other, mode=mode |
46139
3ca5ca380a34
filemerge: add support for the new "mergediff" marker style to premerge
Martin von Zweigbergk <martinvonz@google.com>
parents:
46108
diff
changeset
|
445 ) |
48756
86e4b86df932
filemerge: when not keeping premerge, don't write markers to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48755
diff
changeset
|
446 if not conflicts or premerge in validkeep: |
86e4b86df932
filemerge: when not keeping premerge, don't write markers to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48755
diff
changeset
|
447 # fcd.flags() already has the merged flags (done in |
86e4b86df932
filemerge: when not keeping premerge, don't write markers to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48755
diff
changeset
|
448 # mergestate.resolve()) |
86e4b86df932
filemerge: when not keeping premerge, don't write markers to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48755
diff
changeset
|
449 local.fctx.write(merged_text, local.fctx.flags()) |
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
450 if not conflicts: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
451 ui.debug(b" premerge successful\n") |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
452 return 0 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
453 return 1 # continue merging |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
454 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
455 |
48505
40522aea2f27
filemerge: remove unused `orig` argument from tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48504
diff
changeset
|
456 def _mergecheck(repo, mynode, fcd, fco, fca, toolconf): |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
457 tool, toolpath, binary, symlink, scriptfn = toolconf |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
458 uipathfn = scmutil.getuipathfn(repo) |
26515
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
459 if symlink: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
460 repo.ui.warn( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
461 _(b'warning: internal %s cannot merge symlinks for %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
462 % (tool, uipathfn(fcd.path())) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
463 ) |
26515
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
464 return False |
27040
1bde66b89bb2
filemerge._mergecheck: add check for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27039
diff
changeset
|
465 if fcd.isabsent() or fco.isabsent(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
466 repo.ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
467 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
468 b'warning: internal %s cannot merge change/delete ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
469 b'conflict for %s\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
470 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
471 % (tool, uipathfn(fcd.path())) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
472 ) |
27040
1bde66b89bb2
filemerge._mergecheck: add check for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27039
diff
changeset
|
473 return False |
26515
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
474 return True |
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
475 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
476 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
477 def _merge(repo, local, other, base, mode): |
16127
14dc2bbba6d2
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall <mpm@selenic.com>
parents:
16126
diff
changeset
|
478 """ |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
479 Uses the internal non-interactive simple merge algorithm for merging |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
480 files. It will fail if there are any conflicts and leave markers in |
49956
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
481 the partially merged file. Markers will have two sections, one for each |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
482 side of merge, unless mode equals 'union' or 'union-other-first' which |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
483 suppresses the markers.""" |
26572
c7850af6bb75
filemerge._merge: drop no longer necessary 'if r:' check
Siddharth Agarwal <sid0@fb.com>
parents:
26567
diff
changeset
|
484 ui = repo.ui |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
485 |
48753
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
486 try: |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
487 _verifytext(local, ui) |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
488 _verifytext(base, ui) |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
489 _verifytext(other, ui) |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
490 except error.Abort: |
d9af7c1fb619
simplemerge: let filemerge check for binary inputs
Martin von Zweigbergk <martinvonz@google.com>
parents:
48587
diff
changeset
|
491 return True, True, False |
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
492 else: |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
493 merged_text, conflicts = simplemerge.simplemerge( |
48758
7dad4665d223
simplemerge: remove now-unused arguments
Martin von Zweigbergk <martinvonz@google.com>
parents:
48756
diff
changeset
|
494 local, base, other, mode=mode |
48755
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
495 ) |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
496 # fcd.flags() already has the merged flags (done in |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
497 # mergestate.resolve()) |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
498 local.fctx.write(merged_text, local.fctx.flags()) |
6ae3c97a0919
simplemerge: move printing of merge result to extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
48753
diff
changeset
|
499 return True, conflicts, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
500 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
501 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
502 @internaltool( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
503 b'union', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
504 fullmerge, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
505 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
506 b"warning: conflicts while merging %s! " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
507 b"(edit, then use 'hg resolve --mark')\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
508 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
509 precheck=_mergecheck, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
510 ) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
511 def _iunion(repo, mynode, local, other, base, toolconf, backup): |
26071
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
512 """ |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
513 Uses the internal non-interactive simple merge algorithm for merging |
49956
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
514 files. It will use both local and other sides for conflict regions by |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
515 adding local on top of other. |
26071
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
516 No markers are inserted.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
517 return _merge(repo, local, other, base, b'union') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
518 |
26071
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
519 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
520 @internaltool( |
49956
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
521 b'union-other-first', |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
522 fullmerge, |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
523 _( |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
524 b"warning: conflicts while merging %s! " |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
525 b"(edit, then use 'hg resolve --mark')\n" |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
526 ), |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
527 precheck=_mergecheck, |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
528 ) |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
529 def _iunion_other_first(repo, mynode, local, other, base, toolconf, backup): |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
530 """ |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
531 Like :union, but add other on top of local.""" |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
532 return _merge(repo, local, other, base, b'union-other-first') |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
533 |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
534 |
2282d8ac0fa9
filemerge: add union-other-first as internal merge tool
Cédric Krier <ced@b2ck.com>
parents:
49845
diff
changeset
|
535 @internaltool( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
536 b'merge', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
537 fullmerge, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
538 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
539 b"warning: conflicts while merging %s! " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
540 b"(edit, then use 'hg resolve --mark')\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
541 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
542 precheck=_mergecheck, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
543 ) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
544 def _imerge(repo, mynode, local, other, base, toolconf, backup): |
26070
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
545 """ |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
546 Uses the internal non-interactive simple merge algorithm for merging |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
547 files. It will fail if there are any conflicts and leave markers in |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
548 the partially merged file. Markers will have two sections, one for each side |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
549 of merge.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
550 return _merge(repo, local, other, base, b'merge') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
551 |
26070
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
552 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
553 @internaltool( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
554 b'merge3', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
555 fullmerge, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
556 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
557 b"warning: conflicts while merging %s! " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
558 b"(edit, then use 'hg resolve --mark')\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
559 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
560 precheck=_mergecheck, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
561 ) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
562 def _imerge3(repo, mynode, local, other, base, toolconf, backup): |
22028
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
563 """ |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
564 Uses the internal non-interactive simple merge algorithm for merging |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
565 files. It will fail if there are any conflicts and leave markers in |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
566 the partially merged file. Marker will have three sections, one from each |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
567 side of the merge and one for the base content.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
568 return _merge(repo, local, other, base, b'merge3') |
22028
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
569 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
570 |
46108
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
571 @internaltool( |
46365
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
572 b'merge3-lie-about-conflicts', |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
573 fullmerge, |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
574 b'', |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
575 precheck=_mergecheck, |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
576 ) |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
577 def _imerge3alwaysgood(*args, **kwargs): |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
578 # Like merge3, but record conflicts as resolved with markers in place. |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
579 # |
46496
d57e607d9e33
diff: replace --merge option by config option
Martin von Zweigbergk <martinvonz@google.com>
parents:
46365
diff
changeset
|
580 # This is used for `diff.merge` to show the differences between |
46365
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
581 # the auto-merge state and the committed merge state. It may be |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
582 # useful for other things. |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
583 b1, junk, b2 = _imerge3(*args, **kwargs) |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
584 # TODO is this right? I'm not sure what these return values mean, |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
585 # but as far as I can tell this will indicate to callers tha the |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
586 # merge succeeded. |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
587 return b1, False, b2 |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
588 |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
589 |
63dfaca9087f
filemerge: add a hacktastic version of internal:merge3 for merge diffs
Augie Fackler <augie@google.com>
parents:
46356
diff
changeset
|
590 @internaltool( |
46108
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
591 b'mergediff', |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
592 fullmerge, |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
593 _( |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
594 b"warning: conflicts while merging %s! " |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
595 b"(edit, then use 'hg resolve --mark')\n" |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
596 ), |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
597 precheck=_mergecheck, |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
598 ) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
599 def _imerge_diff(repo, mynode, local, other, base, toolconf, backup): |
46108
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
600 """ |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
601 Uses the internal non-interactive simple merge algorithm for merging |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
602 files. It will fail if there are any conflicts and leave markers in |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
603 the partially merged file. The marker will have two sections, one with the |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
604 content from one side of the merge, and one with a diff from the base |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
605 content to the content on the other side. (experimental)""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
606 return _merge(repo, local, other, base, b'mergediff') |
46108
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
607 |
bdc2bf68f19e
mergetools: add new conflict marker format with diffs in
Martin von Zweigbergk <martinvonz@google.com>
parents:
45942
diff
changeset
|
608 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
609 @internaltool(b'merge-local', mergeonly, precheck=_mergecheck) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
610 def _imergelocal(repo, mynode, local, other, base, toolconf, backup): |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
611 """ |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
612 Like :merge, but resolve all conflicts non-interactively in favor |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
613 of the local `p1()` changes.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
614 return _merge(repo, local, other, base, b'local') |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
615 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
616 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
617 @internaltool(b'merge-other', mergeonly, precheck=_mergecheck) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
618 def _imergeother(repo, mynode, local, other, base, toolconf, backup): |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
619 """ |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
620 Like :merge, but resolve all conflicts non-interactively in favor |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
621 of the other `p2()` changes.""" |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
622 return _merge(repo, local, other, base, b'other') |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
623 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
624 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
625 @internaltool( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
626 b'tagmerge', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
627 mergeonly, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
628 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
629 b"automatic tag merging of %s failed! " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
630 b"(use 'hg resolve --tool :merge' or another merge " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
631 b"tool of your choice)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
632 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
633 ) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
634 def _itagmerge(repo, mynode, local, other, base, toolconf, backup): |
21922
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
635 """ |
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
636 Uses the internal tag merge algorithm (experimental). |
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
637 """ |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
638 success, status = tagmerge.merge(repo, local.fctx, other.fctx, base.fctx) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
639 return success, status, False |
21922
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
640 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
641 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
642 @internaltool(b'dump', fullmerge, binary=True, symlink=True) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
643 def _idump(repo, mynode, local, other, base, toolconf, backup): |
16127
14dc2bbba6d2
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall <mpm@selenic.com>
parents:
16126
diff
changeset
|
644 """ |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
645 Creates three versions of the files to merge, containing the |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
646 contents of local, other and base. These files can then be used to |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
647 perform a merge manually. If the file to be merged is named |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
648 ``a.txt``, these files will accordingly be named ``a.txt.local``, |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
649 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the |
32255
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
650 same directory as ``a.txt``. |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
651 |
34915
cab34bda259e
help: fix typo in hg merge documentation
Joe Blaylock <jrbl@google.com>
parents:
34826
diff
changeset
|
652 This implies premerge. Therefore, files aren't dumped, if premerge |
32255
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
653 runs successfully. Use :forcedump to forcibly write files out. |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
654 """ |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
655 a = _workingpath(repo, local.fctx) |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
656 fd = local.fctx.path() |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
657 |
34785
1af4561b6bfe
filemerge: add a missing flushall()
Phil Cohen <phillco@fb.com>
parents:
34784
diff
changeset
|
658 from . import context |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
659 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
660 if isinstance(local.fctx, context.overlayworkingfilectx): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
661 raise error.InMemoryMergeConflictsError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
662 b'in-memory merge does not support the :dump tool.' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
663 ) |
34785
1af4561b6bfe
filemerge: add a missing flushall()
Phil Cohen <phillco@fb.com>
parents:
34784
diff
changeset
|
664 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
665 util.writefile(a + b".local", local.fctx.decodeddata()) |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
666 repo.wwrite(fd + b".other", other.fctx.data(), other.fctx.flags()) |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
667 repo.wwrite(fd + b".base", base.fctx.data(), base.fctx.flags()) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
668 return False, 1, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
669 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
670 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
671 @internaltool(b'forcedump', mergeonly, binary=True, symlink=True) |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
672 def _forcedump(repo, mynode, local, other, base, toolconf, backup): |
32255
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
673 """ |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
674 Creates three versions of the files as same as :dump, but omits premerge. |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
675 """ |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
676 return _idump(repo, mynode, local, other, base, toolconf, backup) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
677 |
32255
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32254
diff
changeset
|
678 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
679 def _xmergeimm(repo, mynode, local, other, base, toolconf, backup): |
35463
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
680 # In-memory merge simply raises an exception on all external merge tools, |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
681 # for now. |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
682 # |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
683 # It would be possible to run most tools with temporary files, but this |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
684 # raises the question of what to do if the user only partially resolves the |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
685 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/ |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
686 # directory and tell the user how to get it is my best idea, but it's |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
687 # clunky.) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
688 raise error.InMemoryMergeConflictsError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
689 b'in-memory merge does not support external merge tools' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
690 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
691 |
35463
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
692 |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
693 def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args): |
45768
5effb1992c17
config: move ui.pre-merge-tool-output-template into [command-templates]
Martin von Zweigbergk <martinvonz@google.com>
parents:
45767
diff
changeset
|
694 tmpl = ui.config(b'command-templates', b'pre-merge-tool-output') |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
695 if not tmpl: |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
696 return |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
697 |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
698 mappingdict = templateutil.mappingdict |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
699 props = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
700 b'ctx': fcl.changectx(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
701 b'node': hex(mynode), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
702 b'path': fcl.path(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
703 b'local': mappingdict( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
704 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
705 b'ctx': fcl.changectx(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
706 b'fctx': fcl, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
707 b'node': hex(mynode), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
708 b'name': _(b'local'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
709 b'islink': b'l' in fcl.flags(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
710 b'label': env[b'HG_MY_LABEL'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
711 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
712 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
713 b'base': mappingdict( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
714 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
715 b'ctx': fcb.changectx(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
716 b'fctx': fcb, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
717 b'name': _(b'base'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
718 b'islink': b'l' in fcb.flags(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
719 b'label': env[b'HG_BASE_LABEL'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
720 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
721 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
722 b'other': mappingdict( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
723 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
724 b'ctx': fco.changectx(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
725 b'fctx': fco, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
726 b'name': _(b'other'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
727 b'islink': b'l' in fco.flags(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
728 b'label': env[b'HG_OTHER_LABEL'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
729 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
730 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
731 b'toolpath': toolpath, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
732 b'toolargs': args, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
733 } |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
734 |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
735 # TODO: make all of this something that can be specified on a per-tool basis |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
736 tmpl = templater.unquotestring(tmpl) |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
737 |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
738 # Not using cmdutil.rendertemplate here since it causes errors importing |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
739 # things for us to import cmdutil. |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
740 tres = formatter.templateresources(ui, repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
741 t = formatter.maketemplater( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
742 ui, tmpl, defaults=templatekw.keywords, resources=tres |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
743 ) |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
744 ui.status(t.renderdefault(props)) |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
745 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
746 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
747 def _xmerge(repo, mynode, local, other, base, toolconf, backup): |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
748 fcd = local.fctx |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
749 fco = other.fctx |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
750 fca = base.fctx |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
751 tool, toolpath, binary, symlink, scriptfn = toolconf |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
752 uipathfn = scmutil.getuipathfn(repo) |
27042
30b919bc49bf
filemerge: don't try using external tools on change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27041
diff
changeset
|
753 if fcd.isabsent() or fco.isabsent(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
754 repo.ui.warn( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
755 _(b'warning: %s cannot merge change/delete conflict for %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
756 % (tool, uipathfn(fcd.path())) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
757 ) |
27042
30b919bc49bf
filemerge: don't try using external tools on change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27041
diff
changeset
|
758 return False, 1, None |
36976
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36835
diff
changeset
|
759 localpath = _workingpath(repo, fcd) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
760 args = _toolstr(repo.ui, tool, b"args") |
48788
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
761 |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
762 files = [ |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
763 (b"base", fca.path(), fca.decodeddata()), |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
764 (b"other", fco.path(), fco.decodeddata()), |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
765 ] |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
766 outpath = b"" |
48784
9d0d0a388c39
filemerge: remove `uselocalpath` argument from `_maketempfiles()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48783
diff
changeset
|
767 if b"$output" in args: |
48788
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
768 # read input from backup, write to original |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
769 outpath = localpath |
48784
9d0d0a388c39
filemerge: remove `uselocalpath` argument from `_maketempfiles()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48783
diff
changeset
|
770 localoutputpath = backup.path() |
48785
b53f2f5a18de
filemerge: move removal of `.orig` extension on temp file close to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48784
diff
changeset
|
771 # Remove the .orig to make syntax-highlighting more likely. |
b53f2f5a18de
filemerge: move removal of `.orig` extension on temp file close to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48784
diff
changeset
|
772 if localoutputpath.endswith(b'.orig'): |
b53f2f5a18de
filemerge: move removal of `.orig` extension on temp file close to context
Martin von Zweigbergk <martinvonz@google.com>
parents:
48784
diff
changeset
|
773 localoutputpath, ext = os.path.splitext(localoutputpath) |
48967
a54a866349ed
filemerge: when merge tool uses $output, don't leave markers in $local
Martin von Zweigbergk <martinvonz@google.com>
parents:
48788
diff
changeset
|
774 files.append((b"local", localoutputpath, backup.data())) |
37077
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
36999
diff
changeset
|
775 |
48788
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
776 with _maketempfiles(files) as temppaths: |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
777 basepath, otherpath = temppaths[:2] |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
778 if len(temppaths) == 3: |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
779 localpath = temppaths[2] |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
780 |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
781 def format_label(input): |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
782 if input.label_detail: |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
783 return b'%s: %s' % (input.label, input.label_detail) |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
784 else: |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
785 return input.label |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
786 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
787 env = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
788 b'HG_FILE': fcd.path(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
789 b'HG_MY_NODE': short(mynode), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
790 b'HG_OTHER_NODE': short(fco.changectx().node()), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
791 b'HG_BASE_NODE': short(fca.changectx().node()), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
792 b'HG_MY_ISLINK': b'l' in fcd.flags(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
793 b'HG_OTHER_ISLINK': b'l' in fco.flags(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
794 b'HG_BASE_ISLINK': b'l' in fca.flags(), |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
795 b'HG_MY_LABEL': format_label(local), |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
796 b'HG_OTHER_LABEL': format_label(other), |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
797 b'HG_BASE_LABEL': format_label(base), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
798 } |
34035
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34034
diff
changeset
|
799 ui = repo.ui |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
800 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
801 replace = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
802 b'local': localpath, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
803 b'base': basepath, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
804 b'other': otherpath, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
805 b'output': outpath, |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
806 b'labellocal': format_label(local), |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
807 b'labelother': format_label(other), |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
808 b'labelbase': format_label(base), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
809 } |
37120
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37084
diff
changeset
|
810 args = util.interpolate( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
811 br'\$', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
812 replace, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
813 args, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
814 lambda s: procutil.shellquote(util.localpath(s)), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
815 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
816 if _toolbool(ui, tool, b"gui"): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
817 repo.ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
818 _(b'running merge tool %s for file %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
819 % (tool, uipathfn(fcd.path())) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
820 ) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
821 if scriptfn is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
822 cmd = toolpath + b' ' + args |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
823 repo.ui.debug(b'launching merge tool: %s\n' % cmd) |
40478
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39359
diff
changeset
|
824 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
825 r = ui.system( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
826 cmd, cwd=repo.root, environ=env, blockedtag=b'mergetool' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
827 ) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
828 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
829 repo.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
830 b'launching python merge script: %s:%s\n' % (toolpath, scriptfn) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
831 ) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
832 r = 0 |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
833 try: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
834 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
835 from . import extensions |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
836 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
837 mod = extensions.loadpath(toolpath, b'hgmerge.%s' % tool) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
838 except Exception: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
839 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
840 _(b"loading python merge script failed: %s") % toolpath |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
841 ) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
842 mergefn = getattr(mod, scriptfn, None) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
843 if mergefn is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
844 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
845 _(b"%s does not have function: %s") % (toolpath, scriptfn) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
846 ) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
847 argslist = procutil.shellsplit(args) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
848 # avoid cycle cmdutil->merge->filemerge->hook->extensions->cmdutil |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
849 from . import hook |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
850 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
851 ret, raised = hook.pythonhook( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
852 ui, repo, b"merge", toolpath, mergefn, {b'args': argslist}, True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
853 ) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
854 if raised: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
855 r = 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
856 repo.ui.debug(b'merge tool returned: %d\n' % r) |
34035
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34034
diff
changeset
|
857 return True, r, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
858 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
859 |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
860 def _populate_label_detail(input, template): |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
861 """Applies the given template to the ctx and stores it in the input.""" |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
862 ctx = input.fctx.changectx() |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
863 if ctx.node() is None: |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
864 ctx = ctx.p1() |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
865 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
866 props = {b'ctx': ctx} |
36988
317382151ac3
templater: rename .render(mapping) to .renderdefault(mapping) (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36976
diff
changeset
|
867 templateresult = template.renderdefault(props) |
49028
db93041e5b1c
filemerge: use new function for getting first line of string
Martin von Zweigbergk <martinvonz@google.com>
parents:
48982
diff
changeset
|
868 input.label_detail = stringutil.firstline(templateresult) # avoid '\n' |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
869 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
870 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
871 def _populate_label_details(repo, inputs, tool=None): |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
872 """Populates the label details using the conflict marker template.""" |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
873 ui = repo.ui |
45767
40411ad2f5d2
config: rename ui.mergemarkertemplate to command-templates.mergemarker
Martin von Zweigbergk <martinvonz@google.com>
parents:
44872
diff
changeset
|
874 template = ui.config(b'command-templates', b'mergemarker') |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
875 if tool is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
876 template = _toolstr(ui, tool, b'mergemarkertemplate', template) |
32047
458f7294dfee
filemerge: optionally strip quotes from merge marker template (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
31436
diff
changeset
|
877 template = templater.unquotestring(template) |
35469
f1c54d003327
templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents:
35463
diff
changeset
|
878 tres = formatter.templateresources(ui, repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
879 tmpl = formatter.maketemplater( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
880 ui, template, defaults=templatekw.keywords, resources=tres |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
881 ) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
882 |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
883 for input in inputs: |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
884 _populate_label_detail(input, tmpl) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
885 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
886 |
29774
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
887 def partextras(labels): |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
888 """Return a dictionary of extra labels for use in prompts to the user |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
889 |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
890 Intended use is in strings of the form "(l)ocal%(l)s". |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
891 """ |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
892 if labels is None: |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
893 return { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
894 b"l": b"", |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
895 b"o": b"", |
29774
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
896 } |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
897 |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
898 return { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
899 b"l": b" [%s]" % labels[0], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
900 b"o": b" [%s]" % labels[1], |
29774
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
901 } |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29660
diff
changeset
|
902 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
903 |
48782
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
904 def _makebackup(repo, ui, fcd): |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
905 """Makes and returns a filectx-like object for ``fcd``'s backup file. |
34031
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
906 |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
907 In addition to preserving the user's pre-existing modifications to `fcd` |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
908 (if any), the backup is used to undo certain premerges, confirm whether a |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
909 merge changed anything, and determine what line endings the new file should |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
910 have. |
35702
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35483
diff
changeset
|
911 |
48433
0994125a31e5
filemerge: remove `premerge` argument from `_makebackup()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48432
diff
changeset
|
912 Backups only need to be written once since their content doesn't change |
0994125a31e5
filemerge: remove `premerge` argument from `_makebackup()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48432
diff
changeset
|
913 afterwards. |
34031
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
914 """ |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
915 if fcd.isabsent(): |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
916 return None |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
917 # TODO: Break this import cycle somehow. (filectx -> ctx -> fileset -> |
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
918 # merge -> filemerge). (I suspect the fileset import is the weakest link) |
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
919 from . import context |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
920 |
48782
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
921 if isinstance(fcd, context.overlayworkingfilectx): |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
922 # If we're merging in-memory, we're free to put the backup anywhere. |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
923 fd, backup = pycompat.mkstemp(b'hg-merge-backup') |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
924 with os.fdopen(fd, 'wb') as f: |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
925 f.write(fcd.data()) |
34784
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
926 else: |
48782
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
927 backup = scmutil.backuppath(ui, repo, fcd.path()) |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
928 a = _workingpath(repo, fcd) |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
929 util.copyfile(a, backup) |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
930 |
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
931 return context.arbitraryfilectx(backup, repo=repo) |
34031
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
932 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
933 |
36998
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36988
diff
changeset
|
934 @contextlib.contextmanager |
48788
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
935 def _maketempfiles(files): |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
936 """Creates a temporary file for each (prefix, path, data) tuple in `files`, |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
937 so an external merge tool may use them. |
34031
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
938 """ |
48772
b70c9697ab41
filemerge: put temporary files in single temp dir by default
Martin von Zweigbergk <martinvonz@google.com>
parents:
48760
diff
changeset
|
939 tmproot = pycompat.mkdtemp(prefix=b'hgmerge-') |
36999
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
36998
diff
changeset
|
940 |
48787
69000dc0dced
filemerge: reduce some duplication in `_maketempfiles()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48786
diff
changeset
|
941 def maketempfrompath(prefix, path, data): |
37077
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
36999
diff
changeset
|
942 fullbase, ext = os.path.splitext(path) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
943 pre = b"%s~%s" % (os.path.basename(fullbase), prefix) |
48772
b70c9697ab41
filemerge: put temporary files in single temp dir by default
Martin von Zweigbergk <martinvonz@google.com>
parents:
48760
diff
changeset
|
944 name = os.path.join(tmproot, pre) |
b70c9697ab41
filemerge: put temporary files in single temp dir by default
Martin von Zweigbergk <martinvonz@google.com>
parents:
48760
diff
changeset
|
945 if ext: |
b70c9697ab41
filemerge: put temporary files in single temp dir by default
Martin von Zweigbergk <martinvonz@google.com>
parents:
48760
diff
changeset
|
946 name += ext |
48787
69000dc0dced
filemerge: reduce some duplication in `_maketempfiles()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48786
diff
changeset
|
947 util.writefile(name, data) |
69000dc0dced
filemerge: reduce some duplication in `_maketempfiles()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48786
diff
changeset
|
948 return name |
37077
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
36999
diff
changeset
|
949 |
48788
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
950 temp_files = [] |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
951 for prefix, path, data in files: |
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
952 temp_files.append(maketempfrompath(prefix, path, data)) |
36998
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36988
diff
changeset
|
953 try: |
48788
f90337706ce7
filemerge: make `_maketempfiles()` more reusable
Martin von Zweigbergk <martinvonz@google.com>
parents:
48787
diff
changeset
|
954 yield temp_files |
36998
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36988
diff
changeset
|
955 finally: |
48772
b70c9697ab41
filemerge: put temporary files in single temp dir by default
Martin von Zweigbergk <martinvonz@google.com>
parents:
48760
diff
changeset
|
956 shutil.rmtree(tmproot) |
34031
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33906
diff
changeset
|
957 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
958 |
48432
f45a4a47f6a8
filemerge: inline `_filemerge()` into `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48431
diff
changeset
|
959 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None): |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
960 """perform a 3-way merge in the working directory |
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
961 |
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
962 mynode = parent node before merge |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
963 orig = original local filename before merge |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
964 fco = other file context |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
965 fca = ancestor file context |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
966 fcd = local file context for current/destination file |
26606
2a405d307f8c
filemerge: also return whether the merge is complete
Siddharth Agarwal <sid0@fb.com>
parents:
26605
diff
changeset
|
967 |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
968 Returns whether the merge is complete, the return value of the merge, and |
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
969 a boolean indicating whether the file was deleted from disk.""" |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
970 ui = repo.ui |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
971 fd = fcd.path() |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
972 uipathfn = scmutil.getuipathfn(repo) |
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
973 fduipath = uipathfn(fd) |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
974 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
975 symlink = b'l' in fcd.flags() + fco.flags() |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
976 changedelete = fcd.isabsent() or fco.isabsent() |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
977 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
978 scriptfn = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
979 if tool in internals and tool.startswith(b'internal:'): |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
980 # normalize to new-style names (':merge' etc) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
981 tool = tool[len(b'internal') :] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
982 if toolpath and toolpath.startswith(b'python:'): |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
983 invalidsyntax = False |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
984 if toolpath.count(b':') >= 2: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
985 script, scriptfn = toolpath[7:].rsplit(b':', 1) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
986 if not scriptfn: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
987 invalidsyntax = True |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
988 # missing :callable can lead to spliting on windows drive letter |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
989 if b'\\' in scriptfn or b'/' in scriptfn: |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
990 invalidsyntax = True |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
991 else: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
992 invalidsyntax = True |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
993 if invalidsyntax: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
994 raise error.Abort(_(b"invalid 'python:' syntax: %s") % toolpath) |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
995 toolpath = script |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
996 ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
997 b"picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
998 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
999 tool, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1000 fduipath, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1001 pycompat.bytestr(binary), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1002 pycompat.bytestr(symlink), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1003 pycompat.bytestr(changedelete), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1004 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1005 ) |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1006 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1007 if tool in internals: |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1008 func = internals[tool] |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1009 mergetype = func.mergetype |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1010 onfailure = func.onfailure |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1011 precheck = func.precheck |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1012 isexternal = False |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1013 else: |
35463
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
1014 if wctx.isinmemory(): |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
1015 func = _xmergeimm |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
1016 else: |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35282
diff
changeset
|
1017 func = _xmerge |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1018 mergetype = fullmerge |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1019 onfailure = _(b"merging %s failed!\n") |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1020 precheck = None |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1021 isexternal = True |
26512
4c52dd406adc
filemerge: indent filemerge.filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26224
diff
changeset
|
1022 |
38041
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37120
diff
changeset
|
1023 toolconf = tool, toolpath, binary, symlink, scriptfn |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1024 |
48583
a809f1465a76
filemerge: set default labels a little earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
48579
diff
changeset
|
1025 if not labels: |
a809f1465a76
filemerge: set default labels a little earlier
Martin von Zweigbergk <martinvonz@google.com>
parents:
48579
diff
changeset
|
1026 labels = [b'local', b'other'] |
48584
74973a6d4e67
filemerge: always define a "base" label
Martin von Zweigbergk <martinvonz@google.com>
parents:
48583
diff
changeset
|
1027 if len(labels) < 3: |
74973a6d4e67
filemerge: always define a "base" label
Martin von Zweigbergk <martinvonz@google.com>
parents:
48583
diff
changeset
|
1028 labels.append(b'base') |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1029 local = simplemerge.MergeInput(fcd, labels[0]) |
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1030 other = simplemerge.MergeInput(fco, labels[1]) |
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1031 base = simplemerge.MergeInput(fca, labels[2]) |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1032 if mergetype == nomerge: |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1033 return func( |
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1034 repo, |
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1035 mynode, |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1036 local, |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1037 other, |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1038 base, |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1039 toolconf, |
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1040 ) |
26512
4c52dd406adc
filemerge: indent filemerge.filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26224
diff
changeset
|
1041 |
48431
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1042 if orig != fco.path(): |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1043 ui.status( |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1044 _(b"merging %s and %s to %s\n") |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1045 % (uipathfn(orig), uipathfn(fco.path()), fduipath) |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1046 ) |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1047 else: |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1048 ui.status(_(b"merging %s\n") % fduipath) |
26528
8bfef5737321
filemerge: move 'merging' output to before file creation
Siddharth Agarwal <sid0@fb.com>
parents:
26527
diff
changeset
|
1049 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1050 ui.debug(b"my %s other %s ancestor %s\n" % (fcd, fco, fca)) |
26528
8bfef5737321
filemerge: move 'merging' output to before file creation
Siddharth Agarwal <sid0@fb.com>
parents:
26527
diff
changeset
|
1051 |
48505
40522aea2f27
filemerge: remove unused `orig` argument from tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48504
diff
changeset
|
1052 if precheck and not precheck(repo, mynode, fcd, fco, fca, toolconf): |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
1053 if onfailure: |
35282
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35281
diff
changeset
|
1054 if wctx.isinmemory(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1055 raise error.InMemoryMergeConflictsError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1056 b'in-memory merge does not support merge conflicts' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1057 ) |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1058 ui.warn(onfailure % fduipath) |
48506
608a35db186c
filemerge: stop returning always-`True` value
Martin von Zweigbergk <martinvonz@google.com>
parents:
48505
diff
changeset
|
1059 return 1, False |
26529
7833b13b001f
filemerge: move precheck to before files are written out
Siddharth Agarwal <sid0@fb.com>
parents:
26528
diff
changeset
|
1060 |
48782
c7dbfc363655
filemerge: when using in-memory merge, always put backup files in temp dir
Martin von Zweigbergk <martinvonz@google.com>
parents:
48781
diff
changeset
|
1061 backup = _makebackup(repo, ui, fcd) |
26589
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
1062 r = 1 |
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
1063 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1064 internalmarkerstyle = ui.config(b'ui', b'mergemarkers') |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1065 if isexternal: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1066 markerstyle = _toolstr(ui, tool, b'mergemarkers') |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1067 else: |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1068 markerstyle = internalmarkerstyle |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1069 |
48431
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1070 if mergetype == fullmerge: |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1071 _run_partial_resolution_tools(repo, local, other, base) |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1072 # conflict markers generated by premerge will use 'detailed' |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1073 # settings if either ui.mergemarkers or the tool's mergemarkers |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1074 # setting is 'detailed'. This way tools can have basic labels in |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1075 # space-constrained areas of the UI, but still get full information |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1076 # in conflict markers if premerge is 'keep' or 'keep-merge3'. |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1077 labeltool = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1078 if markerstyle != b'basic': |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1079 # respect 'tool's mergemarkertemplate (which defaults to |
45767
40411ad2f5d2
config: rename ui.mergemarkertemplate to command-templates.mergemarker
Martin von Zweigbergk <martinvonz@google.com>
parents:
44872
diff
changeset
|
1080 # command-templates.mergemarker) |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1081 labeltool = tool |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1082 if internalmarkerstyle != b'basic' or markerstyle != b'basic': |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1083 _populate_label_details( |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1084 repo, [local, other, base], tool=labeltool |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1085 ) |
35907
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35829
diff
changeset
|
1086 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1087 r = _premerge( |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1088 repo, |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1089 local, |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1090 other, |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1091 base, |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1092 toolconf, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1093 ) |
48431
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1094 # we're done if premerge was successful (r is 0) |
6b1049d71c3e
filemerge: make `_filemerge()` do both premerge and merge
Martin von Zweigbergk <martinvonz@google.com>
parents:
48430
diff
changeset
|
1095 if not r: |
48506
608a35db186c
filemerge: stop returning always-`True` value
Martin von Zweigbergk <martinvonz@google.com>
parents:
48505
diff
changeset
|
1096 return r, False |
26567
f18646cf0e93
filemerge: call premerge directly from main merge function
Siddharth Agarwal <sid0@fb.com>
parents:
26529
diff
changeset
|
1097 |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1098 # Reset to basic labels |
48587
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
1099 local.label_detail = None |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
1100 other.label_detail = None |
3c8cc987672e
simplemerge: take over formatting of label from `filemerge`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48586
diff
changeset
|
1101 base.label_detail = None |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1102 |
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1103 if markerstyle != b'basic': |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1104 _populate_label_details(repo, [local, other, base], tool=tool) |
48585
07069fcd9a6e
filemerge: work with `simplemerge.MergeInput` in `filemerge()`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48584
diff
changeset
|
1105 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1106 needcheck, r, deleted = func( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1107 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1108 mynode, |
48586
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1109 local, |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1110 other, |
fd9fe2658cda
filemerge: pass `simplemerge.MergeInput` to tool functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
48585
diff
changeset
|
1111 base, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1112 toolconf, |
48504
ba34141f8dbb
filemerge: stop passing around 3 unused `None` values in `files` argument
Martin von Zweigbergk <martinvonz@google.com>
parents:
48503
diff
changeset
|
1113 backup, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1114 ) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
1115 |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1116 if needcheck: |
48504
ba34141f8dbb
filemerge: stop passing around 3 unused `None` values in `files` argument
Martin von Zweigbergk <martinvonz@google.com>
parents:
48503
diff
changeset
|
1117 r = _check(repo, r, ui, tool, fcd, backup) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
1118 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
1119 if r: |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
1120 if onfailure: |
35282
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35281
diff
changeset
|
1121 if wctx.isinmemory(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1122 raise error.InMemoryMergeConflictsError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1123 b'in-memory merge ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1124 b'does not support ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1125 b'merge conflicts' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1126 ) |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1127 ui.warn(onfailure % fduipath) |
34797
284fa44f7f39
merge: allow user to halt merge on merge-tool failures
Ryan McElroy <rmcelroy@fb.com>
parents:
34796
diff
changeset
|
1128 _onfilemergefailure(ui) |
26589
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
1129 |
48506
608a35db186c
filemerge: stop returning always-`True` value
Martin von Zweigbergk <martinvonz@google.com>
parents:
48505
diff
changeset
|
1130 return r, deleted |
26589
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
1131 finally: |
48503
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
1132 if not r and backup is not None: |
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
1133 backup.remove() |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
1134 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1135 |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1136 def _run_partial_resolution_tools(repo, local, other, base): |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1137 """Runs partial-resolution tools on the three inputs and updates them.""" |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1138 ui = repo.ui |
49167
7af798e497f5
filemerge: add configs to disable some or all partial merge tools
Martin von Zweigbergk <martinvonz@google.com>
parents:
49028
diff
changeset
|
1139 if ui.configbool(b'merge', b'disable-partial-tools'): |
7af798e497f5
filemerge: add configs to disable some or all partial merge tools
Martin von Zweigbergk <martinvonz@google.com>
parents:
49028
diff
changeset
|
1140 return |
48982
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1141 # Tuples of (order, name, executable path, args) |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1142 tools = [] |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1143 seen = set() |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1144 section = b"partial-merge-tools" |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1145 for k, v in ui.configitems(section): |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1146 name = k.split(b'.')[0] |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1147 if name in seen: |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1148 continue |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1149 patterns = ui.configlist(section, b'%s.patterns' % name, []) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1150 is_match = True |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1151 if patterns: |
49840
59466b13a3ae
filemerge: fix crash when using filesets in [partial-merge-tools]
Martin von Zweigbergk <martinvonz@google.com>
parents:
49167
diff
changeset
|
1152 m = match.match( |
59466b13a3ae
filemerge: fix crash when using filesets in [partial-merge-tools]
Martin von Zweigbergk <martinvonz@google.com>
parents:
49167
diff
changeset
|
1153 repo.root, b'', patterns, ctx=local.fctx.changectx() |
59466b13a3ae
filemerge: fix crash when using filesets in [partial-merge-tools]
Martin von Zweigbergk <martinvonz@google.com>
parents:
49167
diff
changeset
|
1154 ) |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1155 is_match = m(local.fctx.path()) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1156 if is_match: |
49167
7af798e497f5
filemerge: add configs to disable some or all partial merge tools
Martin von Zweigbergk <martinvonz@google.com>
parents:
49028
diff
changeset
|
1157 if ui.configbool(section, b'%s.disable' % name): |
7af798e497f5
filemerge: add configs to disable some or all partial merge tools
Martin von Zweigbergk <martinvonz@google.com>
parents:
49028
diff
changeset
|
1158 continue |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1159 order = ui.configint(section, b'%s.order' % name, 0) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1160 executable = ui.config(section, b'%s.executable' % name, name) |
48982
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1161 args = ui.config(section, b'%s.args' % name) |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1162 tools.append((order, name, executable, args)) |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1163 |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1164 if not tools: |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1165 return |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1166 # Sort in configured order (first in tuple) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1167 tools.sort() |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1168 |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1169 files = [ |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1170 (b"local", local.fctx.path(), local.text()), |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1171 (b"base", base.fctx.path(), base.text()), |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1172 (b"other", other.fctx.path(), other.text()), |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1173 ] |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1174 |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1175 with _maketempfiles(files) as temppaths: |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1176 localpath, basepath, otherpath = temppaths |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1177 |
48982
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1178 for order, name, executable, args in tools: |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1179 cmd = procutil.shellquote(executable) |
48982
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1180 replace = { |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1181 b'local': localpath, |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1182 b'base': basepath, |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1183 b'other': otherpath, |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1184 } |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1185 args = util.interpolate( |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1186 br'\$', |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1187 replace, |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1188 args, |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1189 lambda s: procutil.shellquote(util.localpath(s)), |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1190 ) |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1191 |
9dfbea54b680
partial-merge: add support for `.args` config (`$local` etc.)
Martin von Zweigbergk <martinvonz@google.com>
parents:
48981
diff
changeset
|
1192 cmd = b'%s %s' % (cmd, args) |
48981
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1193 r = ui.system(cmd, cwd=repo.root, blockedtag=b'partial-mergetool') |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1194 if r: |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1195 raise error.StateError( |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1196 b'partial merge tool %s exited with code %d' % (name, r) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1197 ) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1198 local_text = util.readfile(localpath) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1199 other_text = util.readfile(otherpath) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1200 if local_text == other_text: |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1201 # No need to run other tools if all conflicts have been resolved |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1202 break |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1203 |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1204 local.set_text(local_text) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1205 base.set_text(util.readfile(basepath)) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1206 other.set_text(other_text) |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1207 |
f3aafd785e65
filemerge: add support for partial conflict resolution by external tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
48971
diff
changeset
|
1208 |
34796
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1209 def _haltmerge(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1210 msg = _(b'merge halted after failed merge (see hg resolve)') |
34796
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1211 raise error.InterventionRequired(msg) |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1212 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1213 |
34796
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1214 def _onfilemergefailure(ui): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1215 action = ui.config(b'merge', b'on-failure') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1216 if action == b'prompt': |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1217 msg = _(b'continue merge operation (yn)?$$ &Yes $$ &No') |
34796
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1218 if ui.promptchoice(msg, 0) == 1: |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1219 _haltmerge() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1220 if action == b'halt': |
34796
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1221 _haltmerge() |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1222 # default action is 'continue', in which case we neither prompt nor halt |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
1223 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1224 |
38793
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38165
diff
changeset
|
1225 def hasconflictmarkers(data): |
47939
053dd53a0b59
filemerge: be more strict when detecting conflict markers, add `|` markers
Kyle Lippincott <spectral@google.com>
parents:
47012
diff
changeset
|
1226 # Detect lines starting with a string of 7 identical characters from the |
053dd53a0b59
filemerge: be more strict when detecting conflict markers, add `|` markers
Kyle Lippincott <spectral@google.com>
parents:
47012
diff
changeset
|
1227 # subset Mercurial uses for conflict markers, followed by either the end of |
053dd53a0b59
filemerge: be more strict when detecting conflict markers, add `|` markers
Kyle Lippincott <spectral@google.com>
parents:
47012
diff
changeset
|
1228 # line or a space and some text. Note that using [<>=+|-]{7} would detect |
053dd53a0b59
filemerge: be more strict when detecting conflict markers, add `|` markers
Kyle Lippincott <spectral@google.com>
parents:
47012
diff
changeset
|
1229 # `<><><><><` as a conflict marker, which we don't want. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1230 return bool( |
46356
0c95b59a89f1
resolve: also detect new :mergediff conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents:
46139
diff
changeset
|
1231 re.search( |
47939
053dd53a0b59
filemerge: be more strict when detecting conflict markers, add `|` markers
Kyle Lippincott <spectral@google.com>
parents:
47012
diff
changeset
|
1232 br"^([<>=+|-])\1{6}( .*)$", |
46356
0c95b59a89f1
resolve: also detect new :mergediff conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents:
46139
diff
changeset
|
1233 data, |
0c95b59a89f1
resolve: also detect new :mergediff conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents:
46139
diff
changeset
|
1234 re.MULTILINE, |
0c95b59a89f1
resolve: also detect new :mergediff conflict markers
Martin von Zweigbergk <martinvonz@google.com>
parents:
46139
diff
changeset
|
1235 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1236 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1237 |
38793
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38165
diff
changeset
|
1238 |
48504
ba34141f8dbb
filemerge: stop passing around 3 unused `None` values in `files` argument
Martin von Zweigbergk <martinvonz@google.com>
parents:
48503
diff
changeset
|
1239 def _check(repo, r, ui, tool, fcd, backup): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1240 fd = fcd.path() |
41510
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41365
diff
changeset
|
1241 uipathfn = scmutil.getuipathfn(repo) |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1242 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1243 if not r and ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1244 _toolbool(ui, tool, b"checkconflicts") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1245 or b'conflicts' in _toollist(ui, tool, b"check") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1246 ): |
38793
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38165
diff
changeset
|
1247 if hasconflictmarkers(fcd.data()): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1248 r = 1 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1249 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1250 checked = False |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1251 if b'prompt' in _toollist(ui, tool, b"check"): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1252 checked = True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1253 if ui.promptchoice( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1254 _(b"was merge of '%s' successful (yn)?$$ &Yes $$ &No") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1255 % uipathfn(fd), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1256 1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1257 ): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1258 r = 1 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1259 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1260 if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1261 not r |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1262 and not checked |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1263 and ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1264 _toolbool(ui, tool, b"checkchanged") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1265 or b'changed' in _toollist(ui, tool, b"check") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1266 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1267 ): |
48503
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
1268 if backup is not None and not fcd.cmp(backup): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1269 if ui.promptchoice( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1270 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1271 b" output file %s appears unchanged\n" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1272 b"was merge successful (yn)?" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1273 b"$$ &Yes $$ &No" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1274 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1275 % uipathfn(fd), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1276 1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1277 ): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1278 r = 1 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1279 |
48503
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
1280 if backup is not None and _toolbool(ui, tool, b"fixeol"): |
da38519cbd10
filemerge: rename backup variables from `back` to `backup`
Martin von Zweigbergk <martinvonz@google.com>
parents:
48469
diff
changeset
|
1281 _matcheol(_workingpath(repo, fcd), backup) |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1282 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1283 return r |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1284 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1285 |
34034
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34033
diff
changeset
|
1286 def _workingpath(repo, ctx): |
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34033
diff
changeset
|
1287 return repo.wjoin(ctx.path()) |
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34033
diff
changeset
|
1288 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1289 |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1290 def loadinternalmerge(ui, extname, registrarobj): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45768
diff
changeset
|
1291 """Load internal merge tool from specified registrarobj""" |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
1292 for name, func in registrarobj._table.items(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1293 fullname = b':' + name |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1294 internals[fullname] = func |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1295 internals[b'internal:' + name] = func |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1296 internalsdoc[fullname] = func |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1297 |
39126
e09fad982ef5
filemerge: show actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39125
diff
changeset
|
1298 capabilities = sorted([k for k, v in func.capabilities.items() if v]) |
e09fad982ef5
filemerge: show actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39125
diff
changeset
|
1299 if capabilities: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1300 capdesc = b" (actual capabilities: %s)" % b', '.join( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1301 capabilities |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1302 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1303 func.__doc__ = func.__doc__ + pycompat.sysstr(b"\n\n%s" % capdesc) |
39267
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1304 |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1305 # to put i18n comments into hg.pot for automatically generated texts |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1306 |
39359
bc0eb1dc6aae
filemerge: fix an i18n comment typo
Matt Harbison <matt_harbison@yahoo.com>
parents:
39285
diff
changeset
|
1307 # i18n: "binary" and "symlink" are keywords |
39267
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1308 # i18n: this text is added automatically |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1309 _(b" (actual capabilities: binary, symlink)") |
39267
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1310 # i18n: "binary" is keyword |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1311 # i18n: this text is added automatically |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1312 _(b" (actual capabilities: binary)") |
39267
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1313 # i18n: "symlink" is keyword |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39266
diff
changeset
|
1314 # i18n: this text is added automatically |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1315 _(b" (actual capabilities: symlink)") |
39126
e09fad982ef5
filemerge: show actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39125
diff
changeset
|
1316 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42565
diff
changeset
|
1317 |
33699
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1318 # load built-in merge tools explicitly to setup internalsdoc |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1319 loadinternalmerge(None, None, internaltool) |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1320 |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
1321 # tell hggettext to extract docstrings from these functions: |
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
1322 i18nfunctions = internals.values() |