Mercurial > public > mercurial-scm > hg-stable
annotate mercurial/filemerge.py @ 42565:4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
I've chosen <40 as the target so that other languages that may have a 2x blowup
in character count can still have a chance to fit into an 80 column screen.
Previously, we would show a prompt like:
```
keep (l)ocal [dest], take (o)ther [source], or leave (u)nresolved for some/potentially/really/long/path?
```
On at least some systems, if readline was in use then the last line of the
prompt would be wrapped strangely if it couldn't fit entirely on one line. This
strange wrapping may be just a carriage return without a line feed, overwriting
the beginning of the line; example (100 columns wide, 65 character filename, and
yes there's 10 spaces on the end, I assume this is to handle the user inputting
longest word we provide as an option, "unresolved"):
```
ng/dir/name/that/does/not/work/well/with/readline/file.txt? ave (u)nresolved for some/lon
```
In some cases it may partially wrap onto the next line, but still be missing
earlier parts in the line, such as below (60 columns wide, 65 character
filename):
```
rev], or leave (u)nresolved for some/long/dir/name/that/do
s/not/work/well/with/readline/file.txt?
```
With this fix, this looks like this on a 60 column screen:
```
tool vim_with_markers (for pattern some/long/dir/name/that/d
oes/not/work/well/with/readline/file.txt) can't handle binar
y
tool meld can't handle binary
tool vim_with_markers can't handle binary
tool internal:merge3 can't handle binary
tool merge can't handle binary
no tool found to merge some/long/dir/name/that/does/not/work
/well/with/readline/file.txt
file 'some/long/dir/name/that/does/not/work/well/with/readli
ne/file.txt' needs to be resolved.
You can keep (l)ocal [working copy], take (o)ther [merge rev
], or leave (u)nresolved.
What do you want to do?
```
Differential Revision: https://phab.mercurial-scm.org/D6562
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Thu, 20 Jun 2019 11:40:47 -0700 |
parents | a8ccd821b7d2 |
children | 2372284d9457 |
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 # |
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> |
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 from __future__ import absolute_import |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
9 |
37001
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36991
diff
changeset
|
10 import contextlib |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
11 import os |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
12 import re |
37002
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
13 import shutil |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
14 |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
15 from .i18n import _ |
40528
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
16 from .node import ( |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
17 hex, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
18 nullid, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
19 short, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
20 ) |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
21 |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
22 from . import ( |
30641
f1c9fafcbf46
py3: replace os.environ with encoding.environ (part 3 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30547
diff
changeset
|
23 encoding, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
24 error, |
28955
78759f78a44e
templater: factor out function that creates templater from string template
Yuya Nishihara <yuya@tcha.org>
parents:
28954
diff
changeset
|
25 formatter, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
26 match, |
30073
aa23c93e636d
py3: make format strings unicodes and not bytes
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29786
diff
changeset
|
27 pycompat, |
33725
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
28 registrar, |
27651
07fc2f2134ba
origpath: move from cmdutil to scmutil
Siddharth Agarwal <sid0@fb.com>
parents:
27599
diff
changeset
|
29 scmutil, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
30 simplemerge, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
31 tagmerge, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
32 templatekw, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
33 templater, |
40528
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
34 templateutil, |
25949
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
35 util, |
80aba76e29c1
filemerge: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25835
diff
changeset
|
36 ) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
37 |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37080
diff
changeset
|
38 from .utils import ( |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
39 procutil, |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37080
diff
changeset
|
40 stringutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37080
diff
changeset
|
41 ) |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37080
diff
changeset
|
42 |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
43 def _toolstr(ui, tool, part, *args): |
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
44 return ui.config("merge-tools", tool + "." + part, *args) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
45 |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
46 def _toolbool(ui, tool, part,*args): |
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
47 return ui.configbool("merge-tools", tool + "." + part, *args) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
48 |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
49 def _toollist(ui, tool, part): |
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
50 return ui.configlist("merge-tools", tool + "." + part) |
11148
a912f26777d3
merge: introduce tool.check parameter
David Champion <dgc@uchicago.edu>
parents:
11146
diff
changeset
|
51 |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
52 internals = {} |
24099
be83fd9d46d5
help.merge-tools: do not double document merge tools
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23270
diff
changeset
|
53 # Merge tools to document. |
be83fd9d46d5
help.merge-tools: do not double document merge tools
Gregory Szorc <gregory.szorc@gmail.com>
parents:
23270
diff
changeset
|
54 internalsdoc = {} |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
55 |
33725
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
56 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
|
57 |
26525
abc2327e382a
filemerge: add some merge types
Siddharth Agarwal <sid0@fb.com>
parents:
26519
diff
changeset
|
58 # internal tool merge types |
33725
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
59 nomerge = internaltool.nomerge |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
60 mergeonly = internaltool.mergeonly # just the full merge, no premerge |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
61 fullmerge = internaltool.fullmerge # both premerge and merge |
26525
abc2327e382a
filemerge: add some merge types
Siddharth Agarwal <sid0@fb.com>
parents:
26519
diff
changeset
|
62 |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
63 # 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:
41613
diff
changeset
|
64 # 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:
41613
diff
changeset
|
65 # 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:
41613
diff
changeset
|
66 # 80-column screen). |
32357
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
67 _localchangedotherdeletedmsg = _( |
39312
a3fd84f4fb38
filemerge: fix the wrong placements of messages in prompt
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39311
diff
changeset
|
68 "file '%(fd)s' was deleted in other%(o)s but was modified in local%(l)s.\n" |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
69 "You can use (c)hanged version, (d)elete, or leave (u)nresolved.\n" |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
70 "What do you want to do?" |
32357
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
71 "$$ &Changed $$ &Delete $$ &Unresolved") |
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
72 |
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
73 _otherchangedlocaldeletedmsg = _( |
39312
a3fd84f4fb38
filemerge: fix the wrong placements of messages in prompt
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39311
diff
changeset
|
74 "file '%(fd)s' was deleted in local%(l)s but was modified in other%(o)s.\n" |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
75 "You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.\n" |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
76 "What do you want to do?" |
32357
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
77 "$$ &Changed $$ &Deleted $$ &Unresolved") |
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
78 |
26979
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
79 class absentfilectx(object): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
80 """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
|
81 present in it. |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
82 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
83 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
|
84 other code is likely going to break with the values this returns.""" |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
85 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
|
86 self._ctx = ctx |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
87 self._f = f |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
88 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
89 def path(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
90 return self._f |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
91 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
92 def size(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
93 return None |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
94 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
95 def data(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
96 return None |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
97 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
98 def filenode(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
99 return nullid |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
100 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
101 _customcmp = True |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
102 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
|
103 """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
|
104 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
105 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
|
106 """ |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
107 return not (fctx.isabsent() and |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
108 fctx.ctx() == self.ctx() and |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
109 fctx.path() == self.path()) |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
110 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
111 def flags(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
112 return '' |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
113 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
114 def changectx(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
115 return self._ctx |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
116 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
117 def isbinary(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
118 return False |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
119 |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
120 def isabsent(self): |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
121 return True |
7b038ec6c5fd
filemerge: introduce class whose objects represent files not in a context
Siddharth Agarwal <sid0@fb.com>
parents:
26967
diff
changeset
|
122 |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
123 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
|
124 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
|
125 return tool |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
126 cmd = _toolstr(ui, tool, "executable", tool) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
127 if cmd.startswith('python:'): |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
128 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
|
129 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
|
130 |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
131 def _quotetoolpath(cmd): |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
132 if cmd.startswith('python:'): |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
133 return cmd |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
134 return procutil.shellquote(cmd) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
135 |
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
|
136 def findexternaltool(ui, tool): |
13565
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
137 for kn in ("regkey", "regkeyalt"): |
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
138 k = _toolstr(ui, tool, kn) |
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
139 if not k: |
984175605311
filemerge: introduce a 'regkeyalt' merge tool variable
Steve Borho <steve@borho.org>
parents:
12788
diff
changeset
|
140 continue |
14230
d51630301241
rename util.lookup_reg to lookupreg
Adrian Buehlmann <adrian@cadifra.com>
parents:
14168
diff
changeset
|
141 p = util.lookupreg(k, _toolstr(ui, tool, "regname")) |
6006
3c9dbb743d20
merge: add registry look up bits to tool search
Matt Mackall <mpm@selenic.com>
parents:
6005
diff
changeset
|
142 if p: |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
143 p = procutil.findexe(p + _toolstr(ui, tool, "regappend", "")) |
6006
3c9dbb743d20
merge: add registry look up bits to tool search
Matt Mackall <mpm@selenic.com>
parents:
6005
diff
changeset
|
144 if p: |
3c9dbb743d20
merge: add registry look up bits to tool search
Matt Mackall <mpm@selenic.com>
parents:
6005
diff
changeset
|
145 return p |
15264
157d93c41c10
merge: expand environment variables and ~/ in tool.executable
Greg Ward <greg@gerg.ca>
parents:
14749
diff
changeset
|
146 exe = _toolstr(ui, tool, "executable", tool) |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
147 return procutil.findexe(util.expandpath(exe)) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
148 |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
149 def _picktool(repo, ui, path, binary, symlink, changedelete): |
39162
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
150 strictcheck = ui.configbool('merge', 'strict-capability-check') |
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
151 |
39160
4d7b11877dd0
filemerge: add the function to examine a capability of a internal tool
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39159
diff
changeset
|
152 def hascapability(tool, capability, strict=False): |
39293
82555d7186d0
filemerge: make capability check for internal tools ignore merge-tools section
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39163
diff
changeset
|
153 if tool in internals: |
82555d7186d0
filemerge: make capability check for internal tools ignore merge-tools section
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39163
diff
changeset
|
154 return strict and internals[tool].capabilities.get(capability) |
39160
4d7b11877dd0
filemerge: add the function to examine a capability of a internal tool
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39159
diff
changeset
|
155 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:
39159
diff
changeset
|
156 |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
157 def supportscd(tool): |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
158 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
|
159 |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
160 def check(tool, pat, symlink, binary, changedelete): |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
161 tmsg = tool |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
162 if pat: |
32294
177742666abd
filemerge: make warning message more i18n friendly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32293
diff
changeset
|
163 tmsg = _("%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
|
164 if not _findtool(ui, tool): |
4c92d8971809
More verbose logging when filemerge searches for merge-tool
Mads Kiilerich <mads@kiilerich.com>
parents:
6762
diff
changeset
|
165 if pat: # explicitly requested tool deserves a warning |
4c92d8971809
More verbose logging when filemerge searches for merge-tool
Mads Kiilerich <mads@kiilerich.com>
parents:
6762
diff
changeset
|
166 ui.warn(_("couldn't find merge tool %s\n") % tmsg) |
4c92d8971809
More verbose logging when filemerge searches for merge-tool
Mads Kiilerich <mads@kiilerich.com>
parents:
6762
diff
changeset
|
167 else: # configured but non-existing tools are more silent |
4c92d8971809
More verbose logging when filemerge searches for merge-tool
Mads Kiilerich <mads@kiilerich.com>
parents:
6762
diff
changeset
|
168 ui.note(_("couldn't find merge tool %s\n") % tmsg) |
39162
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
169 elif symlink and not hascapability(tool, "symlink", strictcheck): |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
170 ui.warn(_("tool %s can't handle symlinks\n") % tmsg) |
39162
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
171 elif binary and not hascapability(tool, "binary", strictcheck): |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
172 ui.warn(_("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
|
173 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
|
174 # 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
|
175 # conflicts |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
176 pass |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
177 elif not procutil.gui() and _toolbool(ui, tool, "gui"): |
6007
090b1a665901
filemerge: add config item for GUI tools
Matt Mackall <mpm@selenic.com>
parents:
6006
diff
changeset
|
178 ui.warn(_("tool %s requires a GUI\n") % tmsg) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
179 else: |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
180 return True |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
181 return False |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
182 |
25835
34ffe4c29782
filemerge: mark internal-only config option
Matt Mackall <mpm@selenic.com>
parents:
24987
diff
changeset
|
183 # internal config: ui.forcemerge |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
184 # forcemerge comes from command line arguments, highest priority |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
185 force = ui.config('ui', 'forcemerge') |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
186 if force: |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
187 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
|
188 if changedelete and not supportscd(toolpath): |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
189 return ":prompt", None |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
190 else: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
191 if toolpath: |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
192 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
|
193 else: |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
194 # 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
|
195 return (force, force) |
12788
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
196 |
de793925862e
merge: implement --tool arguments using new ui.forcemerge configurable
Steve Borho <steve@borho.org>
parents:
12047
diff
changeset
|
197 # HGMERGE takes next precedence |
30641
f1c9fafcbf46
py3: replace os.environ with encoding.environ (part 3 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30547
diff
changeset
|
198 hgmerge = encoding.environ.get("HGMERGE") |
6025
f2335246e5c7
filemerge: wrap quotes around tool path
Steve Borho <steve@borho.org>
parents:
6016
diff
changeset
|
199 if hgmerge: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
200 if changedelete and not supportscd(hgmerge): |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
201 return ":prompt", None |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
202 else: |
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
203 return (hgmerge, hgmerge) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
204 |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
205 # then patterns |
39162
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
206 |
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
207 # 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:
39161
diff
changeset
|
208 binarycap = binary and strictcheck |
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
209 |
6016
288ec2f6faa2
filemerge: fix pattern matching
dhruva <dhruvakm@gmail.com>
parents:
6015
diff
changeset
|
210 for pat, tool in ui.configitems("merge-patterns"): |
8567
fea40a677d43
match: add some default args
Matt Mackall <mpm@selenic.com>
parents:
8566
diff
changeset
|
211 mf = match.match(repo.root, '', [pat]) |
39162
cded904f7acc
filemerge: add config knob to check capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39161
diff
changeset
|
212 if mf(path) and check(tool, pat, symlink, binarycap, changedelete): |
39161
6618634e3325
filemerge: show warning if chosen tool has no binary files capability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39160
diff
changeset
|
213 if binary and not hascapability(tool, "binary", strict=True): |
6618634e3325
filemerge: show warning if chosen tool has no binary files capability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39160
diff
changeset
|
214 ui.warn(_("warning: check merge-patterns configurations," |
6618634e3325
filemerge: show warning if chosen tool has no binary files capability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39160
diff
changeset
|
215 " if %r for binary file %r is unintentional\n" |
6618634e3325
filemerge: show warning if chosen tool has no binary files capability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39160
diff
changeset
|
216 "(see 'hg help merge-tools'" |
6618634e3325
filemerge: show warning if chosen tool has no binary files capability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39160
diff
changeset
|
217 " for binary files capability)\n") |
6618634e3325
filemerge: show warning if chosen tool has no binary files capability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39160
diff
changeset
|
218 % (pycompat.bytestr(tool), pycompat.bytestr(path))) |
10339
23e608f42f2c
fix spaces/identation issues
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10282
diff
changeset
|
219 toolpath = _findtool(ui, tool) |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
220 return (tool, _quotetoolpath(toolpath)) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
221 |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
222 # then merge tools |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
223 tools = {} |
26730
a1e43e85d294
merge-tools: allow marking a mergetool as completely disabled
Augie Fackler <augie@google.com>
parents:
26614
diff
changeset
|
224 disabled = set() |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
225 for k, v in ui.configitems("merge-tools"): |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
226 t = k.split('.')[0] |
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
227 if t not in tools: |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
228 tools[t] = int(_toolstr(ui, t, "priority")) |
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
229 if _toolbool(ui, t, "disabled"): |
26730
a1e43e85d294
merge-tools: allow marking a mergetool as completely disabled
Augie Fackler <augie@google.com>
parents:
26614
diff
changeset
|
230 disabled.add(t) |
6076
0ee885fea464
filemerge: more backwards compatible behavior for ui.merge
Steve Borho <steve@borho.org>
parents:
6075
diff
changeset
|
231 names = tools.keys() |
30398
8819b63732b9
filemerge: avoid shadowing a variable in a list comprehension
Augie Fackler <augie@google.com>
parents:
30073
diff
changeset
|
232 tools = sorted([(-p, tool) for tool, p in tools.items() |
8819b63732b9
filemerge: avoid shadowing a variable in a list comprehension
Augie Fackler <augie@google.com>
parents:
30073
diff
changeset
|
233 if tool not in disabled]) |
6076
0ee885fea464
filemerge: more backwards compatible behavior for ui.merge
Steve Borho <steve@borho.org>
parents:
6075
diff
changeset
|
234 uimerge = ui.config("ui", "merge") |
0ee885fea464
filemerge: more backwards compatible behavior for ui.merge
Steve Borho <steve@borho.org>
parents:
6075
diff
changeset
|
235 if uimerge: |
27039
d7517deedf86
filemerge._picktool: only pick from nomerge tools for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27038
diff
changeset
|
236 # 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
|
237 # change/delete conflicts |
38990
0e58c5b20745
mergetool: warn if ui.merge points to nonexistent tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
38833
diff
changeset
|
238 if check(uimerge, path, symlink, binary, changedelete): |
0e58c5b20745
mergetool: warn if ui.merge points to nonexistent tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
38833
diff
changeset
|
239 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:
38833
diff
changeset
|
240 return (uimerge, uimerge) |
0e58c5b20745
mergetool: warn if ui.merge points to nonexistent tool
Martin von Zweigbergk <martinvonz@google.com>
parents:
38833
diff
changeset
|
241 tools.insert(0, (None, uimerge)) # highest priority |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
242 tools.append((None, "hgmerge")) # the old default, if found |
10282
08a0f04b56bd
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
10263
diff
changeset
|
243 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
|
244 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
|
245 toolpath = _findtool(ui, t) |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
246 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
|
247 |
c7eef052c9e3
filemerge: restore default prompt for binary/symlink lost in 83925d3a4559
Matt Mackall <mpm@selenic.com>
parents:
16205
diff
changeset
|
248 # 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
|
249 if symlink or binary or changedelete: |
32293
7d4ce4b567c5
filemerge: show warning about choice of :prompt only at an actual fallback
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32047
diff
changeset
|
250 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
|
251 # any tool is rejected by capability for symlink or binary |
7d4ce4b567c5
filemerge: show warning about choice of :prompt only at an actual fallback
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32047
diff
changeset
|
252 ui.warn(_("no tool found to merge %s\n") % path) |
22707
38e0363dcbe0
filemerge: switch the default name for internal tools from internal:x to :x
Mads Kiilerich <madski@unity3d.com>
parents:
22706
diff
changeset
|
253 return ":prompt", None |
38e0363dcbe0
filemerge: switch the default name for internal tools from internal:x to :x
Mads Kiilerich <madski@unity3d.com>
parents:
22706
diff
changeset
|
254 return ":merge", None |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
255 |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
256 def _eoltype(data): |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
257 "Guess the EOL type of a file" |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
258 if '\0' in data: # binary |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
259 return None |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
260 if '\r\n' in data: # Windows |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
261 return '\r\n' |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
262 if '\r' in data: # Old Mac |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
263 return '\r' |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
264 if '\n' in data: # UNIX |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
265 return '\n' |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
266 return None # unknown |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
267 |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
268 def _matcheol(file, back): |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
269 "Convert EOL markers in a file to match origfile" |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
270 tostyle = _eoltype(back.data()) # No repo.wread filters? |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
271 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
|
272 data = util.readfile(file) |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
273 style = _eoltype(data) |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
274 if style: |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
275 newdata = data.replace(style, tostyle) |
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
276 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
|
277 util.writefile(file, newdata) |
6005
3c33032d8906
merge: add support for tool EOL fixups
Matt Mackall <mpm@selenic.com>
parents:
6004
diff
changeset
|
278 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
279 @internaltool('prompt', nomerge) |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
280 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
281 """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
|
282 keep as the merged version.""" |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
283 ui = repo.ui |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
284 fd = fcd.path() |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
285 uipathfn = scmutil.getuipathfn(repo) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
286 |
35291
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
287 # 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:
35290
diff
changeset
|
288 # conflicts. |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
289 if fcd.changectx().isinmemory(): |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
290 raise error.InMemoryMergeConflictsError('in-memory merge does not ' |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
291 'support file conflicts') |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
292 |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
293 prompts = partextras(labels) |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
294 prompts['fd'] = uipathfn(fd) |
26898
33eb8a56d0c9
filemerge: treat EOF at prompt as fail, not abort
Siddharth Agarwal <sid0@fb.com>
parents:
26893
diff
changeset
|
295 try: |
27038
58a4eb16e722
filemerge: add support for change/delete conflicts to the ':prompt' tool
Siddharth Agarwal <sid0@fb.com>
parents:
27037
diff
changeset
|
296 if fco.isabsent(): |
58a4eb16e722
filemerge: add support for change/delete conflicts to the ':prompt' tool
Siddharth Agarwal <sid0@fb.com>
parents:
27037
diff
changeset
|
297 index = ui.promptchoice( |
32357
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
298 _localchangedotherdeletedmsg % prompts, 2) |
27163
27b89a0957ec
filemerge: add a 'leave unresolved' option to change/delete prompts
Siddharth Agarwal <sid0@fb.com>
parents:
27162
diff
changeset
|
299 choice = ['local', 'other', 'unresolved'][index] |
27038
58a4eb16e722
filemerge: add support for change/delete conflicts to the ':prompt' tool
Siddharth Agarwal <sid0@fb.com>
parents:
27037
diff
changeset
|
300 elif fcd.isabsent(): |
58a4eb16e722
filemerge: add support for change/delete conflicts to the ':prompt' tool
Siddharth Agarwal <sid0@fb.com>
parents:
27037
diff
changeset
|
301 index = ui.promptchoice( |
32357
6587427b2018
filemerge: store error messages in module variables
Stanislau Hlebik <stash@fb.com>
parents:
32295
diff
changeset
|
302 _otherchangedlocaldeletedmsg % prompts, 2) |
27163
27b89a0957ec
filemerge: add a 'leave unresolved' option to change/delete prompts
Siddharth Agarwal <sid0@fb.com>
parents:
27162
diff
changeset
|
303 choice = ['other', 'local', 'unresolved'][index] |
27038
58a4eb16e722
filemerge: add support for change/delete conflicts to the ':prompt' tool
Siddharth Agarwal <sid0@fb.com>
parents:
27037
diff
changeset
|
304 else: |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
305 # 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:
41613
diff
changeset
|
306 # 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:
41613
diff
changeset
|
307 # 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
|
308 index = ui.promptchoice( |
42565
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
309 _("file '%(fd)s' needs to be resolved.\n" |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
310 "You can keep (l)ocal%(l)s, take (o)ther%(o)s, or leave " |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
311 "(u)nresolved.\n" |
4764e8436b2a
filemerge: make last line of prompts <40 english chars (issue6158)
Kyle Lippincott <spectral@google.com>
parents:
41613
diff
changeset
|
312 "What do you want to do?" |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
313 "$$ &Local $$ &Other $$ &Unresolved") % prompts, 2) |
27162
4ab69be0ea15
filemerge: add a 'leave unresolved' option to regular prompts
Siddharth Agarwal <sid0@fb.com>
parents:
27161
diff
changeset
|
314 choice = ['local', 'other', 'unresolved'][index] |
26851
859f453e8b4e
filemerge.prompt: separate out choice selection and action
Siddharth Agarwal <sid0@fb.com>
parents:
26730
diff
changeset
|
315 |
26898
33eb8a56d0c9
filemerge: treat EOF at prompt as fail, not abort
Siddharth Agarwal <sid0@fb.com>
parents:
26893
diff
changeset
|
316 if choice == 'other': |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
317 return _iother(repo, mynode, orig, fcd, fco, fca, toolconf, |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
318 labels) |
27162
4ab69be0ea15
filemerge: add a 'leave unresolved' option to regular prompts
Siddharth Agarwal <sid0@fb.com>
parents:
27161
diff
changeset
|
319 elif choice == 'local': |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
320 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
321 labels) |
27162
4ab69be0ea15
filemerge: add a 'leave unresolved' option to regular prompts
Siddharth Agarwal <sid0@fb.com>
parents:
27161
diff
changeset
|
322 elif choice == 'unresolved': |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
323 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
324 labels) |
26898
33eb8a56d0c9
filemerge: treat EOF at prompt as fail, not abort
Siddharth Agarwal <sid0@fb.com>
parents:
26893
diff
changeset
|
325 except error.ResponseExpected: |
33eb8a56d0c9
filemerge: treat EOF at prompt as fail, not abort
Siddharth Agarwal <sid0@fb.com>
parents:
26893
diff
changeset
|
326 ui.write("\n") |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
327 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
328 labels) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
329 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
330 @internaltool('local', nomerge) |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
331 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
332 """Uses the local `p1()` version of files as the merged version.""" |
27036
63d6bc874dea
filemerge: add support for change/delete conflicts to the ':local' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27034
diff
changeset
|
333 return 0, fcd.isabsent() |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
334 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
335 @internaltool('other', nomerge) |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
336 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): |
28640
4fc640fd0026
filemerge: use revset notation for p1/p2 of local/other descriptions
timeless <timeless@mozdev.org>
parents:
28578
diff
changeset
|
337 """Uses the other `p2()` version of files as the merged version.""" |
27037
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
338 if fco.isabsent(): |
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
339 # local changed, remote deleted -- 'deleted' picked |
33157
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
340 _underlyingfctxifabsent(fcd).remove() |
27037
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
341 deleted = True |
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
342 else: |
33157
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
343 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags()) |
27037
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
344 deleted = False |
a8908c139f2f
filemerge: add support for change/delete conflicts to the ':other' merge tool
Siddharth Agarwal <sid0@fb.com>
parents:
27036
diff
changeset
|
345 return 0, deleted |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
346 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
347 @internaltool('fail', nomerge) |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
348 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None): |
16127
14dc2bbba6d2
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall <mpm@selenic.com>
parents:
16126
diff
changeset
|
349 """ |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
350 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
|
351 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
|
352 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
|
353 # for change/delete conflicts write out the changed version, then fail |
4dc5951df1e4
filemerge: in ':fail' tool, write out other side if local side is deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27047
diff
changeset
|
354 if fcd.isabsent(): |
33157
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
355 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags()) |
27032
28ee7af4b685
filemerge: return whether the file is deleted for nomerge internal tools
Siddharth Agarwal <sid0@fb.com>
parents:
26979
diff
changeset
|
356 return 1, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
357 |
33157
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
358 def _underlyingfctxifabsent(filectx): |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
359 """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:
32891
diff
changeset
|
360 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:
32891
diff
changeset
|
361 underyling workingfilectx in that case. |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
362 """ |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
363 if filectx.isabsent(): |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
364 return filectx.changectx()[filectx.path()] |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
365 else: |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
366 return filectx |
851825214aa3
filemerge: convert a couple of wvfs calls in internal mergetools to contexts
Phil Cohen <phillco@fb.com>
parents:
32891
diff
changeset
|
367 |
27041
0e330f59ef68
filemerge: don't attempt to premerge change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27040
diff
changeset
|
368 def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None): |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
369 tool, toolpath, binary, symlink, scriptfn = toolconf |
27041
0e330f59ef68
filemerge: don't attempt to premerge change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27040
diff
changeset
|
370 if symlink or fcd.isabsent() or fco.isabsent(): |
18257
a35d0128545e
merge: never do premerge on symlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
18256
diff
changeset
|
371 return 1 |
34049
67cfffbfb6a0
filemerge: eliminate most uses of tempfiles
Phil Cohen <phillco@fb.com>
parents:
34048
diff
changeset
|
372 unused, unused, unused, back = files |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
373 |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
374 ui = repo.ui |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
375 |
22032
d7f25834ffbb
merge-tools: add a `premerge=keep-merge3` config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22031
diff
changeset
|
376 validkeep = ['keep', 'keep-merge3'] |
22031
b36c60cfe46f
merge-tools: make premerge valid values extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22028
diff
changeset
|
377 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
378 # do we attempt to simplemerge first? |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
379 try: |
18257
a35d0128545e
merge: never do premerge on symlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
18256
diff
changeset
|
380 premerge = _toolbool(ui, tool, "premerge", not binary) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
381 except error.ConfigError: |
34826
18a3274ed675
configitems: register the full 'merge-tools' config and sub-options
Boris Feld <boris.feld@octobus.net>
parents:
34797
diff
changeset
|
382 premerge = _toolstr(ui, tool, "premerge", "").lower() |
22031
b36c60cfe46f
merge-tools: make premerge valid values extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22028
diff
changeset
|
383 if premerge not in validkeep: |
b36c60cfe46f
merge-tools: make premerge valid values extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22028
diff
changeset
|
384 _valid = ', '.join(["'" + v + "'" for v in validkeep]) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
385 raise error.ConfigError(_("%s.premerge not valid " |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
386 "('%s' is neither boolean nor %s)") % |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
387 (tool, premerge, _valid)) |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
388 |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
389 if premerge: |
22032
d7f25834ffbb
merge-tools: add a `premerge=keep-merge3` config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22031
diff
changeset
|
390 if premerge == 'keep-merge3': |
d7f25834ffbb
merge-tools: add a `premerge=keep-merge3` config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22031
diff
changeset
|
391 if not labels: |
d7f25834ffbb
merge-tools: add a `premerge=keep-merge3` config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22031
diff
changeset
|
392 labels = _defaultconflictlabels |
d7f25834ffbb
merge-tools: add a `premerge=keep-merge3` config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22031
diff
changeset
|
393 if len(labels) < 3: |
d7f25834ffbb
merge-tools: add a `premerge=keep-merge3` config option
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22031
diff
changeset
|
394 labels.append('base') |
34066
6330df9d6393
simplemerge: remove unused `repo` parameter
Phil Cohen <phillco@fb.com>
parents:
34053
diff
changeset
|
395 r = simplemerge.simplemerge(ui, fcd, fca, fco, quiet=True, label=labels) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
396 if not r: |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
397 ui.debug(" premerge successful\n") |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
398 return 0 |
22031
b36c60cfe46f
merge-tools: make premerge valid values extensible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22028
diff
changeset
|
399 if premerge not in validkeep: |
34049
67cfffbfb6a0
filemerge: eliminate most uses of tempfiles
Phil Cohen <phillco@fb.com>
parents:
34048
diff
changeset
|
400 # restore from backup and try again |
34053
fe04c018eaac
filemerge: add _restorebackup
Phil Cohen <phillco@fb.com>
parents:
34052
diff
changeset
|
401 _restorebackup(fcd, back) |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
402 return 1 # continue merging |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
403 |
26948
067ab07435c9
filemerge: rename _symlinkcheck to _mergecheck
Siddharth Agarwal <sid0@fb.com>
parents:
26941
diff
changeset
|
404 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
405 tool, toolpath, binary, symlink, scriptfn = toolconf |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
406 uipathfn = scmutil.getuipathfn(repo) |
26515
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
407 if symlink: |
26518
a77679d0b887
filemerge: print correct name of tool for symlink checks
Siddharth Agarwal <sid0@fb.com>
parents:
26517
diff
changeset
|
408 repo.ui.warn(_('warning: internal %s cannot merge symlinks ' |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
409 'for %s\n') % (tool, uipathfn(fcd.path()))) |
26515
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
410 return False |
27040
1bde66b89bb2
filemerge._mergecheck: add check for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27039
diff
changeset
|
411 if fcd.isabsent() or fco.isabsent(): |
1bde66b89bb2
filemerge._mergecheck: add check for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27039
diff
changeset
|
412 repo.ui.warn(_('warning: internal %s cannot merge change/delete ' |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
413 'conflict for %s\n') % (tool, uipathfn(fcd.path()))) |
27040
1bde66b89bb2
filemerge._mergecheck: add check for change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27039
diff
changeset
|
414 return False |
26515
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
415 return True |
0ffa7fe1076b
filemerge: add a precheck for symlinks
Siddharth Agarwal <sid0@fb.com>
parents:
26514
diff
changeset
|
416 |
26070
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
417 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode): |
16127
14dc2bbba6d2
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall <mpm@selenic.com>
parents:
16126
diff
changeset
|
418 """ |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
419 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
|
420 files. It will fail if there are any conflicts and leave markers in |
22027
b98e5c7afc70
internal:merge: update documentation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22026
diff
changeset
|
421 the partially merged file. Markers will have two sections, one for each side |
26070
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
422 of merge, unless mode equals 'union' which suppresses the markers.""" |
26572
c7850af6bb75
filemerge._merge: drop no longer necessary 'if r:' check
Siddharth Agarwal <sid0@fb.com>
parents:
26567
diff
changeset
|
423 ui = repo.ui |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
424 |
34066
6330df9d6393
simplemerge: remove unused `repo` parameter
Phil Cohen <phillco@fb.com>
parents:
34053
diff
changeset
|
425 r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
426 return True, r, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
427 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
428 @internaltool('union', fullmerge, |
26614
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26613
diff
changeset
|
429 _("warning: conflicts while merging %s! " |
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26613
diff
changeset
|
430 "(edit, then use 'hg resolve --mark')\n"), |
26948
067ab07435c9
filemerge: rename _symlinkcheck to _mergecheck
Siddharth Agarwal <sid0@fb.com>
parents:
26941
diff
changeset
|
431 precheck=_mergecheck) |
26071
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
432 def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
433 """ |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
434 Uses the internal non-interactive simple merge algorithm for merging |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
435 files. It will use both left and right sides for conflict regions. |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
436 No markers are inserted.""" |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
437 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf, |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
438 files, labels, 'union') |
ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
Erik Huelsmann <ehuels@gmail.com>
parents:
26070
diff
changeset
|
439 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
440 @internaltool('merge', fullmerge, |
26614
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26613
diff
changeset
|
441 _("warning: conflicts while merging %s! " |
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26613
diff
changeset
|
442 "(edit, then use 'hg resolve --mark')\n"), |
26948
067ab07435c9
filemerge: rename _symlinkcheck to _mergecheck
Siddharth Agarwal <sid0@fb.com>
parents:
26941
diff
changeset
|
443 precheck=_mergecheck) |
26070
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
444 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
445 """ |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 of merge.""" |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
450 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf, |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
451 files, labels, 'merge') |
e15966216aec
filemerge: split internal merge into api entry point and internal helper
Erik Huelsmann <ehuels@gmail.com>
parents:
25949
diff
changeset
|
452 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
453 @internaltool('merge3', fullmerge, |
26614
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26613
diff
changeset
|
454 _("warning: conflicts while merging %s! " |
ef1eb6df7071
simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26613
diff
changeset
|
455 "(edit, then use 'hg resolve --mark')\n"), |
26948
067ab07435c9
filemerge: rename _symlinkcheck to _mergecheck
Siddharth Agarwal <sid0@fb.com>
parents:
26941
diff
changeset
|
456 precheck=_mergecheck) |
22028
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
457 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
458 """ |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
459 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
|
460 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
|
461 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
|
462 side of the merge and one for the base content.""" |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
463 if not labels: |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
464 labels = _defaultconflictlabels |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
465 if len(labels) < 3: |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
466 labels.append('base') |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
467 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels) |
3d0572ab3b4a
merge: add an internal:merge3 tool
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
22027
diff
changeset
|
468 |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
469 def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files, |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
470 labels=None, localorother=None): |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
471 """ |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
472 Generic driver for _imergelocal and _imergeother |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
473 """ |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
474 assert localorother is not None |
34066
6330df9d6393
simplemerge: remove unused `repo` parameter
Phil Cohen <phillco@fb.com>
parents:
34053
diff
changeset
|
475 r = simplemerge.simplemerge(repo.ui, fcd, fca, fco, label=labels, |
6330df9d6393
simplemerge: remove unused `repo` parameter
Phil Cohen <phillco@fb.com>
parents:
34053
diff
changeset
|
476 localorother=localorother) |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
477 return True, r |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
478 |
26948
067ab07435c9
filemerge: rename _symlinkcheck to _mergecheck
Siddharth Agarwal <sid0@fb.com>
parents:
26941
diff
changeset
|
479 @internaltool('merge-local', mergeonly, precheck=_mergecheck) |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
480 def _imergelocal(*args, **kwargs): |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
481 """ |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
482 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
|
483 of the local `p1()` changes.""" |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
484 success, status = _imergeauto(localorother='local', *args, **kwargs) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
485 return success, status, False |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
486 |
26948
067ab07435c9
filemerge: rename _symlinkcheck to _mergecheck
Siddharth Agarwal <sid0@fb.com>
parents:
26941
diff
changeset
|
487 @internaltool('merge-other', mergeonly, precheck=_mergecheck) |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
488 def _imergeother(*args, **kwargs): |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
489 """ |
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
490 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
|
491 of the other `p2()` changes.""" |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
492 success, status = _imergeauto(localorother='other', *args, **kwargs) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
493 return success, status, False |
26224
a4da463df6cf
filemerge: add non-interactive :merge-local and :merge-other
Jordi Guti?rrez Hermoso <jordigh@octave.org>
parents:
26071
diff
changeset
|
494 |
26526
7fa3560443fd
filemerge: switch trymerge boolean to mergetype enum
Siddharth Agarwal <sid0@fb.com>
parents:
26525
diff
changeset
|
495 @internaltool('tagmerge', mergeonly, |
21922
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
496 _("automatic tag merging of %s failed! " |
22707
38e0363dcbe0
filemerge: switch the default name for internal tools from internal:x to :x
Mads Kiilerich <madski@unity3d.com>
parents:
22706
diff
changeset
|
497 "(use 'hg resolve --tool :merge' or another merge " |
21922
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
498 "tool of your choice)\n")) |
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
499 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
500 """ |
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
501 Uses the internal tag merge algorithm (experimental). |
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
502 """ |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
503 success, status = tagmerge.merge(repo, fcd, fco, fca) |
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
504 return success, status, False |
21922
50e20154cb68
filemerge: add internal:tagmerge merge tool
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21921
diff
changeset
|
505 |
39159
5d3b58472660
filemerge: set actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
38990
diff
changeset
|
506 @internaltool('dump', fullmerge, binary=True, symlink=True) |
21273
20b8090d8125
merge: define conflict marker labels in filemerge()
Durham Goode <durham@fb.com>
parents:
21100
diff
changeset
|
507 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
16127
14dc2bbba6d2
filemerge: remove some redundancy in decorators/docstrings
Matt Mackall <mpm@selenic.com>
parents:
16126
diff
changeset
|
508 """ |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
509 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
|
510 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
|
511 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
|
512 ``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
|
513 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the |
32295
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
514 same directory as ``a.txt``. |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
515 |
34915
cab34bda259e
help: fix typo in hg merge documentation
Joe Blaylock <jrbl@google.com>
parents:
34826
diff
changeset
|
516 This implies premerge. Therefore, files aren't dumped, if premerge |
32295
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
517 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:
32294
diff
changeset
|
518 """ |
34051
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
519 a = _workingpath(repo, fcd) |
26573
a875773cf537
filemerge._idump: drop no longer necessary 'if r:' check
Siddharth Agarwal <sid0@fb.com>
parents:
26572
diff
changeset
|
520 fd = fcd.path() |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
521 |
34785
1af4561b6bfe
filemerge: add a missing flushall()
Phil Cohen <phillco@fb.com>
parents:
34784
diff
changeset
|
522 from . import context |
1af4561b6bfe
filemerge: add a missing flushall()
Phil Cohen <phillco@fb.com>
parents:
34784
diff
changeset
|
523 if isinstance(fcd, context.overlayworkingfilectx): |
35291
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
524 raise error.InMemoryMergeConflictsError('in-memory merge does not ' |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
525 'support the :dump tool.') |
34785
1af4561b6bfe
filemerge: add a missing flushall()
Phil Cohen <phillco@fb.com>
parents:
34784
diff
changeset
|
526 |
34093
cd38b83bfb23
filemerge: use fctx.write() in the internal:dump tool, instead of copy
Phil Cohen <phillco@fb.com>
parents:
34066
diff
changeset
|
527 util.writefile(a + ".local", fcd.decodeddata()) |
26573
a875773cf537
filemerge._idump: drop no longer necessary 'if r:' check
Siddharth Agarwal <sid0@fb.com>
parents:
26572
diff
changeset
|
528 repo.wwrite(fd + ".other", fco.data(), fco.flags()) |
a875773cf537
filemerge._idump: drop no longer necessary 'if r:' check
Siddharth Agarwal <sid0@fb.com>
parents:
26572
diff
changeset
|
529 repo.wwrite(fd + ".base", fca.data(), fca.flags()) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
530 return False, 1, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
531 |
39159
5d3b58472660
filemerge: set actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
38990
diff
changeset
|
532 @internaltool('forcedump', mergeonly, binary=True, symlink=True) |
32295
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
533 def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files, |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
534 labels=None): |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
535 """ |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
536 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:
32294
diff
changeset
|
537 """ |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
538 return _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
539 labels=labels) |
7e35d31b41fd
filemerge: add internal merge tool to dump files forcibly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
32294
diff
changeset
|
540 |
35467
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
541 def _xmergeimm(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
542 # 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:
35291
diff
changeset
|
543 # for now. |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
544 # |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
545 # 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:
35291
diff
changeset
|
546 # 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:
35291
diff
changeset
|
547 # 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:
35291
diff
changeset
|
548 # 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:
35291
diff
changeset
|
549 # clunky.) |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
550 raise error.InMemoryMergeConflictsError('in-memory merge does not support ' |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
551 'external merge tools') |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
552 |
40528
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
553 def _describemerge(ui, repo, mynode, fcl, fcb, fco, env, toolpath, args): |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
554 tmpl = ui.config('ui', 'pre-merge-tool-output-template') |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
555 if not tmpl: |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
556 return |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
557 |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
558 mappingdict = templateutil.mappingdict |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
559 props = {'ctx': fcl.changectx(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
560 'node': hex(mynode), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
561 'path': fcl.path(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
562 'local': mappingdict({'ctx': fcl.changectx(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
563 'fctx': fcl, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
564 'node': hex(mynode), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
565 'name': _('local'), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
566 'islink': 'l' in fcl.flags(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
567 'label': env['HG_MY_LABEL']}), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
568 'base': mappingdict({'ctx': fcb.changectx(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
569 'fctx': fcb, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
570 'name': _('base'), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
571 'islink': 'l' in fcb.flags(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
572 'label': env['HG_BASE_LABEL']}), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
573 'other': mappingdict({'ctx': fco.changectx(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
574 'fctx': fco, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
575 'name': _('other'), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
576 'islink': 'l' in fco.flags(), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
577 'label': env['HG_OTHER_LABEL']}), |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
578 'toolpath': toolpath, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
579 'toolargs': args} |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
580 |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
581 # 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:
39386
diff
changeset
|
582 tmpl = templater.unquotestring(tmpl) |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
583 |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
584 # 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:
39386
diff
changeset
|
585 # things for us to import cmdutil. |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
586 tres = formatter.templateresources(ui, repo) |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
587 t = formatter.maketemplater(ui, tmpl, defaults=templatekw.keywords, |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
588 resources=tres) |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
589 ui.status(t.renderdefault(props)) |
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
590 |
21273
20b8090d8125
merge: define conflict marker labels in filemerge()
Durham Goode <durham@fb.com>
parents:
21100
diff
changeset
|
591 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
592 tool, toolpath, binary, symlink, scriptfn = toolconf |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
593 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
|
594 if fcd.isabsent() or fco.isabsent(): |
30b919bc49bf
filemerge: don't try using external tools on change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27041
diff
changeset
|
595 repo.ui.warn(_('warning: %s cannot merge change/delete conflict ' |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
596 'for %s\n') % (tool, uipathfn(fcd.path()))) |
27042
30b919bc49bf
filemerge: don't try using external tools on change/delete conflicts
Siddharth Agarwal <sid0@fb.com>
parents:
27041
diff
changeset
|
597 return False, 1, None |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
598 unused, unused, unused, back = files |
36982
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36843
diff
changeset
|
599 localpath = _workingpath(repo, fcd) |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
600 args = _toolstr(repo.ui, tool, "args") |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
601 |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
602 with _maketempfiles(repo, fco, fca, repo.wvfs.join(back.path()), |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
603 "$output" in args) as temppaths: |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
604 basepath, otherpath, localoutputpath = temppaths |
36982
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36843
diff
changeset
|
605 outpath = "" |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
606 mylabel, otherlabel = labels[:2] |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
607 if len(labels) >= 3: |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
608 baselabel = labels[2] |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
609 else: |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
610 baselabel = 'base' |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
611 env = {'HG_FILE': fcd.path(), |
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
612 'HG_MY_NODE': short(mynode), |
36454
3ab9d74dd1c5
filemerge: do what the context __bytes__ does, but locally
Augie Fackler <augie@google.com>
parents:
35947
diff
changeset
|
613 'HG_OTHER_NODE': short(fco.changectx().node()), |
3ab9d74dd1c5
filemerge: do what the context __bytes__ does, but locally
Augie Fackler <augie@google.com>
parents:
35947
diff
changeset
|
614 'HG_BASE_NODE': short(fca.changectx().node()), |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
615 'HG_MY_ISLINK': 'l' in fcd.flags(), |
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
616 'HG_OTHER_ISLINK': 'l' in fco.flags(), |
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
617 'HG_BASE_ISLINK': 'l' in fca.flags(), |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
618 'HG_MY_LABEL': mylabel, |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
619 'HG_OTHER_LABEL': otherlabel, |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
620 'HG_BASE_LABEL': baselabel, |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
621 } |
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
622 ui = repo.ui |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
623 |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
624 if "$output" in args: |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
625 # read input from backup, write to original |
36982
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36843
diff
changeset
|
626 outpath = localpath |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
627 localpath = localoutputpath |
36982
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36843
diff
changeset
|
628 replace = {'local': localpath, 'base': basepath, 'other': otherpath, |
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36843
diff
changeset
|
629 'output': outpath, 'labellocal': mylabel, |
a4a95bd7158d
filemerge: give some variables in _xmerge more descriptive names
Kyle Lippincott <spectral@google.com>
parents:
36843
diff
changeset
|
630 'labelother': otherlabel, 'labelbase': baselabel} |
37123
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
631 args = util.interpolate( |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
632 br'\$', replace, args, |
a8a902d7176e
procutil: bulk-replace function calls to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37087
diff
changeset
|
633 lambda s: procutil.shellquote(util.localpath(s))) |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
634 if _toolbool(ui, tool, "gui"): |
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
635 repo.ui.status(_('running merge tool %s for file %s\n') % |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
636 (tool, uipathfn(fcd.path()))) |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
637 if scriptfn is None: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
638 cmd = toolpath + ' ' + args |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
639 repo.ui.debug('launching merge tool: %s\n' % cmd) |
40528
86dfae98a3a2
merge-tools: when calling external merge tool, describe the resolve inputs
Kyle Lippincott <spectral@google.com>
parents:
39386
diff
changeset
|
640 _describemerge(ui, repo, mynode, fcd, fca, fco, env, toolpath, args) |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
641 r = ui.system(cmd, cwd=repo.root, environ=env, |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
642 blockedtag='mergetool') |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
643 else: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
644 repo.ui.debug('launching python merge script: %s:%s\n' % |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
645 (toolpath, scriptfn)) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
646 r = 0 |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
647 try: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
648 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
649 from . import extensions |
38192
dea3903175ee
filemerge: don't pass function name as loadpath's module_name param
hindlemail <tom_hindle@sil.org>
parents:
38074
diff
changeset
|
650 mod = extensions.loadpath(toolpath, 'hgmerge.%s' % tool) |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
651 except Exception: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
652 raise error.Abort(_("loading python merge script failed: %s") % |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
653 toolpath) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
654 mergefn = getattr(mod, scriptfn, None) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
655 if mergefn is None: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
656 raise error.Abort(_("%s does not have function: %s") % |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
657 (toolpath, scriptfn)) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
658 argslist = procutil.shellsplit(args) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
659 # 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:
37123
diff
changeset
|
660 from . import hook |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
661 ret, raised = hook.pythonhook(ui, repo, "merge", toolpath, |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
662 mergefn, {'args': argslist}, True) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
663 if raised: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
664 r = 1 |
34506
1d804c22c671
py3: use '%d' for integers instead of '%s'
Pulkit Goyal <7895pulkit@gmail.com>
parents:
34138
diff
changeset
|
665 repo.ui.debug('merge tool returned: %d\n' % r) |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
666 return True, r, False |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
667 |
35486
c240657febb7
templater: drop unneeded resources from conflict-marker data
Yuya Nishihara <yuya@tcha.org>
parents:
35473
diff
changeset
|
668 def _formatconflictmarker(ctx, template, label, pad): |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
669 """Applies the given template to the ctx, prefixed by the label. |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
670 |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
671 Pad is the minimum width of the label prefix, so that multiple markers |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
672 can have aligned templated parts. |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
673 """ |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
674 if ctx.node() is None: |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
675 ctx = ctx.p1() |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
676 |
35487
817a3d20dd01
templater: register keywords to defaults table
Yuya Nishihara <yuya@tcha.org>
parents:
35486
diff
changeset
|
677 props = {'ctx': ctx} |
36991
317382151ac3
templater: rename .render(mapping) to .renderdefault(mapping) (API)
Yuya Nishihara <yuya@tcha.org>
parents:
36982
diff
changeset
|
678 templateresult = template.renderdefault(props) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
679 |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
680 label = ('%s:' % label).ljust(pad + 1) |
32891
2ecce24dfcd3
templater: add simple interface for unnamed template (API)
Yuya Nishihara <yuya@tcha.org>
parents:
32773
diff
changeset
|
681 mark = '%s %s' % (label, templateresult) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
682 |
21864
755bf1bbe0a9
filemerge: use only the first line of the generated conflict marker for safety
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21693
diff
changeset
|
683 if mark: |
755bf1bbe0a9
filemerge: use only the first line of the generated conflict marker for safety
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21693
diff
changeset
|
684 mark = mark.splitlines()[0] # split for safety |
755bf1bbe0a9
filemerge: use only the first line of the generated conflict marker for safety
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21693
diff
changeset
|
685 |
21865
78e56e70c70a
filemerge: use 'util.ellipsis' to trim custom conflict markers correctly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21864
diff
changeset
|
686 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') |
37087
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37080
diff
changeset
|
687 return stringutil.ellipsis(mark, 80 - 8) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
688 |
21524
47b97d9af27e
merge: add labels parameter from merge.update to filemerge
Durham Goode <durham@fb.com>
parents:
21519
diff
changeset
|
689 _defaultconflictlabels = ['local', 'other'] |
47b97d9af27e
merge: add labels parameter from merge.update to filemerge
Durham Goode <durham@fb.com>
parents:
21519
diff
changeset
|
690 |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
691 def _formatlabels(repo, fcd, fco, fca, labels, tool=None): |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
692 """Formats the given labels using the conflict marker template. |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
693 |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
694 Returns a list of formatted labels. |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
695 """ |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
696 cd = fcd.changectx() |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
697 co = fco.changectx() |
22026
6966542768ff
filemerge: allow the formatting of three labels instead of two
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22025
diff
changeset
|
698 ca = fca.changectx() |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
699 |
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
700 ui = repo.ui |
33523
11025c4f1016
configitems: register the 'ui.mergemarkertemplate' config
Boris Feld <boris.feld@octobus.net>
parents:
33499
diff
changeset
|
701 template = ui.config('ui', 'mergemarkertemplate') |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
702 if tool is not None: |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
703 template = _toolstr(ui, tool, 'mergemarkertemplate', template) |
32047
458f7294dfee
filemerge: optionally strip quotes from merge marker template (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
31445
diff
changeset
|
704 template = templater.unquotestring(template) |
35473
f1c54d003327
templater: move repo, ui and cache to per-engine resources
Yuya Nishihara <yuya@tcha.org>
parents:
35467
diff
changeset
|
705 tres = formatter.templateresources(ui, repo) |
35487
817a3d20dd01
templater: register keywords to defaults table
Yuya Nishihara <yuya@tcha.org>
parents:
35486
diff
changeset
|
706 tmpl = formatter.maketemplater(ui, template, defaults=templatekw.keywords, |
817a3d20dd01
templater: register keywords to defaults table
Yuya Nishihara <yuya@tcha.org>
parents:
35486
diff
changeset
|
707 resources=tres) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
708 |
22026
6966542768ff
filemerge: allow the formatting of three labels instead of two
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22025
diff
changeset
|
709 pad = max(len(l) for l in labels) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
710 |
35486
c240657febb7
templater: drop unneeded resources from conflict-marker data
Yuya Nishihara <yuya@tcha.org>
parents:
35473
diff
changeset
|
711 newlabels = [_formatconflictmarker(cd, tmpl, labels[0], pad), |
c240657febb7
templater: drop unneeded resources from conflict-marker data
Yuya Nishihara <yuya@tcha.org>
parents:
35473
diff
changeset
|
712 _formatconflictmarker(co, tmpl, labels[1], pad)] |
22026
6966542768ff
filemerge: allow the formatting of three labels instead of two
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22025
diff
changeset
|
713 if len(labels) > 2: |
35486
c240657febb7
templater: drop unneeded resources from conflict-marker data
Yuya Nishihara <yuya@tcha.org>
parents:
35473
diff
changeset
|
714 newlabels.append(_formatconflictmarker(ca, tmpl, labels[2], pad)) |
22026
6966542768ff
filemerge: allow the formatting of three labels instead of two
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22025
diff
changeset
|
715 return newlabels |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
716 |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
717 def partextras(labels): |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
718 """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:
29680
diff
changeset
|
719 |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
720 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:
29680
diff
changeset
|
721 """ |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
722 if labels is None: |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
723 return { |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
724 "l": "", |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
725 "o": "", |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
726 } |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
727 |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
728 return { |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
729 "l": " [%s]" % labels[0], |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
730 "o": " [%s]" % labels[1], |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
731 } |
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
732 |
34053
fe04c018eaac
filemerge: add _restorebackup
Phil Cohen <phillco@fb.com>
parents:
34052
diff
changeset
|
733 def _restorebackup(fcd, back): |
fe04c018eaac
filemerge: add _restorebackup
Phil Cohen <phillco@fb.com>
parents:
34052
diff
changeset
|
734 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use |
fe04c018eaac
filemerge: add _restorebackup
Phil Cohen <phillco@fb.com>
parents:
34052
diff
changeset
|
735 # util.copy here instead. |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
736 fcd.write(back.data(), fcd.flags()) |
34053
fe04c018eaac
filemerge: add _restorebackup
Phil Cohen <phillco@fb.com>
parents:
34052
diff
changeset
|
737 |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
738 def _makebackup(repo, ui, wctx, fcd, premerge): |
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
739 """Makes and returns a filectx-like object for ``fcd``'s backup file. |
34048
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
740 |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
741 In addition to preserving the user's pre-existing modifications to `fcd` |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
742 (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:
33924
diff
changeset
|
743 merge changed anything, and determine what line endings the new file should |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
744 have. |
35702
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
745 |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
746 Backups only need to be written once (right before the premerge) since their |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
747 content doesn't change afterwards. |
34048
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
748 """ |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
749 if fcd.isabsent(): |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
750 return None |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
751 # TODO: Break this import cycle somehow. (filectx -> ctx -> fileset -> |
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
752 # 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
|
753 from . import context |
41613
a8ccd821b7d2
filemerge: migrate to scmutil.backuppath()
Martin von Zweigbergk <martinvonz@google.com>
parents:
41524
diff
changeset
|
754 back = scmutil.backuppath(ui, repo, fcd.path()) |
34784
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
755 inworkingdir = (back.startswith(repo.wvfs.base) and not |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
756 back.startswith(repo.vfs.base)) |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
757 if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir: |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
758 # If the backup file is to be in the working directory, and we're |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
759 # merging in-memory, we must redirect the backup to the memory context |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
760 # so we don't disturb the working directory. |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
761 relpath = back[len(repo.wvfs.base) + 1:] |
35703
9a50ffd15b25
filemerge: only write in-memory backup during premerge
Phil Cohen <phillco@fb.com>
parents:
35702
diff
changeset
|
762 if premerge: |
9a50ffd15b25
filemerge: only write in-memory backup during premerge
Phil Cohen <phillco@fb.com>
parents:
35702
diff
changeset
|
763 wctx[relpath].write(fcd.data(), fcd.flags()) |
34784
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
764 return wctx[relpath] |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
765 else: |
35702
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
766 if premerge: |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
767 # Otherwise, write to wherever path the user specified the backups |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
768 # should go. We still need to switch based on whether the source is |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
769 # in-memory so we can use the fast path of ``util.copy`` if both are |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
770 # on disk. |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
771 if isinstance(fcd, context.overlayworkingfilectx): |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
772 util.writefile(back, fcd.data()) |
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
773 else: |
41613
a8ccd821b7d2
filemerge: migrate to scmutil.backuppath()
Martin von Zweigbergk <martinvonz@google.com>
parents:
41524
diff
changeset
|
774 a = _workingpath(repo, fcd) |
35702
c0439e11af16
filemerge: fix backing up an in-memory file to a custom location
Phil Cohen <phillco@fb.com>
parents:
35487
diff
changeset
|
775 util.copyfile(a, back) |
34784
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
776 # A arbitraryfilectx is returned, so we can run the same functions on |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
777 # the backup context regardless of where it lives. |
123a68e6b473
filemerge: store backups in the overlayworkingctx if using imm
Phil Cohen <phillco@fb.com>
parents:
34782
diff
changeset
|
778 return context.arbitraryfilectx(back, repo=repo) |
34048
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
779 |
37001
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36991
diff
changeset
|
780 @contextlib.contextmanager |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
781 def _maketempfiles(repo, fco, fca, localpath, uselocalpath): |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
782 """Writes out `fco` and `fca` as temporary files, and (if uselocalpath) |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
783 copies `localpath` to another temporary file, so an external merge tool may |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
784 use them. |
34048
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
785 """ |
37002
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
786 tmproot = None |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
787 tmprootprefix = repo.ui.config('experimental', 'mergetempdirprefix') |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
788 if tmprootprefix: |
38198
2ce60954b1b7
py3: wrap tempfile.mkdtemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
38197
diff
changeset
|
789 tmproot = pycompat.mkdtemp(prefix=tmprootprefix) |
37002
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
790 |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
791 def maketempfrompath(prefix, path): |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
792 fullbase, ext = os.path.splitext(path) |
37002
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
793 pre = "%s~%s" % (os.path.basename(fullbase), prefix) |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
794 if tmproot: |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
795 name = os.path.join(tmproot, pre) |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
796 if ext: |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
797 name += ext |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
798 f = open(name, r"wb") |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
799 else: |
38197
aac4be30e250
py3: wrap tempfile.mkstemp() to use bytes path
Yuya Nishihara <yuya@tcha.org>
parents:
38192
diff
changeset
|
800 fd, name = pycompat.mkstemp(prefix=pre + '.', suffix=ext) |
37002
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
801 f = os.fdopen(fd, r"wb") |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
802 return f, name |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
803 |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
804 def tempfromcontext(prefix, ctx): |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
805 f, name = maketempfrompath(prefix, ctx.path()) |
34048
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
806 data = repo.wwritedata(ctx.path(), ctx.data()) |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
807 f.write(data) |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
808 f.close() |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
809 return name |
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
810 |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
811 b = tempfromcontext("base", fca) |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
812 c = tempfromcontext("other", fco) |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
813 d = localpath |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
814 if uselocalpath: |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
815 # We start off with this being the backup filename, so remove the .orig |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
816 # to make syntax-highlighting more likely. |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
817 if d.endswith('.orig'): |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
818 d, _ = os.path.splitext(d) |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
819 f, d = maketempfrompath("local", d) |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
820 with open(localpath, 'rb') as src: |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
821 f.write(src.read()) |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
822 f.close() |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
823 |
37001
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36991
diff
changeset
|
824 try: |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
825 yield b, c, d |
37001
3723b42ff953
filemerge: move temp file unlinks to _maketempfiles
Kyle Lippincott <spectral@google.com>
parents:
36991
diff
changeset
|
826 finally: |
37002
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
827 if tmproot: |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
828 shutil.rmtree(tmproot) |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
829 else: |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
830 util.unlink(b) |
e349ad5cbb71
filemerge: use a single temp dir instead of temp files
Kyle Lippincott <spectral@google.com>
parents:
37001
diff
changeset
|
831 util.unlink(c) |
37080
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
832 # if not uselocalpath, d is the 'orig'/backup file which we |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
833 # shouldn't delete. |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
834 if d and uselocalpath: |
1e30a26a65d0
filemerge: make the 'local' path match the format that 'base' and 'other' use
Kyle Lippincott <spectral@google.com>
parents:
37002
diff
changeset
|
835 util.unlink(d) |
34048
52bd006b4f49
filemerge: extract _maketemp and _makebackup
Phil Cohen <phillco@fb.com>
parents:
33924
diff
changeset
|
836 |
34137
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
837 def _filemerge(premerge, 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
|
838 """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
|
839 |
26607
45a6233d5f50
filemerge: introduce a premerge flag and function
Siddharth Agarwal <sid0@fb.com>
parents:
26606
diff
changeset
|
840 premerge = whether this is a premerge |
6512
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
841 mynode = parent node before merge |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
842 orig = original local filename before merge |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
843 fco = other file context |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
844 fca = ancestor file context |
368a4ec603cc
merge: introduce mergestate
Matt Mackall <mpm@selenic.com>
parents:
6212
diff
changeset
|
845 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
|
846 |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
847 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
|
848 a boolean indicating whether the file was deleted from disk.""" |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
849 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
850 if not fco.cmp(fcd): # files identical? |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
851 return True, None, False |
26512
4c52dd406adc
filemerge: indent filemerge.filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26224
diff
changeset
|
852 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
853 ui = repo.ui |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
854 fd = fcd.path() |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
855 uipathfn = scmutil.getuipathfn(repo) |
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
856 fduipath = uipathfn(fd) |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
857 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
858 symlink = '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
|
859 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
|
860 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete) |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
861 scriptfn = None |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
862 if tool in internals and tool.startswith('internal:'): |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
863 # normalize to new-style names (':merge' etc) |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
864 tool = tool[len('internal'):] |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
865 if toolpath and toolpath.startswith('python:'): |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
866 invalidsyntax = False |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
867 if toolpath.count(':') >= 2: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
868 script, scriptfn = toolpath[7:].rsplit(':', 1) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
869 if not scriptfn: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
870 invalidsyntax = True |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
871 # missing :callable can lead to spliting on windows drive letter |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
872 if '\\' in scriptfn or '/' in scriptfn: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
873 invalidsyntax = True |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
874 else: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
875 invalidsyntax = True |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
876 if invalidsyntax: |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
877 raise error.Abort(_("invalid 'python:' syntax: %s") % toolpath) |
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
878 toolpath = script |
27161
296d55def9c4
filemerge: add debug output for whether this is a change/delete conflict
Siddharth Agarwal <sid0@fb.com>
parents:
27124
diff
changeset
|
879 ui.debug("picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n" |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
880 % (tool, fduipath, pycompat.bytestr(binary), |
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
881 pycompat.bytestr(symlink), pycompat.bytestr(changedelete))) |
6003
7855b88ba838
filemerge: pull file-merging code into its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
882 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
883 if tool in internals: |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
884 func = internals[tool] |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
885 mergetype = func.mergetype |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
886 onfailure = func.onfailure |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
887 precheck = func.precheck |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
888 isexternal = False |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
889 else: |
35467
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
890 if wctx.isinmemory(): |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
891 func = _xmergeimm |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
892 else: |
ef7e667a4f7b
filemerge: only raise InMemoryMergeConflictsError when running _xmerge
Phil Cohen <phillco@fb.com>
parents:
35291
diff
changeset
|
893 func = _xmerge |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
894 mergetype = fullmerge |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
895 onfailure = _("merging %s failed!\n") |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
896 precheck = None |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
897 isexternal = True |
26512
4c52dd406adc
filemerge: indent filemerge.filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26224
diff
changeset
|
898 |
38074
242eb5132203
filemerge: support specifying a python function to custom merge-tools
hindlemail <tom_hindle@sil.org>
parents:
37123
diff
changeset
|
899 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
|
900 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
901 if mergetype == nomerge: |
29785
a7f8939641aa
merge: use labels in prompts to the user
Simon Farnsworth <simonfar@fb.com>
parents:
29680
diff
changeset
|
902 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels) |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
903 return True, r, deleted |
26512
4c52dd406adc
filemerge: indent filemerge.filemerge
Siddharth Agarwal <sid0@fb.com>
parents:
26224
diff
changeset
|
904 |
26609
47681e77e484
filemerge: only print out "merging f" output at premerge step
Siddharth Agarwal <sid0@fb.com>
parents:
26608
diff
changeset
|
905 if premerge: |
47681e77e484
filemerge: only print out "merging f" output at premerge step
Siddharth Agarwal <sid0@fb.com>
parents:
26608
diff
changeset
|
906 if orig != fco.path(): |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
907 ui.status(_("merging %s and %s to %s\n") % |
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
908 (uipathfn(orig), uipathfn(fco.path()), fduipath)) |
26609
47681e77e484
filemerge: only print out "merging f" output at premerge step
Siddharth Agarwal <sid0@fb.com>
parents:
26608
diff
changeset
|
909 else: |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
910 ui.status(_("merging %s\n") % fduipath) |
26528
8bfef5737321
filemerge: move 'merging' output to before file creation
Siddharth Agarwal <sid0@fb.com>
parents:
26527
diff
changeset
|
911 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
912 ui.debug("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
|
913 |
26608
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
914 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
915 toolconf): |
ae5b60d3294f
filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal <sid0@fb.com>
parents:
26607
diff
changeset
|
916 if onfailure: |
35291
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
917 if wctx.isinmemory(): |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
918 raise error.InMemoryMergeConflictsError('in-memory merge does ' |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
919 'not support merge ' |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
920 'conflicts') |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
921 ui.warn(onfailure % fduipath) |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
922 return True, 1, False |
26529
7833b13b001f
filemerge: move precheck to before files are written out
Siddharth Agarwal <sid0@fb.com>
parents:
26528
diff
changeset
|
923 |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
924 back = _makebackup(repo, ui, wctx, fcd, premerge) |
34052
96123bdea43e
filemerge: reduce creation of tempfiles until needed
Phil Cohen <phillco@fb.com>
parents:
34051
diff
changeset
|
925 files = (None, None, None, back) |
26589
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
926 r = 1 |
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
927 try: |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
928 internalmarkerstyle = ui.config('ui', 'mergemarkers') |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
929 if isexternal: |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
930 markerstyle = _toolstr(ui, tool, 'mergemarkers') |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
931 else: |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
932 markerstyle = internalmarkerstyle |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
933 |
26529
7833b13b001f
filemerge: move precheck to before files are written out
Siddharth Agarwal <sid0@fb.com>
parents:
26528
diff
changeset
|
934 if not labels: |
7833b13b001f
filemerge: move precheck to before files are written out
Siddharth Agarwal <sid0@fb.com>
parents:
26528
diff
changeset
|
935 labels = _defaultconflictlabels |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
936 formattedlabels = labels |
26529
7833b13b001f
filemerge: move precheck to before files are written out
Siddharth Agarwal <sid0@fb.com>
parents:
26528
diff
changeset
|
937 if markerstyle != 'basic': |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
938 formattedlabels = _formatlabels(repo, fcd, fco, fca, labels, |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
939 tool=tool) |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
940 |
26607
45a6233d5f50
filemerge: introduce a premerge flag and function
Siddharth Agarwal <sid0@fb.com>
parents:
26606
diff
changeset
|
941 if premerge and mergetype == fullmerge: |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
942 # conflict markers generated by premerge will use 'detailed' |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
943 # 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:
35869
diff
changeset
|
944 # 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:
35869
diff
changeset
|
945 # 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:
35869
diff
changeset
|
946 # 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:
35869
diff
changeset
|
947 premergelabels = labels |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
948 labeltool = None |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
949 if markerstyle != 'basic': |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
950 # respect 'tool's mergemarkertemplate (which defaults to |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
951 # ui.mergemarkertemplate) |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
952 labeltool = tool |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
953 if internalmarkerstyle != 'basic' or markerstyle != 'basic': |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
954 premergelabels = _formatlabels(repo, fcd, fco, fca, |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
955 premergelabels, tool=labeltool) |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
956 |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
957 r = _premerge(repo, fcd, fco, fca, toolconf, files, |
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
958 labels=premergelabels) |
26611
a5ff66e6d77a
filemerge: break overall filemerge into separate premerge and merge steps
Siddharth Agarwal <sid0@fb.com>
parents:
26610
diff
changeset
|
959 # complete if premerge successful (r is 0) |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
960 return not r, r, False |
26567
f18646cf0e93
filemerge: call premerge directly from main merge function
Siddharth Agarwal <sid0@fb.com>
parents:
26529
diff
changeset
|
961 |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
962 needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca, |
35947
9037c29e9f53
filemerge: support passing labels to external merge tools
Kyle Lippincott <spectral@google.com>
parents:
35869
diff
changeset
|
963 toolconf, files, labels=formattedlabels) |
27033
089dab8794dc
filemerge: return whether the file is deleted from all other merge tools
Siddharth Agarwal <sid0@fb.com>
parents:
27032
diff
changeset
|
964 |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
965 if needcheck: |
34051
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
966 r = _check(repo, r, ui, tool, fcd, files) |
21519
25d5a9ecbb85
merge: add conflict marker formatter (BC)
Durham Goode <durham@fb.com>
parents:
21273
diff
changeset
|
967 |
16125
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
968 if r: |
83925d3a4559
filemerge: refactoring of 'filemerge()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15738
diff
changeset
|
969 if onfailure: |
35291
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
970 if wctx.isinmemory(): |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
971 raise error.InMemoryMergeConflictsError('in-memory merge ' |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
972 'does not support ' |
46d7f0713a87
filemerge: raise InMemoryMergeConflictsError if we hit merge conflicts in IMM
Phil Cohen <phillco@fb.com>
parents:
35290
diff
changeset
|
973 'merge conflicts') |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
974 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
|
975 _onfilemergefailure(ui) |
26589
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
976 |
27034
86ede9eda252
filemerge: return whether the file was deleted
Siddharth Agarwal <sid0@fb.com>
parents:
27033
diff
changeset
|
977 return True, r, deleted |
26589
fb388aa26453
filemerge: clean up temp files in a finally block
Siddharth Agarwal <sid0@fb.com>
parents:
26575
diff
changeset
|
978 finally: |
27047
e1458049dca5
filemerge: don't try to copy files known to be absent
Siddharth Agarwal <sid0@fb.com>
parents:
27042
diff
changeset
|
979 if not r and back is not None: |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
980 back.remove() |
6004
5af5f0f9d724
merge: allow smarter tool configuration
Matt Mackall <mpm@selenic.com>
parents:
6003
diff
changeset
|
981 |
34796
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
982 def _haltmerge(): |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
983 msg = _('merge halted after failed merge (see hg resolve)') |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
984 raise error.InterventionRequired(msg) |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
985 |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
986 def _onfilemergefailure(ui): |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
987 action = ui.config('merge', 'on-failure') |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
988 if action == 'prompt': |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
989 msg = _('continue merge operation (yn)?' '$$ &Yes $$ &No') |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
990 if ui.promptchoice(msg, 0) == 1: |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
991 _haltmerge() |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
992 if action == 'halt': |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
993 _haltmerge() |
ed91846c29cf
filemerge: introduce functions to halt merge flow
Ryan McElroy <rmcelroy@fb.com>
parents:
34785
diff
changeset
|
994 # 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
|
995 |
38833
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38198
diff
changeset
|
996 def hasconflictmarkers(data): |
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38198
diff
changeset
|
997 return bool(re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", data, |
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38198
diff
changeset
|
998 re.MULTILINE)) |
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38198
diff
changeset
|
999 |
34051
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
1000 def _check(repo, r, ui, tool, fcd, files): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1001 fd = fcd.path() |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
1002 uipathfn = scmutil.getuipathfn(repo) |
34051
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
1003 unused, unused, unused, back = files |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1004 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1005 if not r and (_toolbool(ui, tool, "checkconflicts") or |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1006 'conflicts' in _toollist(ui, tool, "check")): |
38833
6c8e3c847977
resolve: add option to warn/abort on -m with unresolved conflict markers
Kyle Lippincott <spectral@google.com>
parents:
38198
diff
changeset
|
1007 if hasconflictmarkers(fcd.data()): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1008 r = 1 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1009 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1010 checked = False |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1011 if 'prompt' in _toollist(ui, tool, "check"): |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1012 checked = True |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1013 if ui.promptchoice(_("was merge of '%s' successful (yn)?" |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
1014 "$$ &Yes $$ &No") % uipathfn(fd), 1): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1015 r = 1 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1016 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1017 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1018 'changed' in |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1019 _toollist(ui, tool, "check")): |
34782
f21eecc64ace
filemerge: use arbitraryfilectx for backups
Phil Cohen <phillco@fb.com>
parents:
34506
diff
changeset
|
1020 if back is not None and not fcd.cmp(back): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1021 if ui.promptchoice(_(" output file %s appears unchanged\n" |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1022 "was merge successful (yn)?" |
41524
faa49a5914bb
merge: respect ui.relative-paths
Martin von Zweigbergk <martinvonz@google.com>
parents:
41387
diff
changeset
|
1023 "$$ &Yes $$ &No") % uipathfn(fd), 1): |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1024 r = 1 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1025 |
27047
e1458049dca5
filemerge: don't try to copy files known to be absent
Siddharth Agarwal <sid0@fb.com>
parents:
27042
diff
changeset
|
1026 if back is not None and _toolbool(ui, tool, "fixeol"): |
34051
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
1027 _matcheol(_workingpath(repo, fcd), back) |
26575
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1028 |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1029 return r |
d60815664c34
filemerge: move post-merge checks into a separate function
Siddharth Agarwal <sid0@fb.com>
parents:
26574
diff
changeset
|
1030 |
34051
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
1031 def _workingpath(repo, ctx): |
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
1032 return repo.wjoin(ctx.path()) |
7558917f291e
filemerge: add `_workingpath`
Phil Cohen <phillco@fb.com>
parents:
34050
diff
changeset
|
1033 |
34137
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
1034 def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None): |
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
1035 return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca, |
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
1036 labels=labels) |
26607
45a6233d5f50
filemerge: introduce a premerge flag and function
Siddharth Agarwal <sid0@fb.com>
parents:
26606
diff
changeset
|
1037 |
34137
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
1038 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None): |
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
1039 return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca, |
c0ce60459d84
merge: pass wctx to premerge, filemerge
Phil Cohen <phillco@fb.com>
parents:
34093
diff
changeset
|
1040 labels=labels) |
26605
ef21a2c41629
filemerge: add a wrapper around the filemerge function
Siddharth Agarwal <sid0@fb.com>
parents:
26589
diff
changeset
|
1041 |
33725
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1042 def loadinternalmerge(ui, extname, registrarobj): |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1043 """Load internal merge tool from specified registrarobj |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1044 """ |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1045 for name, func in registrarobj._table.iteritems(): |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1046 fullname = ':' + name |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1047 internals[fullname] = func |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1048 internals['internal:' + name] = func |
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1049 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
|
1050 |
39163
e09fad982ef5
filemerge: show actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39162
diff
changeset
|
1051 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:
39162
diff
changeset
|
1052 if capabilities: |
39294
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1053 capdesc = " (actual capabilities: %s)" % ', '.join(capabilities) |
39163
e09fad982ef5
filemerge: show actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39162
diff
changeset
|
1054 func.__doc__ = (func.__doc__ + |
39294
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1055 pycompat.sysstr("\n\n%s" % capdesc)) |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1056 |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1057 # 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:
39293
diff
changeset
|
1058 |
39386
bc0eb1dc6aae
filemerge: fix an i18n comment typo
Matt Harbison <matt_harbison@yahoo.com>
parents:
39312
diff
changeset
|
1059 # i18n: "binary" and "symlink" are keywords |
39294
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1060 # i18n: this text is added automatically |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1061 _(" (actual capabilities: binary, symlink)") |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1062 # i18n: "binary" is keyword |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1063 # i18n: this text is added automatically |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1064 _(" (actual capabilities: binary)") |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1065 # i18n: "symlink" is keyword |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1066 # i18n: this text is added automatically |
88c5a3ef54b1
filemerge: avoid putting translated text into docstring
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39293
diff
changeset
|
1067 _(" (actual capabilities: symlink)") |
39163
e09fad982ef5
filemerge: show actual capabilities of internal merge tools
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
39162
diff
changeset
|
1068 |
33725
50c44dee741a
filemerge: move decorator definition for internal merge tools to registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
33523
diff
changeset
|
1069 # 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
|
1070 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
|
1071 |
16126
0c4bec9596d8
filemerge: create detail of internal merge tools from documentation string
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16125
diff
changeset
|
1072 # 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
|
1073 i18nfunctions = internals.values() |