Show More
@@ -1,375 +1,377 b'' | |||||
1 | # filemerge.py - file-level merge handling for Mercurial |
|
1 | # filemerge.py - file-level merge handling for Mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import short |
|
8 | from node import short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import util, simplemerge, match, error |
|
10 | import util, simplemerge, match, error | |
11 | import os, tempfile, re, filecmp |
|
11 | import os, tempfile, re, filecmp | |
12 |
|
12 | |||
13 | def _toolstr(ui, tool, part, default=""): |
|
13 | def _toolstr(ui, tool, part, default=""): | |
14 | return ui.config("merge-tools", tool + "." + part, default) |
|
14 | return ui.config("merge-tools", tool + "." + part, default) | |
15 |
|
15 | |||
16 | def _toolbool(ui, tool, part, default=False): |
|
16 | def _toolbool(ui, tool, part, default=False): | |
17 | return ui.configbool("merge-tools", tool + "." + part, default) |
|
17 | return ui.configbool("merge-tools", tool + "." + part, default) | |
18 |
|
18 | |||
19 | def _toollist(ui, tool, part, default=[]): |
|
19 | def _toollist(ui, tool, part, default=[]): | |
20 | return ui.configlist("merge-tools", tool + "." + part, default) |
|
20 | return ui.configlist("merge-tools", tool + "." + part, default) | |
21 |
|
21 | |||
22 | internals = {} |
|
22 | internals = {} | |
23 |
|
23 | |||
24 | def internaltool(name, trymerge, onfailure=None): |
|
24 | def internaltool(name, trymerge, onfailure=None): | |
25 | '''return a decorator for populating internal merge tool table''' |
|
25 | '''return a decorator for populating internal merge tool table''' | |
26 | def decorator(func): |
|
26 | def decorator(func): | |
27 | fullname = 'internal:' + name |
|
27 | fullname = 'internal:' + name | |
28 | func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip() |
|
28 | func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip() | |
29 | internals[fullname] = func |
|
29 | internals[fullname] = func | |
30 | func.trymerge = trymerge |
|
30 | func.trymerge = trymerge | |
31 | func.onfailure = onfailure |
|
31 | func.onfailure = onfailure | |
32 | return func |
|
32 | return func | |
33 | return decorator |
|
33 | return decorator | |
34 |
|
34 | |||
35 | def _findtool(ui, tool): |
|
35 | def _findtool(ui, tool): | |
36 | if tool in internals: |
|
36 | if tool in internals: | |
37 | return tool |
|
37 | return tool | |
38 | for kn in ("regkey", "regkeyalt"): |
|
38 | for kn in ("regkey", "regkeyalt"): | |
39 | k = _toolstr(ui, tool, kn) |
|
39 | k = _toolstr(ui, tool, kn) | |
40 | if not k: |
|
40 | if not k: | |
41 | continue |
|
41 | continue | |
42 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) |
|
42 | p = util.lookupreg(k, _toolstr(ui, tool, "regname")) | |
43 | if p: |
|
43 | if p: | |
44 | p = util.findexe(p + _toolstr(ui, tool, "regappend")) |
|
44 | p = util.findexe(p + _toolstr(ui, tool, "regappend")) | |
45 | if p: |
|
45 | if p: | |
46 | return p |
|
46 | return p | |
47 | exe = _toolstr(ui, tool, "executable", tool) |
|
47 | exe = _toolstr(ui, tool, "executable", tool) | |
48 | return util.findexe(util.expandpath(exe)) |
|
48 | return util.findexe(util.expandpath(exe)) | |
49 |
|
49 | |||
50 | def _picktool(repo, ui, path, binary, symlink): |
|
50 | def _picktool(repo, ui, path, binary, symlink): | |
51 | def check(tool, pat, symlink, binary): |
|
51 | def check(tool, pat, symlink, binary): | |
52 | tmsg = tool |
|
52 | tmsg = tool | |
53 | if pat: |
|
53 | if pat: | |
54 | tmsg += " specified for " + pat |
|
54 | tmsg += " specified for " + pat | |
55 | if not _findtool(ui, tool): |
|
55 | if not _findtool(ui, tool): | |
56 | if pat: # explicitly requested tool deserves a warning |
|
56 | if pat: # explicitly requested tool deserves a warning | |
57 | ui.warn(_("couldn't find merge tool %s\n") % tmsg) |
|
57 | ui.warn(_("couldn't find merge tool %s\n") % tmsg) | |
58 | else: # configured but non-existing tools are more silent |
|
58 | else: # configured but non-existing tools are more silent | |
59 | ui.note(_("couldn't find merge tool %s\n") % tmsg) |
|
59 | ui.note(_("couldn't find merge tool %s\n") % tmsg) | |
60 | elif symlink and not _toolbool(ui, tool, "symlink"): |
|
60 | elif symlink and not _toolbool(ui, tool, "symlink"): | |
61 | ui.warn(_("tool %s can't handle symlinks\n") % tmsg) |
|
61 | ui.warn(_("tool %s can't handle symlinks\n") % tmsg) | |
62 | elif binary and not _toolbool(ui, tool, "binary"): |
|
62 | elif binary and not _toolbool(ui, tool, "binary"): | |
63 | ui.warn(_("tool %s can't handle binary\n") % tmsg) |
|
63 | ui.warn(_("tool %s can't handle binary\n") % tmsg) | |
64 | elif not util.gui() and _toolbool(ui, tool, "gui"): |
|
64 | elif not util.gui() and _toolbool(ui, tool, "gui"): | |
65 | ui.warn(_("tool %s requires a GUI\n") % tmsg) |
|
65 | ui.warn(_("tool %s requires a GUI\n") % tmsg) | |
66 | else: |
|
66 | else: | |
67 | return True |
|
67 | return True | |
68 | return False |
|
68 | return False | |
69 |
|
69 | |||
70 | # forcemerge comes from command line arguments, highest priority |
|
70 | # forcemerge comes from command line arguments, highest priority | |
71 | force = ui.config('ui', 'forcemerge') |
|
71 | force = ui.config('ui', 'forcemerge') | |
72 | if force: |
|
72 | if force: | |
73 | toolpath = _findtool(ui, force) |
|
73 | toolpath = _findtool(ui, force) | |
74 | if toolpath: |
|
74 | if toolpath: | |
75 | return (force, util.shellquote(toolpath)) |
|
75 | return (force, util.shellquote(toolpath)) | |
76 | else: |
|
76 | else: | |
77 | # mimic HGMERGE if given tool not found |
|
77 | # mimic HGMERGE if given tool not found | |
78 | return (force, force) |
|
78 | return (force, force) | |
79 |
|
79 | |||
80 | # HGMERGE takes next precedence |
|
80 | # HGMERGE takes next precedence | |
81 | hgmerge = os.environ.get("HGMERGE") |
|
81 | hgmerge = os.environ.get("HGMERGE") | |
82 | if hgmerge: |
|
82 | if hgmerge: | |
83 | return (hgmerge, hgmerge) |
|
83 | return (hgmerge, hgmerge) | |
84 |
|
84 | |||
85 | # then patterns |
|
85 | # then patterns | |
86 | for pat, tool in ui.configitems("merge-patterns"): |
|
86 | for pat, tool in ui.configitems("merge-patterns"): | |
87 | mf = match.match(repo.root, '', [pat]) |
|
87 | mf = match.match(repo.root, '', [pat]) | |
88 | if mf(path) and check(tool, pat, symlink, False): |
|
88 | if mf(path) and check(tool, pat, symlink, False): | |
89 | toolpath = _findtool(ui, tool) |
|
89 | toolpath = _findtool(ui, tool) | |
90 | return (tool, util.shellquote(toolpath)) |
|
90 | return (tool, util.shellquote(toolpath)) | |
91 |
|
91 | |||
92 | # then merge tools |
|
92 | # then merge tools | |
93 | tools = {} |
|
93 | tools = {} | |
94 | for k, v in ui.configitems("merge-tools"): |
|
94 | for k, v in ui.configitems("merge-tools"): | |
95 | t = k.split('.')[0] |
|
95 | t = k.split('.')[0] | |
96 | if t not in tools: |
|
96 | if t not in tools: | |
97 | tools[t] = int(_toolstr(ui, t, "priority", "0")) |
|
97 | tools[t] = int(_toolstr(ui, t, "priority", "0")) | |
98 | names = tools.keys() |
|
98 | names = tools.keys() | |
99 | tools = sorted([(-p, t) for t, p in tools.items()]) |
|
99 | tools = sorted([(-p, t) for t, p in tools.items()]) | |
100 | uimerge = ui.config("ui", "merge") |
|
100 | uimerge = ui.config("ui", "merge") | |
101 | if uimerge: |
|
101 | if uimerge: | |
102 | if uimerge not in names: |
|
102 | if uimerge not in names: | |
103 | return (uimerge, uimerge) |
|
103 | return (uimerge, uimerge) | |
104 | tools.insert(0, (None, uimerge)) # highest priority |
|
104 | tools.insert(0, (None, uimerge)) # highest priority | |
105 | tools.append((None, "hgmerge")) # the old default, if found |
|
105 | tools.append((None, "hgmerge")) # the old default, if found | |
106 | for p, t in tools: |
|
106 | for p, t in tools: | |
107 | if check(t, None, symlink, binary): |
|
107 | if check(t, None, symlink, binary): | |
108 | toolpath = _findtool(ui, t) |
|
108 | toolpath = _findtool(ui, t) | |
109 | return (t, util.shellquote(toolpath)) |
|
109 | return (t, util.shellquote(toolpath)) | |
110 |
|
110 | |||
111 | # internal merge or prompt as last resort |
|
111 | # internal merge or prompt as last resort | |
112 | if symlink or binary: |
|
112 | if symlink or binary: | |
113 | return "internal:prompt", None |
|
113 | return "internal:prompt", None | |
114 | return "internal:merge", None |
|
114 | return "internal:merge", None | |
115 |
|
115 | |||
116 | def _eoltype(data): |
|
116 | def _eoltype(data): | |
117 | "Guess the EOL type of a file" |
|
117 | "Guess the EOL type of a file" | |
118 | if '\0' in data: # binary |
|
118 | if '\0' in data: # binary | |
119 | return None |
|
119 | return None | |
120 | if '\r\n' in data: # Windows |
|
120 | if '\r\n' in data: # Windows | |
121 | return '\r\n' |
|
121 | return '\r\n' | |
122 | if '\r' in data: # Old Mac |
|
122 | if '\r' in data: # Old Mac | |
123 | return '\r' |
|
123 | return '\r' | |
124 | if '\n' in data: # UNIX |
|
124 | if '\n' in data: # UNIX | |
125 | return '\n' |
|
125 | return '\n' | |
126 | return None # unknown |
|
126 | return None # unknown | |
127 |
|
127 | |||
128 | def _matcheol(file, origfile): |
|
128 | def _matcheol(file, origfile): | |
129 | "Convert EOL markers in a file to match origfile" |
|
129 | "Convert EOL markers in a file to match origfile" | |
130 | tostyle = _eoltype(util.readfile(origfile)) |
|
130 | tostyle = _eoltype(util.readfile(origfile)) | |
131 | if tostyle: |
|
131 | if tostyle: | |
132 | data = util.readfile(file) |
|
132 | data = util.readfile(file) | |
133 | style = _eoltype(data) |
|
133 | style = _eoltype(data) | |
134 | if style: |
|
134 | if style: | |
135 | newdata = data.replace(style, tostyle) |
|
135 | newdata = data.replace(style, tostyle) | |
136 | if newdata != data: |
|
136 | if newdata != data: | |
137 | util.writefile(file, newdata) |
|
137 | util.writefile(file, newdata) | |
138 |
|
138 | |||
139 | @internaltool('prompt', False) |
|
139 | @internaltool('prompt', False) | |
140 | def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
140 | def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf): | |
141 | """Asks the user which of the local or the other version to keep as |
|
141 | """Asks the user which of the local or the other version to keep as | |
142 | the merged version.""" |
|
142 | the merged version.""" | |
143 | ui = repo.ui |
|
143 | ui = repo.ui | |
144 | fd = fcd.path() |
|
144 | fd = fcd.path() | |
145 |
|
145 | |||
146 | if ui.promptchoice(_(" no tool found to merge %s\n" |
|
146 | if ui.promptchoice(_(" no tool found to merge %s\n" | |
147 | "keep (l)ocal or take (o)ther?") % fd, |
|
147 | "keep (l)ocal or take (o)ther?") % fd, | |
148 | (_("&Local"), _("&Other")), 0): |
|
148 | (_("&Local"), _("&Other")), 0): | |
149 | return _iother(repo, mynode, orig, fcd, fco, fca, toolconf) |
|
149 | return _iother(repo, mynode, orig, fcd, fco, fca, toolconf) | |
150 | else: |
|
150 | else: | |
151 | return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf) |
|
151 | return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf) | |
152 |
|
152 | |||
153 | @internaltool('local', False) |
|
153 | @internaltool('local', False) | |
154 | def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
154 | def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf): | |
155 | """Uses the local version of files as the merged version.""" |
|
155 | """Uses the local version of files as the merged version.""" | |
156 | return 0 |
|
156 | return 0 | |
157 |
|
157 | |||
158 | @internaltool('other', False) |
|
158 | @internaltool('other', False) | |
159 | def _iother(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
159 | def _iother(repo, mynode, orig, fcd, fco, fca, toolconf): | |
160 | """Uses the other version of files as the merged version.""" |
|
160 | """Uses the other version of files as the merged version.""" | |
161 | repo.wwrite(fcd.path(), fco.data(), fco.flags()) |
|
161 | repo.wwrite(fcd.path(), fco.data(), fco.flags()) | |
162 | return 0 |
|
162 | return 0 | |
163 |
|
163 | |||
164 | @internaltool('fail', False) |
|
164 | @internaltool('fail', False) | |
165 | def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf): |
|
165 | def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf): | |
166 | """ |
|
166 | """ | |
167 | Rather than attempting to merge files that were modified on both |
|
167 | Rather than attempting to merge files that were modified on both | |
168 | branches, it marks them as unresolved. The resolve command must be |
|
168 | branches, it marks them as unresolved. The resolve command must be | |
169 | used to resolve these conflicts.""" |
|
169 | used to resolve these conflicts.""" | |
170 | return 1 |
|
170 | return 1 | |
171 |
|
171 | |||
172 | def _premerge(repo, toolconf, files): |
|
172 | def _premerge(repo, toolconf, files): | |
173 | tool, toolpath, binary, symlink = toolconf |
|
173 | tool, toolpath, binary, symlink = toolconf | |
174 | if symlink: |
|
174 | if symlink: | |
175 | return 1 |
|
175 | return 1 | |
176 | a, b, c, back = files |
|
176 | a, b, c, back = files | |
177 |
|
177 | |||
178 | ui = repo.ui |
|
178 | ui = repo.ui | |
179 |
|
179 | |||
180 | # do we attempt to simplemerge first? |
|
180 | # do we attempt to simplemerge first? | |
181 | try: |
|
181 | try: | |
182 | premerge = _toolbool(ui, tool, "premerge", not binary) |
|
182 | premerge = _toolbool(ui, tool, "premerge", not binary) | |
183 | except error.ConfigError: |
|
183 | except error.ConfigError: | |
184 | premerge = _toolstr(ui, tool, "premerge").lower() |
|
184 | premerge = _toolstr(ui, tool, "premerge").lower() | |
185 | valid = 'keep'.split() |
|
185 | valid = 'keep'.split() | |
186 | if premerge not in valid: |
|
186 | if premerge not in valid: | |
187 | _valid = ', '.join(["'" + v + "'" for v in valid]) |
|
187 | _valid = ', '.join(["'" + v + "'" for v in valid]) | |
188 | raise error.ConfigError(_("%s.premerge not valid " |
|
188 | raise error.ConfigError(_("%s.premerge not valid " | |
189 | "('%s' is neither boolean nor %s)") % |
|
189 | "('%s' is neither boolean nor %s)") % | |
190 | (tool, premerge, _valid)) |
|
190 | (tool, premerge, _valid)) | |
191 |
|
191 | |||
192 | if premerge: |
|
192 | if premerge: | |
193 | r = simplemerge.simplemerge(ui, a, b, c, quiet=True) |
|
193 | r = simplemerge.simplemerge(ui, a, b, c, quiet=True) | |
194 | if not r: |
|
194 | if not r: | |
195 | ui.debug(" premerge successful\n") |
|
195 | ui.debug(" premerge successful\n") | |
196 | return 0 |
|
196 | return 0 | |
197 | if premerge != 'keep': |
|
197 | if premerge != 'keep': | |
198 | util.copyfile(back, a) # restore from backup and try again |
|
198 | util.copyfile(back, a) # restore from backup and try again | |
199 | return 1 # continue merging |
|
199 | return 1 # continue merging | |
200 |
|
200 | |||
201 | @internaltool('merge', True, |
|
201 | @internaltool('merge', True, | |
202 | _("merging %s incomplete! " |
|
202 | _("merging %s incomplete! " | |
203 | "(edit conflicts, then use 'hg resolve --mark')\n")) |
|
203 | "(edit conflicts, then use 'hg resolve --mark')\n")) | |
204 | def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): |
|
204 | def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): | |
205 | """ |
|
205 | """ | |
206 | Uses the internal non-interactive simple merge algorithm for merging |
|
206 | Uses the internal non-interactive simple merge algorithm for merging | |
207 | files. It will fail if there are any conflicts and leave markers in |
|
207 | files. It will fail if there are any conflicts and leave markers in | |
208 | the partially merged file.""" |
|
208 | the partially merged file.""" | |
209 | tool, toolpath, binary, symlink = toolconf |
|
209 | tool, toolpath, binary, symlink = toolconf | |
210 | if symlink: |
|
210 | if symlink: | |
|
211 | repo.ui.warn(_('warning: internal:merge cannot merge symlinks ' | |||
|
212 | 'for %s\n') % fcd.path()) | |||
211 | return False, 1 |
|
213 | return False, 1 | |
212 |
|
214 | |||
213 | r = _premerge(repo, toolconf, files) |
|
215 | r = _premerge(repo, toolconf, files) | |
214 | if r: |
|
216 | if r: | |
215 | a, b, c, back = files |
|
217 | a, b, c, back = files | |
216 |
|
218 | |||
217 | ui = repo.ui |
|
219 | ui = repo.ui | |
218 |
|
220 | |||
219 | r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) |
|
221 | r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) | |
220 | return True, r |
|
222 | return True, r | |
221 | return False, 0 |
|
223 | return False, 0 | |
222 |
|
224 | |||
223 | @internaltool('dump', True) |
|
225 | @internaltool('dump', True) | |
224 | def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files): |
|
226 | def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files): | |
225 | """ |
|
227 | """ | |
226 | Creates three versions of the files to merge, containing the |
|
228 | Creates three versions of the files to merge, containing the | |
227 | contents of local, other and base. These files can then be used to |
|
229 | contents of local, other and base. These files can then be used to | |
228 | perform a merge manually. If the file to be merged is named |
|
230 | perform a merge manually. If the file to be merged is named | |
229 | ``a.txt``, these files will accordingly be named ``a.txt.local``, |
|
231 | ``a.txt``, these files will accordingly be named ``a.txt.local``, | |
230 | ``a.txt.other`` and ``a.txt.base`` and they will be placed in the |
|
232 | ``a.txt.other`` and ``a.txt.base`` and they will be placed in the | |
231 | same directory as ``a.txt``.""" |
|
233 | same directory as ``a.txt``.""" | |
232 | r = _premerge(repo, toolconf, files) |
|
234 | r = _premerge(repo, toolconf, files) | |
233 | if r: |
|
235 | if r: | |
234 | a, b, c, back = files |
|
236 | a, b, c, back = files | |
235 |
|
237 | |||
236 | fd = fcd.path() |
|
238 | fd = fcd.path() | |
237 |
|
239 | |||
238 | util.copyfile(a, a + ".local") |
|
240 | util.copyfile(a, a + ".local") | |
239 | repo.wwrite(fd + ".other", fco.data(), fco.flags()) |
|
241 | repo.wwrite(fd + ".other", fco.data(), fco.flags()) | |
240 | repo.wwrite(fd + ".base", fca.data(), fca.flags()) |
|
242 | repo.wwrite(fd + ".base", fca.data(), fca.flags()) | |
241 | return False, r |
|
243 | return False, r | |
242 |
|
244 | |||
243 | def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): |
|
245 | def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): | |
244 | r = _premerge(repo, toolconf, files) |
|
246 | r = _premerge(repo, toolconf, files) | |
245 | if r: |
|
247 | if r: | |
246 | tool, toolpath, binary, symlink = toolconf |
|
248 | tool, toolpath, binary, symlink = toolconf | |
247 | a, b, c, back = files |
|
249 | a, b, c, back = files | |
248 | out = "" |
|
250 | out = "" | |
249 | env = dict(HG_FILE=fcd.path(), |
|
251 | env = dict(HG_FILE=fcd.path(), | |
250 | HG_MY_NODE=short(mynode), |
|
252 | HG_MY_NODE=short(mynode), | |
251 | HG_OTHER_NODE=str(fco.changectx()), |
|
253 | HG_OTHER_NODE=str(fco.changectx()), | |
252 | HG_BASE_NODE=str(fca.changectx()), |
|
254 | HG_BASE_NODE=str(fca.changectx()), | |
253 | HG_MY_ISLINK='l' in fcd.flags(), |
|
255 | HG_MY_ISLINK='l' in fcd.flags(), | |
254 | HG_OTHER_ISLINK='l' in fco.flags(), |
|
256 | HG_OTHER_ISLINK='l' in fco.flags(), | |
255 | HG_BASE_ISLINK='l' in fca.flags()) |
|
257 | HG_BASE_ISLINK='l' in fca.flags()) | |
256 |
|
258 | |||
257 | ui = repo.ui |
|
259 | ui = repo.ui | |
258 |
|
260 | |||
259 | args = _toolstr(ui, tool, "args", '$local $base $other') |
|
261 | args = _toolstr(ui, tool, "args", '$local $base $other') | |
260 | if "$output" in args: |
|
262 | if "$output" in args: | |
261 | out, a = a, back # read input from backup, write to original |
|
263 | out, a = a, back # read input from backup, write to original | |
262 | replace = dict(local=a, base=b, other=c, output=out) |
|
264 | replace = dict(local=a, base=b, other=c, output=out) | |
263 | args = util.interpolate(r'\$', replace, args, |
|
265 | args = util.interpolate(r'\$', replace, args, | |
264 | lambda s: util.shellquote(util.localpath(s))) |
|
266 | lambda s: util.shellquote(util.localpath(s))) | |
265 | r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, |
|
267 | r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, | |
266 | out=ui.fout) |
|
268 | out=ui.fout) | |
267 | return True, r |
|
269 | return True, r | |
268 | return False, 0 |
|
270 | return False, 0 | |
269 |
|
271 | |||
270 | def filemerge(repo, mynode, orig, fcd, fco, fca): |
|
272 | def filemerge(repo, mynode, orig, fcd, fco, fca): | |
271 | """perform a 3-way merge in the working directory |
|
273 | """perform a 3-way merge in the working directory | |
272 |
|
274 | |||
273 | mynode = parent node before merge |
|
275 | mynode = parent node before merge | |
274 | orig = original local filename before merge |
|
276 | orig = original local filename before merge | |
275 | fco = other file context |
|
277 | fco = other file context | |
276 | fca = ancestor file context |
|
278 | fca = ancestor file context | |
277 | fcd = local file context for current/destination file |
|
279 | fcd = local file context for current/destination file | |
278 | """ |
|
280 | """ | |
279 |
|
281 | |||
280 | def temp(prefix, ctx): |
|
282 | def temp(prefix, ctx): | |
281 | pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) |
|
283 | pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) | |
282 | (fd, name) = tempfile.mkstemp(prefix=pre) |
|
284 | (fd, name) = tempfile.mkstemp(prefix=pre) | |
283 | data = repo.wwritedata(ctx.path(), ctx.data()) |
|
285 | data = repo.wwritedata(ctx.path(), ctx.data()) | |
284 | f = os.fdopen(fd, "wb") |
|
286 | f = os.fdopen(fd, "wb") | |
285 | f.write(data) |
|
287 | f.write(data) | |
286 | f.close() |
|
288 | f.close() | |
287 | return name |
|
289 | return name | |
288 |
|
290 | |||
289 | if not fco.cmp(fcd): # files identical? |
|
291 | if not fco.cmp(fcd): # files identical? | |
290 | return None |
|
292 | return None | |
291 |
|
293 | |||
292 | ui = repo.ui |
|
294 | ui = repo.ui | |
293 | fd = fcd.path() |
|
295 | fd = fcd.path() | |
294 | binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() |
|
296 | binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() | |
295 | symlink = 'l' in fcd.flags() + fco.flags() |
|
297 | symlink = 'l' in fcd.flags() + fco.flags() | |
296 | tool, toolpath = _picktool(repo, ui, fd, binary, symlink) |
|
298 | tool, toolpath = _picktool(repo, ui, fd, binary, symlink) | |
297 | ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % |
|
299 | ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % | |
298 | (tool, fd, binary, symlink)) |
|
300 | (tool, fd, binary, symlink)) | |
299 |
|
301 | |||
300 | if tool in internals: |
|
302 | if tool in internals: | |
301 | func = internals[tool] |
|
303 | func = internals[tool] | |
302 | trymerge = func.trymerge |
|
304 | trymerge = func.trymerge | |
303 | onfailure = func.onfailure |
|
305 | onfailure = func.onfailure | |
304 | else: |
|
306 | else: | |
305 | func = _xmerge |
|
307 | func = _xmerge | |
306 | trymerge = True |
|
308 | trymerge = True | |
307 | onfailure = _("merging %s failed!\n") |
|
309 | onfailure = _("merging %s failed!\n") | |
308 |
|
310 | |||
309 | toolconf = tool, toolpath, binary, symlink |
|
311 | toolconf = tool, toolpath, binary, symlink | |
310 |
|
312 | |||
311 | if not trymerge: |
|
313 | if not trymerge: | |
312 | return func(repo, mynode, orig, fcd, fco, fca, toolconf) |
|
314 | return func(repo, mynode, orig, fcd, fco, fca, toolconf) | |
313 |
|
315 | |||
314 | a = repo.wjoin(fd) |
|
316 | a = repo.wjoin(fd) | |
315 | b = temp("base", fca) |
|
317 | b = temp("base", fca) | |
316 | c = temp("other", fco) |
|
318 | c = temp("other", fco) | |
317 | back = a + ".orig" |
|
319 | back = a + ".orig" | |
318 | util.copyfile(a, back) |
|
320 | util.copyfile(a, back) | |
319 |
|
321 | |||
320 | if orig != fco.path(): |
|
322 | if orig != fco.path(): | |
321 | ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) |
|
323 | ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) | |
322 | else: |
|
324 | else: | |
323 | ui.status(_("merging %s\n") % fd) |
|
325 | ui.status(_("merging %s\n") % fd) | |
324 |
|
326 | |||
325 | ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) |
|
327 | ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) | |
326 |
|
328 | |||
327 | needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, |
|
329 | needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, | |
328 | (a, b, c, back)) |
|
330 | (a, b, c, back)) | |
329 | if not needcheck: |
|
331 | if not needcheck: | |
330 | if r: |
|
332 | if r: | |
331 | if onfailure: |
|
333 | if onfailure: | |
332 | ui.warn(onfailure % fd) |
|
334 | ui.warn(onfailure % fd) | |
333 | else: |
|
335 | else: | |
334 | os.unlink(back) |
|
336 | os.unlink(back) | |
335 |
|
337 | |||
336 | os.unlink(b) |
|
338 | os.unlink(b) | |
337 | os.unlink(c) |
|
339 | os.unlink(c) | |
338 | return r |
|
340 | return r | |
339 |
|
341 | |||
340 | if not r and (_toolbool(ui, tool, "checkconflicts") or |
|
342 | if not r and (_toolbool(ui, tool, "checkconflicts") or | |
341 | 'conflicts' in _toollist(ui, tool, "check")): |
|
343 | 'conflicts' in _toollist(ui, tool, "check")): | |
342 | if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), |
|
344 | if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), | |
343 | re.MULTILINE): |
|
345 | re.MULTILINE): | |
344 | r = 1 |
|
346 | r = 1 | |
345 |
|
347 | |||
346 | checked = False |
|
348 | checked = False | |
347 | if 'prompt' in _toollist(ui, tool, "check"): |
|
349 | if 'prompt' in _toollist(ui, tool, "check"): | |
348 | checked = True |
|
350 | checked = True | |
349 | if ui.promptchoice(_("was merge of '%s' successful (yn)?") % fd, |
|
351 | if ui.promptchoice(_("was merge of '%s' successful (yn)?") % fd, | |
350 | (_("&Yes"), _("&No")), 1): |
|
352 | (_("&Yes"), _("&No")), 1): | |
351 | r = 1 |
|
353 | r = 1 | |
352 |
|
354 | |||
353 | if not r and not checked and (_toolbool(ui, tool, "checkchanged") or |
|
355 | if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | |
354 | 'changed' in _toollist(ui, tool, "check")): |
|
356 | 'changed' in _toollist(ui, tool, "check")): | |
355 | if filecmp.cmp(a, back): |
|
357 | if filecmp.cmp(a, back): | |
356 | if ui.promptchoice(_(" output file %s appears unchanged\n" |
|
358 | if ui.promptchoice(_(" output file %s appears unchanged\n" | |
357 | "was merge successful (yn)?") % fd, |
|
359 | "was merge successful (yn)?") % fd, | |
358 | (_("&Yes"), _("&No")), 1): |
|
360 | (_("&Yes"), _("&No")), 1): | |
359 | r = 1 |
|
361 | r = 1 | |
360 |
|
362 | |||
361 | if _toolbool(ui, tool, "fixeol"): |
|
363 | if _toolbool(ui, tool, "fixeol"): | |
362 | _matcheol(a, back) |
|
364 | _matcheol(a, back) | |
363 |
|
365 | |||
364 | if r: |
|
366 | if r: | |
365 | if onfailure: |
|
367 | if onfailure: | |
366 | ui.warn(onfailure % fd) |
|
368 | ui.warn(onfailure % fd) | |
367 | else: |
|
369 | else: | |
368 | os.unlink(back) |
|
370 | os.unlink(back) | |
369 |
|
371 | |||
370 | os.unlink(b) |
|
372 | os.unlink(b) | |
371 | os.unlink(c) |
|
373 | os.unlink(c) | |
372 | return r |
|
374 | return r | |
373 |
|
375 | |||
374 | # tell hggettext to extract docstrings from these functions: |
|
376 | # tell hggettext to extract docstrings from these functions: | |
375 | i18nfunctions = internals.values() |
|
377 | i18nfunctions = internals.values() |
@@ -1,851 +1,852 b'' | |||||
1 | test merge-tools configuration - mostly exercising filemerge.py |
|
1 | test merge-tools configuration - mostly exercising filemerge.py | |
2 |
|
2 | |||
3 | $ unset HGMERGE # make sure HGMERGE doesn't interfere with the test |
|
3 | $ unset HGMERGE # make sure HGMERGE doesn't interfere with the test | |
4 | $ hg init |
|
4 | $ hg init | |
5 |
|
5 | |||
6 | revision 0 |
|
6 | revision 0 | |
7 |
|
7 | |||
8 | $ echo "revision 0" > f |
|
8 | $ echo "revision 0" > f | |
9 | $ echo "space" >> f |
|
9 | $ echo "space" >> f | |
10 | $ hg commit -Am "revision 0" |
|
10 | $ hg commit -Am "revision 0" | |
11 | adding f |
|
11 | adding f | |
12 |
|
12 | |||
13 | revision 1 |
|
13 | revision 1 | |
14 |
|
14 | |||
15 | $ echo "revision 1" > f |
|
15 | $ echo "revision 1" > f | |
16 | $ echo "space" >> f |
|
16 | $ echo "space" >> f | |
17 | $ hg commit -Am "revision 1" |
|
17 | $ hg commit -Am "revision 1" | |
18 | $ hg update 0 > /dev/null |
|
18 | $ hg update 0 > /dev/null | |
19 |
|
19 | |||
20 | revision 2 |
|
20 | revision 2 | |
21 |
|
21 | |||
22 | $ echo "revision 2" > f |
|
22 | $ echo "revision 2" > f | |
23 | $ echo "space" >> f |
|
23 | $ echo "space" >> f | |
24 | $ hg commit -Am "revision 2" |
|
24 | $ hg commit -Am "revision 2" | |
25 | created new head |
|
25 | created new head | |
26 | $ hg update 0 > /dev/null |
|
26 | $ hg update 0 > /dev/null | |
27 |
|
27 | |||
28 | revision 3 - simple to merge |
|
28 | revision 3 - simple to merge | |
29 |
|
29 | |||
30 | $ echo "revision 3" >> f |
|
30 | $ echo "revision 3" >> f | |
31 | $ hg commit -Am "revision 3" |
|
31 | $ hg commit -Am "revision 3" | |
32 | created new head |
|
32 | created new head | |
33 | $ echo "[merge-tools]" > .hg/hgrc |
|
33 | $ echo "[merge-tools]" > .hg/hgrc | |
34 |
|
34 | |||
35 | $ beforemerge() { |
|
35 | $ beforemerge() { | |
36 | > cat .hg/hgrc |
|
36 | > cat .hg/hgrc | |
37 | > echo "# hg update -C 1" |
|
37 | > echo "# hg update -C 1" | |
38 | > hg update -C 1 > /dev/null |
|
38 | > hg update -C 1 > /dev/null | |
39 | > } |
|
39 | > } | |
40 | $ aftermerge() { |
|
40 | $ aftermerge() { | |
41 | > echo "# cat f" |
|
41 | > echo "# cat f" | |
42 | > cat f |
|
42 | > cat f | |
43 | > echo "# hg stat" |
|
43 | > echo "# hg stat" | |
44 | > hg stat |
|
44 | > hg stat | |
45 | > rm -f f.orig |
|
45 | > rm -f f.orig | |
46 | > } |
|
46 | > } | |
47 |
|
47 | |||
48 | Tool selection |
|
48 | Tool selection | |
49 |
|
49 | |||
50 | default is internal merge: |
|
50 | default is internal merge: | |
51 |
|
51 | |||
52 | $ beforemerge |
|
52 | $ beforemerge | |
53 | [merge-tools] |
|
53 | [merge-tools] | |
54 | # hg update -C 1 |
|
54 | # hg update -C 1 | |
55 |
|
55 | |||
56 | hg merge -r 2 |
|
56 | hg merge -r 2 | |
57 | override $PATH to ensure hgmerge not visible; use $PYTHON in case we're |
|
57 | override $PATH to ensure hgmerge not visible; use $PYTHON in case we're | |
58 | running from a devel copy, not a temp installation |
|
58 | running from a devel copy, not a temp installation | |
59 |
|
59 | |||
60 | $ PATH="$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 |
|
60 | $ PATH="$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 | |
61 | merging f |
|
61 | merging f | |
62 | warning: conflicts during merge. |
|
62 | warning: conflicts during merge. | |
63 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') |
|
63 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') | |
64 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
64 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
65 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
65 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
66 | [1] |
|
66 | [1] | |
67 | $ aftermerge |
|
67 | $ aftermerge | |
68 | # cat f |
|
68 | # cat f | |
69 | <<<<<<< local |
|
69 | <<<<<<< local | |
70 | revision 1 |
|
70 | revision 1 | |
71 | ======= |
|
71 | ======= | |
72 | revision 2 |
|
72 | revision 2 | |
73 | >>>>>>> other |
|
73 | >>>>>>> other | |
74 | space |
|
74 | space | |
75 | # hg stat |
|
75 | # hg stat | |
76 | M f |
|
76 | M f | |
77 | ? f.orig |
|
77 | ? f.orig | |
78 |
|
78 | |||
79 | simplest hgrc using false for merge: |
|
79 | simplest hgrc using false for merge: | |
80 |
|
80 | |||
81 | $ echo "false.whatever=" >> .hg/hgrc |
|
81 | $ echo "false.whatever=" >> .hg/hgrc | |
82 | $ beforemerge |
|
82 | $ beforemerge | |
83 | [merge-tools] |
|
83 | [merge-tools] | |
84 | false.whatever= |
|
84 | false.whatever= | |
85 | # hg update -C 1 |
|
85 | # hg update -C 1 | |
86 | $ hg merge -r 2 |
|
86 | $ hg merge -r 2 | |
87 | merging f |
|
87 | merging f | |
88 | merging f failed! |
|
88 | merging f failed! | |
89 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
89 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
90 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
90 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
91 | [1] |
|
91 | [1] | |
92 | $ aftermerge |
|
92 | $ aftermerge | |
93 | # cat f |
|
93 | # cat f | |
94 | revision 1 |
|
94 | revision 1 | |
95 | space |
|
95 | space | |
96 | # hg stat |
|
96 | # hg stat | |
97 | M f |
|
97 | M f | |
98 | ? f.orig |
|
98 | ? f.orig | |
99 |
|
99 | |||
100 | unexecutable file in $PATH shouldn't be found: |
|
100 | unexecutable file in $PATH shouldn't be found: | |
101 |
|
101 | |||
102 | $ touch false |
|
102 | $ touch false | |
103 | $ hg up -qC 1 |
|
103 | $ hg up -qC 1 | |
104 | $ PATH="`pwd`:$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 |
|
104 | $ PATH="`pwd`:$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 | |
105 | merging f |
|
105 | merging f | |
106 | warning: conflicts during merge. |
|
106 | warning: conflicts during merge. | |
107 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') |
|
107 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') | |
108 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
108 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
109 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
109 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
110 | [1] |
|
110 | [1] | |
111 | $ rm false |
|
111 | $ rm false | |
112 |
|
112 | |||
113 | executable directory in $PATH shouldn't be found: |
|
113 | executable directory in $PATH shouldn't be found: | |
114 |
|
114 | |||
115 | $ mkdir false |
|
115 | $ mkdir false | |
116 | $ hg up -qC 1 |
|
116 | $ hg up -qC 1 | |
117 | $ PATH="`pwd`:$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 |
|
117 | $ PATH="`pwd`:$BINDIR" $PYTHON "$BINDIR"/hg merge -r 2 | |
118 | merging f |
|
118 | merging f | |
119 | warning: conflicts during merge. |
|
119 | warning: conflicts during merge. | |
120 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') |
|
120 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') | |
121 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
121 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
122 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
122 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
123 | [1] |
|
123 | [1] | |
124 | $ rmdir false |
|
124 | $ rmdir false | |
125 |
|
125 | |||
126 | true with higher .priority gets precedence: |
|
126 | true with higher .priority gets precedence: | |
127 |
|
127 | |||
128 | $ echo "true.priority=1" >> .hg/hgrc |
|
128 | $ echo "true.priority=1" >> .hg/hgrc | |
129 | $ beforemerge |
|
129 | $ beforemerge | |
130 | [merge-tools] |
|
130 | [merge-tools] | |
131 | false.whatever= |
|
131 | false.whatever= | |
132 | true.priority=1 |
|
132 | true.priority=1 | |
133 | # hg update -C 1 |
|
133 | # hg update -C 1 | |
134 | $ hg merge -r 2 |
|
134 | $ hg merge -r 2 | |
135 | merging f |
|
135 | merging f | |
136 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
136 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
137 | (branch merge, don't forget to commit) |
|
137 | (branch merge, don't forget to commit) | |
138 | $ aftermerge |
|
138 | $ aftermerge | |
139 | # cat f |
|
139 | # cat f | |
140 | revision 1 |
|
140 | revision 1 | |
141 | space |
|
141 | space | |
142 | # hg stat |
|
142 | # hg stat | |
143 | M f |
|
143 | M f | |
144 |
|
144 | |||
145 | unless lowered on command line: |
|
145 | unless lowered on command line: | |
146 |
|
146 | |||
147 | $ beforemerge |
|
147 | $ beforemerge | |
148 | [merge-tools] |
|
148 | [merge-tools] | |
149 | false.whatever= |
|
149 | false.whatever= | |
150 | true.priority=1 |
|
150 | true.priority=1 | |
151 | # hg update -C 1 |
|
151 | # hg update -C 1 | |
152 | $ hg merge -r 2 --config merge-tools.true.priority=-7 |
|
152 | $ hg merge -r 2 --config merge-tools.true.priority=-7 | |
153 | merging f |
|
153 | merging f | |
154 | merging f failed! |
|
154 | merging f failed! | |
155 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
155 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
156 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
156 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
157 | [1] |
|
157 | [1] | |
158 | $ aftermerge |
|
158 | $ aftermerge | |
159 | # cat f |
|
159 | # cat f | |
160 | revision 1 |
|
160 | revision 1 | |
161 | space |
|
161 | space | |
162 | # hg stat |
|
162 | # hg stat | |
163 | M f |
|
163 | M f | |
164 | ? f.orig |
|
164 | ? f.orig | |
165 |
|
165 | |||
166 | or false set higher on command line: |
|
166 | or false set higher on command line: | |
167 |
|
167 | |||
168 | $ beforemerge |
|
168 | $ beforemerge | |
169 | [merge-tools] |
|
169 | [merge-tools] | |
170 | false.whatever= |
|
170 | false.whatever= | |
171 | true.priority=1 |
|
171 | true.priority=1 | |
172 | # hg update -C 1 |
|
172 | # hg update -C 1 | |
173 | $ hg merge -r 2 --config merge-tools.false.priority=117 |
|
173 | $ hg merge -r 2 --config merge-tools.false.priority=117 | |
174 | merging f |
|
174 | merging f | |
175 | merging f failed! |
|
175 | merging f failed! | |
176 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
176 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
177 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
177 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
178 | [1] |
|
178 | [1] | |
179 | $ aftermerge |
|
179 | $ aftermerge | |
180 | # cat f |
|
180 | # cat f | |
181 | revision 1 |
|
181 | revision 1 | |
182 | space |
|
182 | space | |
183 | # hg stat |
|
183 | # hg stat | |
184 | M f |
|
184 | M f | |
185 | ? f.orig |
|
185 | ? f.orig | |
186 |
|
186 | |||
187 | or true.executable not found in PATH: |
|
187 | or true.executable not found in PATH: | |
188 |
|
188 | |||
189 | $ beforemerge |
|
189 | $ beforemerge | |
190 | [merge-tools] |
|
190 | [merge-tools] | |
191 | false.whatever= |
|
191 | false.whatever= | |
192 | true.priority=1 |
|
192 | true.priority=1 | |
193 | # hg update -C 1 |
|
193 | # hg update -C 1 | |
194 | $ hg merge -r 2 --config merge-tools.true.executable=nonexistentmergetool |
|
194 | $ hg merge -r 2 --config merge-tools.true.executable=nonexistentmergetool | |
195 | merging f |
|
195 | merging f | |
196 | merging f failed! |
|
196 | merging f failed! | |
197 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
197 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
198 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
198 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
199 | [1] |
|
199 | [1] | |
200 | $ aftermerge |
|
200 | $ aftermerge | |
201 | # cat f |
|
201 | # cat f | |
202 | revision 1 |
|
202 | revision 1 | |
203 | space |
|
203 | space | |
204 | # hg stat |
|
204 | # hg stat | |
205 | M f |
|
205 | M f | |
206 | ? f.orig |
|
206 | ? f.orig | |
207 |
|
207 | |||
208 | or true.executable with bogus path: |
|
208 | or true.executable with bogus path: | |
209 |
|
209 | |||
210 | $ beforemerge |
|
210 | $ beforemerge | |
211 | [merge-tools] |
|
211 | [merge-tools] | |
212 | false.whatever= |
|
212 | false.whatever= | |
213 | true.priority=1 |
|
213 | true.priority=1 | |
214 | # hg update -C 1 |
|
214 | # hg update -C 1 | |
215 | $ hg merge -r 2 --config merge-tools.true.executable=/nonexistent/mergetool |
|
215 | $ hg merge -r 2 --config merge-tools.true.executable=/nonexistent/mergetool | |
216 | merging f |
|
216 | merging f | |
217 | merging f failed! |
|
217 | merging f failed! | |
218 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
218 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
219 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
219 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
220 | [1] |
|
220 | [1] | |
221 | $ aftermerge |
|
221 | $ aftermerge | |
222 | # cat f |
|
222 | # cat f | |
223 | revision 1 |
|
223 | revision 1 | |
224 | space |
|
224 | space | |
225 | # hg stat |
|
225 | # hg stat | |
226 | M f |
|
226 | M f | |
227 | ? f.orig |
|
227 | ? f.orig | |
228 |
|
228 | |||
229 | but true.executable set to cat found in PATH works: |
|
229 | but true.executable set to cat found in PATH works: | |
230 |
|
230 | |||
231 | $ echo "true.executable=cat" >> .hg/hgrc |
|
231 | $ echo "true.executable=cat" >> .hg/hgrc | |
232 | $ beforemerge |
|
232 | $ beforemerge | |
233 | [merge-tools] |
|
233 | [merge-tools] | |
234 | false.whatever= |
|
234 | false.whatever= | |
235 | true.priority=1 |
|
235 | true.priority=1 | |
236 | true.executable=cat |
|
236 | true.executable=cat | |
237 | # hg update -C 1 |
|
237 | # hg update -C 1 | |
238 | $ hg merge -r 2 |
|
238 | $ hg merge -r 2 | |
239 | merging f |
|
239 | merging f | |
240 | revision 1 |
|
240 | revision 1 | |
241 | space |
|
241 | space | |
242 | revision 0 |
|
242 | revision 0 | |
243 | space |
|
243 | space | |
244 | revision 2 |
|
244 | revision 2 | |
245 | space |
|
245 | space | |
246 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
246 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
247 | (branch merge, don't forget to commit) |
|
247 | (branch merge, don't forget to commit) | |
248 | $ aftermerge |
|
248 | $ aftermerge | |
249 | # cat f |
|
249 | # cat f | |
250 | revision 1 |
|
250 | revision 1 | |
251 | space |
|
251 | space | |
252 | # hg stat |
|
252 | # hg stat | |
253 | M f |
|
253 | M f | |
254 |
|
254 | |||
255 | and true.executable set to cat with path works: |
|
255 | and true.executable set to cat with path works: | |
256 |
|
256 | |||
257 | $ beforemerge |
|
257 | $ beforemerge | |
258 | [merge-tools] |
|
258 | [merge-tools] | |
259 | false.whatever= |
|
259 | false.whatever= | |
260 | true.priority=1 |
|
260 | true.priority=1 | |
261 | true.executable=cat |
|
261 | true.executable=cat | |
262 | # hg update -C 1 |
|
262 | # hg update -C 1 | |
263 | $ hg merge -r 2 --config merge-tools.true.executable=cat |
|
263 | $ hg merge -r 2 --config merge-tools.true.executable=cat | |
264 | merging f |
|
264 | merging f | |
265 | revision 1 |
|
265 | revision 1 | |
266 | space |
|
266 | space | |
267 | revision 0 |
|
267 | revision 0 | |
268 | space |
|
268 | space | |
269 | revision 2 |
|
269 | revision 2 | |
270 | space |
|
270 | space | |
271 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
271 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
272 | (branch merge, don't forget to commit) |
|
272 | (branch merge, don't forget to commit) | |
273 | $ aftermerge |
|
273 | $ aftermerge | |
274 | # cat f |
|
274 | # cat f | |
275 | revision 1 |
|
275 | revision 1 | |
276 | space |
|
276 | space | |
277 | # hg stat |
|
277 | # hg stat | |
278 | M f |
|
278 | M f | |
279 |
|
279 | |||
280 | #if unix-permissions |
|
280 | #if unix-permissions | |
281 |
|
281 | |||
282 | environment variables in true.executable are handled: |
|
282 | environment variables in true.executable are handled: | |
283 |
|
283 | |||
284 | $ echo 'echo "custom merge tool"' > "$HGTMP/merge.sh" |
|
284 | $ echo 'echo "custom merge tool"' > "$HGTMP/merge.sh" | |
285 | $ beforemerge |
|
285 | $ beforemerge | |
286 | [merge-tools] |
|
286 | [merge-tools] | |
287 | false.whatever= |
|
287 | false.whatever= | |
288 | true.priority=1 |
|
288 | true.priority=1 | |
289 | true.executable=cat |
|
289 | true.executable=cat | |
290 | # hg update -C 1 |
|
290 | # hg update -C 1 | |
291 | $ hg --config merge-tools.true.executable='sh' \ |
|
291 | $ hg --config merge-tools.true.executable='sh' \ | |
292 | > --config merge-tools.true.args="$HGTMP/merge.sh" \ |
|
292 | > --config merge-tools.true.args="$HGTMP/merge.sh" \ | |
293 | > merge -r 2 |
|
293 | > merge -r 2 | |
294 | merging f |
|
294 | merging f | |
295 | custom merge tool |
|
295 | custom merge tool | |
296 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
296 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
297 | (branch merge, don't forget to commit) |
|
297 | (branch merge, don't forget to commit) | |
298 | $ aftermerge |
|
298 | $ aftermerge | |
299 | # cat f |
|
299 | # cat f | |
300 | revision 1 |
|
300 | revision 1 | |
301 | space |
|
301 | space | |
302 | # hg stat |
|
302 | # hg stat | |
303 | M f |
|
303 | M f | |
304 |
|
304 | |||
305 | #endif |
|
305 | #endif | |
306 |
|
306 | |||
307 | Tool selection and merge-patterns |
|
307 | Tool selection and merge-patterns | |
308 |
|
308 | |||
309 | merge-patterns specifies new tool false: |
|
309 | merge-patterns specifies new tool false: | |
310 |
|
310 | |||
311 | $ beforemerge |
|
311 | $ beforemerge | |
312 | [merge-tools] |
|
312 | [merge-tools] | |
313 | false.whatever= |
|
313 | false.whatever= | |
314 | true.priority=1 |
|
314 | true.priority=1 | |
315 | true.executable=cat |
|
315 | true.executable=cat | |
316 | # hg update -C 1 |
|
316 | # hg update -C 1 | |
317 | $ hg merge -r 2 --config merge-patterns.f=false |
|
317 | $ hg merge -r 2 --config merge-patterns.f=false | |
318 | merging f |
|
318 | merging f | |
319 | merging f failed! |
|
319 | merging f failed! | |
320 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
320 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
321 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
321 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
322 | [1] |
|
322 | [1] | |
323 | $ aftermerge |
|
323 | $ aftermerge | |
324 | # cat f |
|
324 | # cat f | |
325 | revision 1 |
|
325 | revision 1 | |
326 | space |
|
326 | space | |
327 | # hg stat |
|
327 | # hg stat | |
328 | M f |
|
328 | M f | |
329 | ? f.orig |
|
329 | ? f.orig | |
330 |
|
330 | |||
331 | merge-patterns specifies executable not found in PATH and gets warning: |
|
331 | merge-patterns specifies executable not found in PATH and gets warning: | |
332 |
|
332 | |||
333 | $ beforemerge |
|
333 | $ beforemerge | |
334 | [merge-tools] |
|
334 | [merge-tools] | |
335 | false.whatever= |
|
335 | false.whatever= | |
336 | true.priority=1 |
|
336 | true.priority=1 | |
337 | true.executable=cat |
|
337 | true.executable=cat | |
338 | # hg update -C 1 |
|
338 | # hg update -C 1 | |
339 | $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool |
|
339 | $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool | |
340 | couldn't find merge tool true specified for f |
|
340 | couldn't find merge tool true specified for f | |
341 | merging f |
|
341 | merging f | |
342 | merging f failed! |
|
342 | merging f failed! | |
343 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
343 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
344 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
344 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
345 | [1] |
|
345 | [1] | |
346 | $ aftermerge |
|
346 | $ aftermerge | |
347 | # cat f |
|
347 | # cat f | |
348 | revision 1 |
|
348 | revision 1 | |
349 | space |
|
349 | space | |
350 | # hg stat |
|
350 | # hg stat | |
351 | M f |
|
351 | M f | |
352 | ? f.orig |
|
352 | ? f.orig | |
353 |
|
353 | |||
354 | merge-patterns specifies executable with bogus path and gets warning: |
|
354 | merge-patterns specifies executable with bogus path and gets warning: | |
355 |
|
355 | |||
356 | $ beforemerge |
|
356 | $ beforemerge | |
357 | [merge-tools] |
|
357 | [merge-tools] | |
358 | false.whatever= |
|
358 | false.whatever= | |
359 | true.priority=1 |
|
359 | true.priority=1 | |
360 | true.executable=cat |
|
360 | true.executable=cat | |
361 | # hg update -C 1 |
|
361 | # hg update -C 1 | |
362 | $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexistent/mergetool |
|
362 | $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexistent/mergetool | |
363 | couldn't find merge tool true specified for f |
|
363 | couldn't find merge tool true specified for f | |
364 | merging f |
|
364 | merging f | |
365 | merging f failed! |
|
365 | merging f failed! | |
366 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
366 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
367 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
367 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
368 | [1] |
|
368 | [1] | |
369 | $ aftermerge |
|
369 | $ aftermerge | |
370 | # cat f |
|
370 | # cat f | |
371 | revision 1 |
|
371 | revision 1 | |
372 | space |
|
372 | space | |
373 | # hg stat |
|
373 | # hg stat | |
374 | M f |
|
374 | M f | |
375 | ? f.orig |
|
375 | ? f.orig | |
376 |
|
376 | |||
377 | ui.merge overrules priority |
|
377 | ui.merge overrules priority | |
378 |
|
378 | |||
379 | ui.merge specifies false: |
|
379 | ui.merge specifies false: | |
380 |
|
380 | |||
381 | $ beforemerge |
|
381 | $ beforemerge | |
382 | [merge-tools] |
|
382 | [merge-tools] | |
383 | false.whatever= |
|
383 | false.whatever= | |
384 | true.priority=1 |
|
384 | true.priority=1 | |
385 | true.executable=cat |
|
385 | true.executable=cat | |
386 | # hg update -C 1 |
|
386 | # hg update -C 1 | |
387 | $ hg merge -r 2 --config ui.merge=false |
|
387 | $ hg merge -r 2 --config ui.merge=false | |
388 | merging f |
|
388 | merging f | |
389 | merging f failed! |
|
389 | merging f failed! | |
390 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
390 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
391 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
391 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
392 | [1] |
|
392 | [1] | |
393 | $ aftermerge |
|
393 | $ aftermerge | |
394 | # cat f |
|
394 | # cat f | |
395 | revision 1 |
|
395 | revision 1 | |
396 | space |
|
396 | space | |
397 | # hg stat |
|
397 | # hg stat | |
398 | M f |
|
398 | M f | |
399 | ? f.orig |
|
399 | ? f.orig | |
400 |
|
400 | |||
401 | ui.merge specifies internal:fail: |
|
401 | ui.merge specifies internal:fail: | |
402 |
|
402 | |||
403 | $ beforemerge |
|
403 | $ beforemerge | |
404 | [merge-tools] |
|
404 | [merge-tools] | |
405 | false.whatever= |
|
405 | false.whatever= | |
406 | true.priority=1 |
|
406 | true.priority=1 | |
407 | true.executable=cat |
|
407 | true.executable=cat | |
408 | # hg update -C 1 |
|
408 | # hg update -C 1 | |
409 | $ hg merge -r 2 --config ui.merge=internal:fail |
|
409 | $ hg merge -r 2 --config ui.merge=internal:fail | |
410 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
410 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
411 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
411 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
412 | [1] |
|
412 | [1] | |
413 | $ aftermerge |
|
413 | $ aftermerge | |
414 | # cat f |
|
414 | # cat f | |
415 | revision 1 |
|
415 | revision 1 | |
416 | space |
|
416 | space | |
417 | # hg stat |
|
417 | # hg stat | |
418 | M f |
|
418 | M f | |
419 |
|
419 | |||
420 | ui.merge specifies internal:local: |
|
420 | ui.merge specifies internal:local: | |
421 |
|
421 | |||
422 | $ beforemerge |
|
422 | $ beforemerge | |
423 | [merge-tools] |
|
423 | [merge-tools] | |
424 | false.whatever= |
|
424 | false.whatever= | |
425 | true.priority=1 |
|
425 | true.priority=1 | |
426 | true.executable=cat |
|
426 | true.executable=cat | |
427 | # hg update -C 1 |
|
427 | # hg update -C 1 | |
428 | $ hg merge -r 2 --config ui.merge=internal:local |
|
428 | $ hg merge -r 2 --config ui.merge=internal:local | |
429 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
429 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
430 | (branch merge, don't forget to commit) |
|
430 | (branch merge, don't forget to commit) | |
431 | $ aftermerge |
|
431 | $ aftermerge | |
432 | # cat f |
|
432 | # cat f | |
433 | revision 1 |
|
433 | revision 1 | |
434 | space |
|
434 | space | |
435 | # hg stat |
|
435 | # hg stat | |
436 | M f |
|
436 | M f | |
437 |
|
437 | |||
438 | ui.merge specifies internal:other: |
|
438 | ui.merge specifies internal:other: | |
439 |
|
439 | |||
440 | $ beforemerge |
|
440 | $ beforemerge | |
441 | [merge-tools] |
|
441 | [merge-tools] | |
442 | false.whatever= |
|
442 | false.whatever= | |
443 | true.priority=1 |
|
443 | true.priority=1 | |
444 | true.executable=cat |
|
444 | true.executable=cat | |
445 | # hg update -C 1 |
|
445 | # hg update -C 1 | |
446 | $ hg merge -r 2 --config ui.merge=internal:other |
|
446 | $ hg merge -r 2 --config ui.merge=internal:other | |
447 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
447 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
448 | (branch merge, don't forget to commit) |
|
448 | (branch merge, don't forget to commit) | |
449 | $ aftermerge |
|
449 | $ aftermerge | |
450 | # cat f |
|
450 | # cat f | |
451 | revision 2 |
|
451 | revision 2 | |
452 | space |
|
452 | space | |
453 | # hg stat |
|
453 | # hg stat | |
454 | M f |
|
454 | M f | |
455 |
|
455 | |||
456 | ui.merge specifies internal:prompt: |
|
456 | ui.merge specifies internal:prompt: | |
457 |
|
457 | |||
458 | $ beforemerge |
|
458 | $ beforemerge | |
459 | [merge-tools] |
|
459 | [merge-tools] | |
460 | false.whatever= |
|
460 | false.whatever= | |
461 | true.priority=1 |
|
461 | true.priority=1 | |
462 | true.executable=cat |
|
462 | true.executable=cat | |
463 | # hg update -C 1 |
|
463 | # hg update -C 1 | |
464 | $ hg merge -r 2 --config ui.merge=internal:prompt |
|
464 | $ hg merge -r 2 --config ui.merge=internal:prompt | |
465 | no tool found to merge f |
|
465 | no tool found to merge f | |
466 | keep (l)ocal or take (o)ther? l |
|
466 | keep (l)ocal or take (o)ther? l | |
467 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
467 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
468 | (branch merge, don't forget to commit) |
|
468 | (branch merge, don't forget to commit) | |
469 | $ aftermerge |
|
469 | $ aftermerge | |
470 | # cat f |
|
470 | # cat f | |
471 | revision 1 |
|
471 | revision 1 | |
472 | space |
|
472 | space | |
473 | # hg stat |
|
473 | # hg stat | |
474 | M f |
|
474 | M f | |
475 |
|
475 | |||
476 | ui.merge specifies internal:dump: |
|
476 | ui.merge specifies internal:dump: | |
477 |
|
477 | |||
478 | $ beforemerge |
|
478 | $ beforemerge | |
479 | [merge-tools] |
|
479 | [merge-tools] | |
480 | false.whatever= |
|
480 | false.whatever= | |
481 | true.priority=1 |
|
481 | true.priority=1 | |
482 | true.executable=cat |
|
482 | true.executable=cat | |
483 | # hg update -C 1 |
|
483 | # hg update -C 1 | |
484 | $ hg merge -r 2 --config ui.merge=internal:dump |
|
484 | $ hg merge -r 2 --config ui.merge=internal:dump | |
485 | merging f |
|
485 | merging f | |
486 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
486 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
487 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
487 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
488 | [1] |
|
488 | [1] | |
489 | $ aftermerge |
|
489 | $ aftermerge | |
490 | # cat f |
|
490 | # cat f | |
491 | revision 1 |
|
491 | revision 1 | |
492 | space |
|
492 | space | |
493 | # hg stat |
|
493 | # hg stat | |
494 | M f |
|
494 | M f | |
495 | ? f.base |
|
495 | ? f.base | |
496 | ? f.local |
|
496 | ? f.local | |
497 | ? f.orig |
|
497 | ? f.orig | |
498 | ? f.other |
|
498 | ? f.other | |
499 |
|
499 | |||
500 | f.base: |
|
500 | f.base: | |
501 |
|
501 | |||
502 | $ cat f.base |
|
502 | $ cat f.base | |
503 | revision 0 |
|
503 | revision 0 | |
504 | space |
|
504 | space | |
505 |
|
505 | |||
506 | f.local: |
|
506 | f.local: | |
507 |
|
507 | |||
508 | $ cat f.local |
|
508 | $ cat f.local | |
509 | revision 1 |
|
509 | revision 1 | |
510 | space |
|
510 | space | |
511 |
|
511 | |||
512 | f.other: |
|
512 | f.other: | |
513 |
|
513 | |||
514 | $ cat f.other |
|
514 | $ cat f.other | |
515 | revision 2 |
|
515 | revision 2 | |
516 | space |
|
516 | space | |
517 | $ rm f.base f.local f.other |
|
517 | $ rm f.base f.local f.other | |
518 |
|
518 | |||
519 | ui.merge specifies internal:other but is overruled by pattern for false: |
|
519 | ui.merge specifies internal:other but is overruled by pattern for false: | |
520 |
|
520 | |||
521 | $ beforemerge |
|
521 | $ beforemerge | |
522 | [merge-tools] |
|
522 | [merge-tools] | |
523 | false.whatever= |
|
523 | false.whatever= | |
524 | true.priority=1 |
|
524 | true.priority=1 | |
525 | true.executable=cat |
|
525 | true.executable=cat | |
526 | # hg update -C 1 |
|
526 | # hg update -C 1 | |
527 | $ hg merge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false |
|
527 | $ hg merge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false | |
528 | merging f |
|
528 | merging f | |
529 | merging f failed! |
|
529 | merging f failed! | |
530 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
530 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
531 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
531 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
532 | [1] |
|
532 | [1] | |
533 | $ aftermerge |
|
533 | $ aftermerge | |
534 | # cat f |
|
534 | # cat f | |
535 | revision 1 |
|
535 | revision 1 | |
536 | space |
|
536 | space | |
537 | # hg stat |
|
537 | # hg stat | |
538 | M f |
|
538 | M f | |
539 | ? f.orig |
|
539 | ? f.orig | |
540 |
|
540 | |||
541 | Premerge |
|
541 | Premerge | |
542 |
|
542 | |||
543 | ui.merge specifies internal:other but is overruled by --tool=false |
|
543 | ui.merge specifies internal:other but is overruled by --tool=false | |
544 |
|
544 | |||
545 | $ beforemerge |
|
545 | $ beforemerge | |
546 | [merge-tools] |
|
546 | [merge-tools] | |
547 | false.whatever= |
|
547 | false.whatever= | |
548 | true.priority=1 |
|
548 | true.priority=1 | |
549 | true.executable=cat |
|
549 | true.executable=cat | |
550 | # hg update -C 1 |
|
550 | # hg update -C 1 | |
551 | $ hg merge -r 2 --config ui.merge=internal:other --tool=false |
|
551 | $ hg merge -r 2 --config ui.merge=internal:other --tool=false | |
552 | merging f |
|
552 | merging f | |
553 | merging f failed! |
|
553 | merging f failed! | |
554 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
554 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
555 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
555 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
556 | [1] |
|
556 | [1] | |
557 | $ aftermerge |
|
557 | $ aftermerge | |
558 | # cat f |
|
558 | # cat f | |
559 | revision 1 |
|
559 | revision 1 | |
560 | space |
|
560 | space | |
561 | # hg stat |
|
561 | # hg stat | |
562 | M f |
|
562 | M f | |
563 | ? f.orig |
|
563 | ? f.orig | |
564 |
|
564 | |||
565 | HGMERGE specifies internal:other but is overruled by --tool=false |
|
565 | HGMERGE specifies internal:other but is overruled by --tool=false | |
566 |
|
566 | |||
567 | $ HGMERGE=internal:other ; export HGMERGE |
|
567 | $ HGMERGE=internal:other ; export HGMERGE | |
568 | $ beforemerge |
|
568 | $ beforemerge | |
569 | [merge-tools] |
|
569 | [merge-tools] | |
570 | false.whatever= |
|
570 | false.whatever= | |
571 | true.priority=1 |
|
571 | true.priority=1 | |
572 | true.executable=cat |
|
572 | true.executable=cat | |
573 | # hg update -C 1 |
|
573 | # hg update -C 1 | |
574 | $ hg merge -r 2 --tool=false |
|
574 | $ hg merge -r 2 --tool=false | |
575 | merging f |
|
575 | merging f | |
576 | merging f failed! |
|
576 | merging f failed! | |
577 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
577 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
578 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
578 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
579 | [1] |
|
579 | [1] | |
580 | $ aftermerge |
|
580 | $ aftermerge | |
581 | # cat f |
|
581 | # cat f | |
582 | revision 1 |
|
582 | revision 1 | |
583 | space |
|
583 | space | |
584 | # hg stat |
|
584 | # hg stat | |
585 | M f |
|
585 | M f | |
586 | ? f.orig |
|
586 | ? f.orig | |
587 |
|
587 | |||
588 | $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests |
|
588 | $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests | |
589 |
|
589 | |||
590 | Default is silent simplemerge: |
|
590 | Default is silent simplemerge: | |
591 |
|
591 | |||
592 | $ beforemerge |
|
592 | $ beforemerge | |
593 | [merge-tools] |
|
593 | [merge-tools] | |
594 | false.whatever= |
|
594 | false.whatever= | |
595 | true.priority=1 |
|
595 | true.priority=1 | |
596 | true.executable=cat |
|
596 | true.executable=cat | |
597 | # hg update -C 1 |
|
597 | # hg update -C 1 | |
598 | $ hg merge -r 3 |
|
598 | $ hg merge -r 3 | |
599 | merging f |
|
599 | merging f | |
600 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
600 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
601 | (branch merge, don't forget to commit) |
|
601 | (branch merge, don't forget to commit) | |
602 | $ aftermerge |
|
602 | $ aftermerge | |
603 | # cat f |
|
603 | # cat f | |
604 | revision 1 |
|
604 | revision 1 | |
605 | space |
|
605 | space | |
606 | revision 3 |
|
606 | revision 3 | |
607 | # hg stat |
|
607 | # hg stat | |
608 | M f |
|
608 | M f | |
609 |
|
609 | |||
610 | .premerge=True is same: |
|
610 | .premerge=True is same: | |
611 |
|
611 | |||
612 | $ beforemerge |
|
612 | $ beforemerge | |
613 | [merge-tools] |
|
613 | [merge-tools] | |
614 | false.whatever= |
|
614 | false.whatever= | |
615 | true.priority=1 |
|
615 | true.priority=1 | |
616 | true.executable=cat |
|
616 | true.executable=cat | |
617 | # hg update -C 1 |
|
617 | # hg update -C 1 | |
618 | $ hg merge -r 3 --config merge-tools.true.premerge=True |
|
618 | $ hg merge -r 3 --config merge-tools.true.premerge=True | |
619 | merging f |
|
619 | merging f | |
620 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
620 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
621 | (branch merge, don't forget to commit) |
|
621 | (branch merge, don't forget to commit) | |
622 | $ aftermerge |
|
622 | $ aftermerge | |
623 | # cat f |
|
623 | # cat f | |
624 | revision 1 |
|
624 | revision 1 | |
625 | space |
|
625 | space | |
626 | revision 3 |
|
626 | revision 3 | |
627 | # hg stat |
|
627 | # hg stat | |
628 | M f |
|
628 | M f | |
629 |
|
629 | |||
630 | .premerge=False executes merge-tool: |
|
630 | .premerge=False executes merge-tool: | |
631 |
|
631 | |||
632 | $ beforemerge |
|
632 | $ beforemerge | |
633 | [merge-tools] |
|
633 | [merge-tools] | |
634 | false.whatever= |
|
634 | false.whatever= | |
635 | true.priority=1 |
|
635 | true.priority=1 | |
636 | true.executable=cat |
|
636 | true.executable=cat | |
637 | # hg update -C 1 |
|
637 | # hg update -C 1 | |
638 | $ hg merge -r 3 --config merge-tools.true.premerge=False |
|
638 | $ hg merge -r 3 --config merge-tools.true.premerge=False | |
639 | merging f |
|
639 | merging f | |
640 | revision 1 |
|
640 | revision 1 | |
641 | space |
|
641 | space | |
642 | revision 0 |
|
642 | revision 0 | |
643 | space |
|
643 | space | |
644 | revision 0 |
|
644 | revision 0 | |
645 | space |
|
645 | space | |
646 | revision 3 |
|
646 | revision 3 | |
647 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
647 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
648 | (branch merge, don't forget to commit) |
|
648 | (branch merge, don't forget to commit) | |
649 | $ aftermerge |
|
649 | $ aftermerge | |
650 | # cat f |
|
650 | # cat f | |
651 | revision 1 |
|
651 | revision 1 | |
652 | space |
|
652 | space | |
653 | # hg stat |
|
653 | # hg stat | |
654 | M f |
|
654 | M f | |
655 |
|
655 | |||
656 | Tool execution |
|
656 | Tool execution | |
657 |
|
657 | |||
658 | set tools.args explicit to include $base $local $other $output: |
|
658 | set tools.args explicit to include $base $local $other $output: | |
659 |
|
659 | |||
660 | $ beforemerge |
|
660 | $ beforemerge | |
661 | [merge-tools] |
|
661 | [merge-tools] | |
662 | false.whatever= |
|
662 | false.whatever= | |
663 | true.priority=1 |
|
663 | true.priority=1 | |
664 | true.executable=cat |
|
664 | true.executable=cat | |
665 | # hg update -C 1 |
|
665 | # hg update -C 1 | |
666 | $ hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \ |
|
666 | $ hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \ | |
667 | > | sed 's,==> .* <==,==> ... <==,g' |
|
667 | > | sed 's,==> .* <==,==> ... <==,g' | |
668 | merging f |
|
668 | merging f | |
669 | ==> ... <== |
|
669 | ==> ... <== | |
670 | revision 0 |
|
670 | revision 0 | |
671 | space |
|
671 | space | |
672 |
|
672 | |||
673 | ==> ... <== |
|
673 | ==> ... <== | |
674 | revision 1 |
|
674 | revision 1 | |
675 | space |
|
675 | space | |
676 |
|
676 | |||
677 | ==> ... <== |
|
677 | ==> ... <== | |
678 | revision 2 |
|
678 | revision 2 | |
679 | space |
|
679 | space | |
680 |
|
680 | |||
681 | ==> ... <== |
|
681 | ==> ... <== | |
682 | revision 1 |
|
682 | revision 1 | |
683 | space |
|
683 | space | |
684 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
684 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
685 | (branch merge, don't forget to commit) |
|
685 | (branch merge, don't forget to commit) | |
686 | $ aftermerge |
|
686 | $ aftermerge | |
687 | # cat f |
|
687 | # cat f | |
688 | revision 1 |
|
688 | revision 1 | |
689 | space |
|
689 | space | |
690 | # hg stat |
|
690 | # hg stat | |
691 | M f |
|
691 | M f | |
692 |
|
692 | |||
693 | Merge with "echo mergeresult > $local": |
|
693 | Merge with "echo mergeresult > $local": | |
694 |
|
694 | |||
695 | $ beforemerge |
|
695 | $ beforemerge | |
696 | [merge-tools] |
|
696 | [merge-tools] | |
697 | false.whatever= |
|
697 | false.whatever= | |
698 | true.priority=1 |
|
698 | true.priority=1 | |
699 | true.executable=cat |
|
699 | true.executable=cat | |
700 | # hg update -C 1 |
|
700 | # hg update -C 1 | |
701 | $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local' |
|
701 | $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local' | |
702 | merging f |
|
702 | merging f | |
703 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
703 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
704 | (branch merge, don't forget to commit) |
|
704 | (branch merge, don't forget to commit) | |
705 | $ aftermerge |
|
705 | $ aftermerge | |
706 | # cat f |
|
706 | # cat f | |
707 | mergeresult |
|
707 | mergeresult | |
708 | # hg stat |
|
708 | # hg stat | |
709 | M f |
|
709 | M f | |
710 |
|
710 | |||
711 | - and $local is the file f: |
|
711 | - and $local is the file f: | |
712 |
|
712 | |||
713 | $ beforemerge |
|
713 | $ beforemerge | |
714 | [merge-tools] |
|
714 | [merge-tools] | |
715 | false.whatever= |
|
715 | false.whatever= | |
716 | true.priority=1 |
|
716 | true.priority=1 | |
717 | true.executable=cat |
|
717 | true.executable=cat | |
718 | # hg update -C 1 |
|
718 | # hg update -C 1 | |
719 | $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f' |
|
719 | $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f' | |
720 | merging f |
|
720 | merging f | |
721 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
721 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
722 | (branch merge, don't forget to commit) |
|
722 | (branch merge, don't forget to commit) | |
723 | $ aftermerge |
|
723 | $ aftermerge | |
724 | # cat f |
|
724 | # cat f | |
725 | mergeresult |
|
725 | mergeresult | |
726 | # hg stat |
|
726 | # hg stat | |
727 | M f |
|
727 | M f | |
728 |
|
728 | |||
729 | Merge with "echo mergeresult > $output" - the variable is a bit magic: |
|
729 | Merge with "echo mergeresult > $output" - the variable is a bit magic: | |
730 |
|
730 | |||
731 | $ beforemerge |
|
731 | $ beforemerge | |
732 | [merge-tools] |
|
732 | [merge-tools] | |
733 | false.whatever= |
|
733 | false.whatever= | |
734 | true.priority=1 |
|
734 | true.priority=1 | |
735 | true.executable=cat |
|
735 | true.executable=cat | |
736 | # hg update -C 1 |
|
736 | # hg update -C 1 | |
737 | $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output' |
|
737 | $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output' | |
738 | merging f |
|
738 | merging f | |
739 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
739 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
740 | (branch merge, don't forget to commit) |
|
740 | (branch merge, don't forget to commit) | |
741 | $ aftermerge |
|
741 | $ aftermerge | |
742 | # cat f |
|
742 | # cat f | |
743 | mergeresult |
|
743 | mergeresult | |
744 | # hg stat |
|
744 | # hg stat | |
745 | M f |
|
745 | M f | |
746 |
|
746 | |||
747 | Merge using tool with a path that must be quoted: |
|
747 | Merge using tool with a path that must be quoted: | |
748 |
|
748 | |||
749 | $ beforemerge |
|
749 | $ beforemerge | |
750 | [merge-tools] |
|
750 | [merge-tools] | |
751 | false.whatever= |
|
751 | false.whatever= | |
752 | true.priority=1 |
|
752 | true.priority=1 | |
753 | true.executable=cat |
|
753 | true.executable=cat | |
754 | # hg update -C 1 |
|
754 | # hg update -C 1 | |
755 | $ cat <<EOF > 'my merge tool' |
|
755 | $ cat <<EOF > 'my merge tool' | |
756 | > cat "\$1" "\$2" "\$3" > "\$4" |
|
756 | > cat "\$1" "\$2" "\$3" > "\$4" | |
757 | > EOF |
|
757 | > EOF | |
758 | $ hg --config merge-tools.true.executable='sh' \ |
|
758 | $ hg --config merge-tools.true.executable='sh' \ | |
759 | > --config merge-tools.true.args='"./my merge tool" $base $local $other $output' \ |
|
759 | > --config merge-tools.true.args='"./my merge tool" $base $local $other $output' \ | |
760 | > merge -r 2 |
|
760 | > merge -r 2 | |
761 | merging f |
|
761 | merging f | |
762 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
762 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
763 | (branch merge, don't forget to commit) |
|
763 | (branch merge, don't forget to commit) | |
764 | $ rm -f 'my merge tool' |
|
764 | $ rm -f 'my merge tool' | |
765 | $ aftermerge |
|
765 | $ aftermerge | |
766 | # cat f |
|
766 | # cat f | |
767 | revision 0 |
|
767 | revision 0 | |
768 | space |
|
768 | space | |
769 | revision 1 |
|
769 | revision 1 | |
770 | space |
|
770 | space | |
771 | revision 2 |
|
771 | revision 2 | |
772 | space |
|
772 | space | |
773 | # hg stat |
|
773 | # hg stat | |
774 | M f |
|
774 | M f | |
775 |
|
775 | |||
776 | Issue3581: Merging a filename that needs to be quoted |
|
776 | Issue3581: Merging a filename that needs to be quoted | |
777 | (This test doesn't work on Windows filesystems even on Linux, so check |
|
777 | (This test doesn't work on Windows filesystems even on Linux, so check | |
778 | for Unix-like permission) |
|
778 | for Unix-like permission) | |
779 |
|
779 | |||
780 | #if unix-permissions |
|
780 | #if unix-permissions | |
781 | $ beforemerge |
|
781 | $ beforemerge | |
782 | [merge-tools] |
|
782 | [merge-tools] | |
783 | false.whatever= |
|
783 | false.whatever= | |
784 | true.priority=1 |
|
784 | true.priority=1 | |
785 | true.executable=cat |
|
785 | true.executable=cat | |
786 | # hg update -C 1 |
|
786 | # hg update -C 1 | |
787 | $ echo "revision 4" > '"; exit 1; echo "' |
|
787 | $ echo "revision 4" > '"; exit 1; echo "' | |
788 | $ hg commit -Am "revision 4" |
|
788 | $ hg commit -Am "revision 4" | |
789 | adding "; exit 1; echo " |
|
789 | adding "; exit 1; echo " | |
790 | warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "' |
|
790 | warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "' | |
791 | $ hg update -C 1 > /dev/null |
|
791 | $ hg update -C 1 > /dev/null | |
792 | $ echo "revision 5" > '"; exit 1; echo "' |
|
792 | $ echo "revision 5" > '"; exit 1; echo "' | |
793 | $ hg commit -Am "revision 5" |
|
793 | $ hg commit -Am "revision 5" | |
794 | adding "; exit 1; echo " |
|
794 | adding "; exit 1; echo " | |
795 | warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "' |
|
795 | warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "' | |
796 | created new head |
|
796 | created new head | |
797 | $ hg merge --config merge-tools.true.executable="true" -r 4 |
|
797 | $ hg merge --config merge-tools.true.executable="true" -r 4 | |
798 | merging "; exit 1; echo " |
|
798 | merging "; exit 1; echo " | |
799 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
799 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |
800 | (branch merge, don't forget to commit) |
|
800 | (branch merge, don't forget to commit) | |
801 | $ hg update -C 1 > /dev/null |
|
801 | $ hg update -C 1 > /dev/null | |
802 | #endif |
|
802 | #endif | |
803 |
|
803 | |||
804 | Merge post-processing |
|
804 | Merge post-processing | |
805 |
|
805 | |||
806 | cat is a bad merge-tool and doesn't change: |
|
806 | cat is a bad merge-tool and doesn't change: | |
807 |
|
807 | |||
808 | $ beforemerge |
|
808 | $ beforemerge | |
809 | [merge-tools] |
|
809 | [merge-tools] | |
810 | false.whatever= |
|
810 | false.whatever= | |
811 | true.priority=1 |
|
811 | true.priority=1 | |
812 | true.executable=cat |
|
812 | true.executable=cat | |
813 | # hg update -C 1 |
|
813 | # hg update -C 1 | |
814 | $ hg merge -y -r 2 --config merge-tools.true.checkchanged=1 |
|
814 | $ hg merge -y -r 2 --config merge-tools.true.checkchanged=1 | |
815 | merging f |
|
815 | merging f | |
816 | revision 1 |
|
816 | revision 1 | |
817 | space |
|
817 | space | |
818 | revision 0 |
|
818 | revision 0 | |
819 | space |
|
819 | space | |
820 | revision 2 |
|
820 | revision 2 | |
821 | space |
|
821 | space | |
822 | output file f appears unchanged |
|
822 | output file f appears unchanged | |
823 | was merge successful (yn)? n |
|
823 | was merge successful (yn)? n | |
824 | merging f failed! |
|
824 | merging f failed! | |
825 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
825 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
826 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
826 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
827 | [1] |
|
827 | [1] | |
828 | $ aftermerge |
|
828 | $ aftermerge | |
829 | # cat f |
|
829 | # cat f | |
830 | revision 1 |
|
830 | revision 1 | |
831 | space |
|
831 | space | |
832 | # hg stat |
|
832 | # hg stat | |
833 | M f |
|
833 | M f | |
834 | ? f.orig |
|
834 | ? f.orig | |
835 |
|
835 | |||
836 | #if symlink |
|
836 | #if symlink | |
837 |
|
837 | |||
838 | internal merge cannot handle symlinks and shouldn't try: |
|
838 | internal merge cannot handle symlinks and shouldn't try: | |
839 |
|
839 | |||
840 | $ hg update -q -C 1 |
|
840 | $ hg update -q -C 1 | |
841 | $ rm f |
|
841 | $ rm f | |
842 | $ ln -s symlink f |
|
842 | $ ln -s symlink f | |
843 | $ hg commit -qm 'f is symlink' |
|
843 | $ hg commit -qm 'f is symlink' | |
844 | $ hg merge -r 2 --tool internal:merge |
|
844 | $ hg merge -r 2 --tool internal:merge | |
845 | merging f |
|
845 | merging f | |
|
846 | warning: internal:merge cannot merge symlinks for f | |||
846 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') |
|
847 | merging f incomplete! (edit conflicts, then use 'hg resolve --mark') | |
847 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
|
848 | 0 files updated, 0 files merged, 0 files removed, 1 files unresolved | |
848 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
849 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon | |
849 | [1] |
|
850 | [1] | |
850 |
|
851 | |||
851 | #endif |
|
852 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now