##// END OF EJS Templates
mergetool: warn if ui.merge points to nonexistent tool...
Martin von Zweigbergk -
r38987:0e58c5b2 default
parent child Browse files
Show More
@@ -1,977 +1,978 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 __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import contextlib
10 import contextlib
11 import os
11 import os
12 import re
12 import re
13 import shutil
13 import shutil
14
14
15 from .i18n import _
15 from .i18n import _
16 from .node import nullid, short
16 from .node import nullid, short
17
17
18 from . import (
18 from . import (
19 encoding,
19 encoding,
20 error,
20 error,
21 formatter,
21 formatter,
22 match,
22 match,
23 pycompat,
23 pycompat,
24 registrar,
24 registrar,
25 scmutil,
25 scmutil,
26 simplemerge,
26 simplemerge,
27 tagmerge,
27 tagmerge,
28 templatekw,
28 templatekw,
29 templater,
29 templater,
30 util,
30 util,
31 )
31 )
32
32
33 from .utils import (
33 from .utils import (
34 procutil,
34 procutil,
35 stringutil,
35 stringutil,
36 )
36 )
37
37
38 def _toolstr(ui, tool, part, *args):
38 def _toolstr(ui, tool, part, *args):
39 return ui.config("merge-tools", tool + "." + part, *args)
39 return ui.config("merge-tools", tool + "." + part, *args)
40
40
41 def _toolbool(ui, tool, part,*args):
41 def _toolbool(ui, tool, part,*args):
42 return ui.configbool("merge-tools", tool + "." + part, *args)
42 return ui.configbool("merge-tools", tool + "." + part, *args)
43
43
44 def _toollist(ui, tool, part):
44 def _toollist(ui, tool, part):
45 return ui.configlist("merge-tools", tool + "." + part)
45 return ui.configlist("merge-tools", tool + "." + part)
46
46
47 internals = {}
47 internals = {}
48 # Merge tools to document.
48 # Merge tools to document.
49 internalsdoc = {}
49 internalsdoc = {}
50
50
51 internaltool = registrar.internalmerge()
51 internaltool = registrar.internalmerge()
52
52
53 # internal tool merge types
53 # internal tool merge types
54 nomerge = internaltool.nomerge
54 nomerge = internaltool.nomerge
55 mergeonly = internaltool.mergeonly # just the full merge, no premerge
55 mergeonly = internaltool.mergeonly # just the full merge, no premerge
56 fullmerge = internaltool.fullmerge # both premerge and merge
56 fullmerge = internaltool.fullmerge # both premerge and merge
57
57
58 _localchangedotherdeletedmsg = _(
58 _localchangedotherdeletedmsg = _(
59 "local%(l)s changed %(fd)s which other%(o)s deleted\n"
59 "local%(l)s changed %(fd)s which other%(o)s deleted\n"
60 "use (c)hanged version, (d)elete, or leave (u)nresolved?"
60 "use (c)hanged version, (d)elete, or leave (u)nresolved?"
61 "$$ &Changed $$ &Delete $$ &Unresolved")
61 "$$ &Changed $$ &Delete $$ &Unresolved")
62
62
63 _otherchangedlocaldeletedmsg = _(
63 _otherchangedlocaldeletedmsg = _(
64 "other%(o)s changed %(fd)s which local%(l)s deleted\n"
64 "other%(o)s changed %(fd)s which local%(l)s deleted\n"
65 "use (c)hanged version, leave (d)eleted, or "
65 "use (c)hanged version, leave (d)eleted, or "
66 "leave (u)nresolved?"
66 "leave (u)nresolved?"
67 "$$ &Changed $$ &Deleted $$ &Unresolved")
67 "$$ &Changed $$ &Deleted $$ &Unresolved")
68
68
69 class absentfilectx(object):
69 class absentfilectx(object):
70 """Represents a file that's ostensibly in a context but is actually not
70 """Represents a file that's ostensibly in a context but is actually not
71 present in it.
71 present in it.
72
72
73 This is here because it's very specific to the filemerge code for now --
73 This is here because it's very specific to the filemerge code for now --
74 other code is likely going to break with the values this returns."""
74 other code is likely going to break with the values this returns."""
75 def __init__(self, ctx, f):
75 def __init__(self, ctx, f):
76 self._ctx = ctx
76 self._ctx = ctx
77 self._f = f
77 self._f = f
78
78
79 def path(self):
79 def path(self):
80 return self._f
80 return self._f
81
81
82 def size(self):
82 def size(self):
83 return None
83 return None
84
84
85 def data(self):
85 def data(self):
86 return None
86 return None
87
87
88 def filenode(self):
88 def filenode(self):
89 return nullid
89 return nullid
90
90
91 _customcmp = True
91 _customcmp = True
92 def cmp(self, fctx):
92 def cmp(self, fctx):
93 """compare with other file context
93 """compare with other file context
94
94
95 returns True if different from fctx.
95 returns True if different from fctx.
96 """
96 """
97 return not (fctx.isabsent() and
97 return not (fctx.isabsent() and
98 fctx.ctx() == self.ctx() and
98 fctx.ctx() == self.ctx() and
99 fctx.path() == self.path())
99 fctx.path() == self.path())
100
100
101 def flags(self):
101 def flags(self):
102 return ''
102 return ''
103
103
104 def changectx(self):
104 def changectx(self):
105 return self._ctx
105 return self._ctx
106
106
107 def isbinary(self):
107 def isbinary(self):
108 return False
108 return False
109
109
110 def isabsent(self):
110 def isabsent(self):
111 return True
111 return True
112
112
113 def _findtool(ui, tool):
113 def _findtool(ui, tool):
114 if tool in internals:
114 if tool in internals:
115 return tool
115 return tool
116 cmd = _toolstr(ui, tool, "executable", tool)
116 cmd = _toolstr(ui, tool, "executable", tool)
117 if cmd.startswith('python:'):
117 if cmd.startswith('python:'):
118 return cmd
118 return cmd
119 return findexternaltool(ui, tool)
119 return findexternaltool(ui, tool)
120
120
121 def _quotetoolpath(cmd):
121 def _quotetoolpath(cmd):
122 if cmd.startswith('python:'):
122 if cmd.startswith('python:'):
123 return cmd
123 return cmd
124 return procutil.shellquote(cmd)
124 return procutil.shellquote(cmd)
125
125
126 def findexternaltool(ui, tool):
126 def findexternaltool(ui, tool):
127 for kn in ("regkey", "regkeyalt"):
127 for kn in ("regkey", "regkeyalt"):
128 k = _toolstr(ui, tool, kn)
128 k = _toolstr(ui, tool, kn)
129 if not k:
129 if not k:
130 continue
130 continue
131 p = util.lookupreg(k, _toolstr(ui, tool, "regname"))
131 p = util.lookupreg(k, _toolstr(ui, tool, "regname"))
132 if p:
132 if p:
133 p = procutil.findexe(p + _toolstr(ui, tool, "regappend", ""))
133 p = procutil.findexe(p + _toolstr(ui, tool, "regappend", ""))
134 if p:
134 if p:
135 return p
135 return p
136 exe = _toolstr(ui, tool, "executable", tool)
136 exe = _toolstr(ui, tool, "executable", tool)
137 return procutil.findexe(util.expandpath(exe))
137 return procutil.findexe(util.expandpath(exe))
138
138
139 def _picktool(repo, ui, path, binary, symlink, changedelete):
139 def _picktool(repo, ui, path, binary, symlink, changedelete):
140 def supportscd(tool):
140 def supportscd(tool):
141 return tool in internals and internals[tool].mergetype == nomerge
141 return tool in internals and internals[tool].mergetype == nomerge
142
142
143 def check(tool, pat, symlink, binary, changedelete):
143 def check(tool, pat, symlink, binary, changedelete):
144 tmsg = tool
144 tmsg = tool
145 if pat:
145 if pat:
146 tmsg = _("%s (for pattern %s)") % (tool, pat)
146 tmsg = _("%s (for pattern %s)") % (tool, pat)
147 if not _findtool(ui, tool):
147 if not _findtool(ui, tool):
148 if pat: # explicitly requested tool deserves a warning
148 if pat: # explicitly requested tool deserves a warning
149 ui.warn(_("couldn't find merge tool %s\n") % tmsg)
149 ui.warn(_("couldn't find merge tool %s\n") % tmsg)
150 else: # configured but non-existing tools are more silent
150 else: # configured but non-existing tools are more silent
151 ui.note(_("couldn't find merge tool %s\n") % tmsg)
151 ui.note(_("couldn't find merge tool %s\n") % tmsg)
152 elif symlink and not _toolbool(ui, tool, "symlink"):
152 elif symlink and not _toolbool(ui, tool, "symlink"):
153 ui.warn(_("tool %s can't handle symlinks\n") % tmsg)
153 ui.warn(_("tool %s can't handle symlinks\n") % tmsg)
154 elif binary and not _toolbool(ui, tool, "binary"):
154 elif binary and not _toolbool(ui, tool, "binary"):
155 ui.warn(_("tool %s can't handle binary\n") % tmsg)
155 ui.warn(_("tool %s can't handle binary\n") % tmsg)
156 elif changedelete and not supportscd(tool):
156 elif changedelete and not supportscd(tool):
157 # the nomerge tools are the only tools that support change/delete
157 # the nomerge tools are the only tools that support change/delete
158 # conflicts
158 # conflicts
159 pass
159 pass
160 elif not procutil.gui() and _toolbool(ui, tool, "gui"):
160 elif not procutil.gui() and _toolbool(ui, tool, "gui"):
161 ui.warn(_("tool %s requires a GUI\n") % tmsg)
161 ui.warn(_("tool %s requires a GUI\n") % tmsg)
162 else:
162 else:
163 return True
163 return True
164 return False
164 return False
165
165
166 # internal config: ui.forcemerge
166 # internal config: ui.forcemerge
167 # forcemerge comes from command line arguments, highest priority
167 # forcemerge comes from command line arguments, highest priority
168 force = ui.config('ui', 'forcemerge')
168 force = ui.config('ui', 'forcemerge')
169 if force:
169 if force:
170 toolpath = _findtool(ui, force)
170 toolpath = _findtool(ui, force)
171 if changedelete and not supportscd(toolpath):
171 if changedelete and not supportscd(toolpath):
172 return ":prompt", None
172 return ":prompt", None
173 else:
173 else:
174 if toolpath:
174 if toolpath:
175 return (force, _quotetoolpath(toolpath))
175 return (force, _quotetoolpath(toolpath))
176 else:
176 else:
177 # mimic HGMERGE if given tool not found
177 # mimic HGMERGE if given tool not found
178 return (force, force)
178 return (force, force)
179
179
180 # HGMERGE takes next precedence
180 # HGMERGE takes next precedence
181 hgmerge = encoding.environ.get("HGMERGE")
181 hgmerge = encoding.environ.get("HGMERGE")
182 if hgmerge:
182 if hgmerge:
183 if changedelete and not supportscd(hgmerge):
183 if changedelete and not supportscd(hgmerge):
184 return ":prompt", None
184 return ":prompt", None
185 else:
185 else:
186 return (hgmerge, hgmerge)
186 return (hgmerge, hgmerge)
187
187
188 # then patterns
188 # then patterns
189 for pat, tool in ui.configitems("merge-patterns"):
189 for pat, tool in ui.configitems("merge-patterns"):
190 mf = match.match(repo.root, '', [pat])
190 mf = match.match(repo.root, '', [pat])
191 if mf(path) and check(tool, pat, symlink, False, changedelete):
191 if mf(path) and check(tool, pat, symlink, False, changedelete):
192 toolpath = _findtool(ui, tool)
192 toolpath = _findtool(ui, tool)
193 return (tool, _quotetoolpath(toolpath))
193 return (tool, _quotetoolpath(toolpath))
194
194
195 # then merge tools
195 # then merge tools
196 tools = {}
196 tools = {}
197 disabled = set()
197 disabled = set()
198 for k, v in ui.configitems("merge-tools"):
198 for k, v in ui.configitems("merge-tools"):
199 t = k.split('.')[0]
199 t = k.split('.')[0]
200 if t not in tools:
200 if t not in tools:
201 tools[t] = int(_toolstr(ui, t, "priority"))
201 tools[t] = int(_toolstr(ui, t, "priority"))
202 if _toolbool(ui, t, "disabled"):
202 if _toolbool(ui, t, "disabled"):
203 disabled.add(t)
203 disabled.add(t)
204 names = tools.keys()
204 names = tools.keys()
205 tools = sorted([(-p, tool) for tool, p in tools.items()
205 tools = sorted([(-p, tool) for tool, p in tools.items()
206 if tool not in disabled])
206 if tool not in disabled])
207 uimerge = ui.config("ui", "merge")
207 uimerge = ui.config("ui", "merge")
208 if uimerge:
208 if uimerge:
209 # external tools defined in uimerge won't be able to handle
209 # external tools defined in uimerge won't be able to handle
210 # change/delete conflicts
210 # change/delete conflicts
211 if uimerge not in names and not changedelete:
211 if check(uimerge, path, symlink, binary, changedelete):
212 return (uimerge, uimerge)
212 if uimerge not in names and not changedelete:
213 tools.insert(0, (None, uimerge)) # highest priority
213 return (uimerge, uimerge)
214 tools.insert(0, (None, uimerge)) # highest priority
214 tools.append((None, "hgmerge")) # the old default, if found
215 tools.append((None, "hgmerge")) # the old default, if found
215 for p, t in tools:
216 for p, t in tools:
216 if check(t, None, symlink, binary, changedelete):
217 if check(t, None, symlink, binary, changedelete):
217 toolpath = _findtool(ui, t)
218 toolpath = _findtool(ui, t)
218 return (t, _quotetoolpath(toolpath))
219 return (t, _quotetoolpath(toolpath))
219
220
220 # internal merge or prompt as last resort
221 # internal merge or prompt as last resort
221 if symlink or binary or changedelete:
222 if symlink or binary or changedelete:
222 if not changedelete and len(tools):
223 if not changedelete and len(tools):
223 # any tool is rejected by capability for symlink or binary
224 # any tool is rejected by capability for symlink or binary
224 ui.warn(_("no tool found to merge %s\n") % path)
225 ui.warn(_("no tool found to merge %s\n") % path)
225 return ":prompt", None
226 return ":prompt", None
226 return ":merge", None
227 return ":merge", None
227
228
228 def _eoltype(data):
229 def _eoltype(data):
229 "Guess the EOL type of a file"
230 "Guess the EOL type of a file"
230 if '\0' in data: # binary
231 if '\0' in data: # binary
231 return None
232 return None
232 if '\r\n' in data: # Windows
233 if '\r\n' in data: # Windows
233 return '\r\n'
234 return '\r\n'
234 if '\r' in data: # Old Mac
235 if '\r' in data: # Old Mac
235 return '\r'
236 return '\r'
236 if '\n' in data: # UNIX
237 if '\n' in data: # UNIX
237 return '\n'
238 return '\n'
238 return None # unknown
239 return None # unknown
239
240
240 def _matcheol(file, back):
241 def _matcheol(file, back):
241 "Convert EOL markers in a file to match origfile"
242 "Convert EOL markers in a file to match origfile"
242 tostyle = _eoltype(back.data()) # No repo.wread filters?
243 tostyle = _eoltype(back.data()) # No repo.wread filters?
243 if tostyle:
244 if tostyle:
244 data = util.readfile(file)
245 data = util.readfile(file)
245 style = _eoltype(data)
246 style = _eoltype(data)
246 if style:
247 if style:
247 newdata = data.replace(style, tostyle)
248 newdata = data.replace(style, tostyle)
248 if newdata != data:
249 if newdata != data:
249 util.writefile(file, newdata)
250 util.writefile(file, newdata)
250
251
251 @internaltool('prompt', nomerge)
252 @internaltool('prompt', nomerge)
252 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
253 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
253 """Asks the user which of the local `p1()` or the other `p2()` version to
254 """Asks the user which of the local `p1()` or the other `p2()` version to
254 keep as the merged version."""
255 keep as the merged version."""
255 ui = repo.ui
256 ui = repo.ui
256 fd = fcd.path()
257 fd = fcd.path()
257
258
258 # Avoid prompting during an in-memory merge since it doesn't support merge
259 # Avoid prompting during an in-memory merge since it doesn't support merge
259 # conflicts.
260 # conflicts.
260 if fcd.changectx().isinmemory():
261 if fcd.changectx().isinmemory():
261 raise error.InMemoryMergeConflictsError('in-memory merge does not '
262 raise error.InMemoryMergeConflictsError('in-memory merge does not '
262 'support file conflicts')
263 'support file conflicts')
263
264
264 prompts = partextras(labels)
265 prompts = partextras(labels)
265 prompts['fd'] = fd
266 prompts['fd'] = fd
266 try:
267 try:
267 if fco.isabsent():
268 if fco.isabsent():
268 index = ui.promptchoice(
269 index = ui.promptchoice(
269 _localchangedotherdeletedmsg % prompts, 2)
270 _localchangedotherdeletedmsg % prompts, 2)
270 choice = ['local', 'other', 'unresolved'][index]
271 choice = ['local', 'other', 'unresolved'][index]
271 elif fcd.isabsent():
272 elif fcd.isabsent():
272 index = ui.promptchoice(
273 index = ui.promptchoice(
273 _otherchangedlocaldeletedmsg % prompts, 2)
274 _otherchangedlocaldeletedmsg % prompts, 2)
274 choice = ['other', 'local', 'unresolved'][index]
275 choice = ['other', 'local', 'unresolved'][index]
275 else:
276 else:
276 index = ui.promptchoice(
277 index = ui.promptchoice(
277 _("keep (l)ocal%(l)s, take (o)ther%(o)s, or leave (u)nresolved"
278 _("keep (l)ocal%(l)s, take (o)ther%(o)s, or leave (u)nresolved"
278 " for %(fd)s?"
279 " for %(fd)s?"
279 "$$ &Local $$ &Other $$ &Unresolved") % prompts, 2)
280 "$$ &Local $$ &Other $$ &Unresolved") % prompts, 2)
280 choice = ['local', 'other', 'unresolved'][index]
281 choice = ['local', 'other', 'unresolved'][index]
281
282
282 if choice == 'other':
283 if choice == 'other':
283 return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
284 return _iother(repo, mynode, orig, fcd, fco, fca, toolconf,
284 labels)
285 labels)
285 elif choice == 'local':
286 elif choice == 'local':
286 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
287 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf,
287 labels)
288 labels)
288 elif choice == 'unresolved':
289 elif choice == 'unresolved':
289 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
290 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
290 labels)
291 labels)
291 except error.ResponseExpected:
292 except error.ResponseExpected:
292 ui.write("\n")
293 ui.write("\n")
293 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
294 return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf,
294 labels)
295 labels)
295
296
296 @internaltool('local', nomerge)
297 @internaltool('local', nomerge)
297 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
298 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
298 """Uses the local `p1()` version of files as the merged version."""
299 """Uses the local `p1()` version of files as the merged version."""
299 return 0, fcd.isabsent()
300 return 0, fcd.isabsent()
300
301
301 @internaltool('other', nomerge)
302 @internaltool('other', nomerge)
302 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
303 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
303 """Uses the other `p2()` version of files as the merged version."""
304 """Uses the other `p2()` version of files as the merged version."""
304 if fco.isabsent():
305 if fco.isabsent():
305 # local changed, remote deleted -- 'deleted' picked
306 # local changed, remote deleted -- 'deleted' picked
306 _underlyingfctxifabsent(fcd).remove()
307 _underlyingfctxifabsent(fcd).remove()
307 deleted = True
308 deleted = True
308 else:
309 else:
309 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
310 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
310 deleted = False
311 deleted = False
311 return 0, deleted
312 return 0, deleted
312
313
313 @internaltool('fail', nomerge)
314 @internaltool('fail', nomerge)
314 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
315 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf, labels=None):
315 """
316 """
316 Rather than attempting to merge files that were modified on both
317 Rather than attempting to merge files that were modified on both
317 branches, it marks them as unresolved. The resolve command must be
318 branches, it marks them as unresolved. The resolve command must be
318 used to resolve these conflicts."""
319 used to resolve these conflicts."""
319 # for change/delete conflicts write out the changed version, then fail
320 # for change/delete conflicts write out the changed version, then fail
320 if fcd.isabsent():
321 if fcd.isabsent():
321 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
322 _underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
322 return 1, False
323 return 1, False
323
324
324 def _underlyingfctxifabsent(filectx):
325 def _underlyingfctxifabsent(filectx):
325 """Sometimes when resolving, our fcd is actually an absentfilectx, but
326 """Sometimes when resolving, our fcd is actually an absentfilectx, but
326 we want to write to it (to do the resolve). This helper returns the
327 we want to write to it (to do the resolve). This helper returns the
327 underyling workingfilectx in that case.
328 underyling workingfilectx in that case.
328 """
329 """
329 if filectx.isabsent():
330 if filectx.isabsent():
330 return filectx.changectx()[filectx.path()]
331 return filectx.changectx()[filectx.path()]
331 else:
332 else:
332 return filectx
333 return filectx
333
334
334 def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
335 def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
335 tool, toolpath, binary, symlink, scriptfn = toolconf
336 tool, toolpath, binary, symlink, scriptfn = toolconf
336 if symlink or fcd.isabsent() or fco.isabsent():
337 if symlink or fcd.isabsent() or fco.isabsent():
337 return 1
338 return 1
338 unused, unused, unused, back = files
339 unused, unused, unused, back = files
339
340
340 ui = repo.ui
341 ui = repo.ui
341
342
342 validkeep = ['keep', 'keep-merge3']
343 validkeep = ['keep', 'keep-merge3']
343
344
344 # do we attempt to simplemerge first?
345 # do we attempt to simplemerge first?
345 try:
346 try:
346 premerge = _toolbool(ui, tool, "premerge", not binary)
347 premerge = _toolbool(ui, tool, "premerge", not binary)
347 except error.ConfigError:
348 except error.ConfigError:
348 premerge = _toolstr(ui, tool, "premerge", "").lower()
349 premerge = _toolstr(ui, tool, "premerge", "").lower()
349 if premerge not in validkeep:
350 if premerge not in validkeep:
350 _valid = ', '.join(["'" + v + "'" for v in validkeep])
351 _valid = ', '.join(["'" + v + "'" for v in validkeep])
351 raise error.ConfigError(_("%s.premerge not valid "
352 raise error.ConfigError(_("%s.premerge not valid "
352 "('%s' is neither boolean nor %s)") %
353 "('%s' is neither boolean nor %s)") %
353 (tool, premerge, _valid))
354 (tool, premerge, _valid))
354
355
355 if premerge:
356 if premerge:
356 if premerge == 'keep-merge3':
357 if premerge == 'keep-merge3':
357 if not labels:
358 if not labels:
358 labels = _defaultconflictlabels
359 labels = _defaultconflictlabels
359 if len(labels) < 3:
360 if len(labels) < 3:
360 labels.append('base')
361 labels.append('base')
361 r = simplemerge.simplemerge(ui, fcd, fca, fco, quiet=True, label=labels)
362 r = simplemerge.simplemerge(ui, fcd, fca, fco, quiet=True, label=labels)
362 if not r:
363 if not r:
363 ui.debug(" premerge successful\n")
364 ui.debug(" premerge successful\n")
364 return 0
365 return 0
365 if premerge not in validkeep:
366 if premerge not in validkeep:
366 # restore from backup and try again
367 # restore from backup and try again
367 _restorebackup(fcd, back)
368 _restorebackup(fcd, back)
368 return 1 # continue merging
369 return 1 # continue merging
369
370
370 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
371 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
371 tool, toolpath, binary, symlink, scriptfn = toolconf
372 tool, toolpath, binary, symlink, scriptfn = toolconf
372 if symlink:
373 if symlink:
373 repo.ui.warn(_('warning: internal %s cannot merge symlinks '
374 repo.ui.warn(_('warning: internal %s cannot merge symlinks '
374 'for %s\n') % (tool, fcd.path()))
375 'for %s\n') % (tool, fcd.path()))
375 return False
376 return False
376 if fcd.isabsent() or fco.isabsent():
377 if fcd.isabsent() or fco.isabsent():
377 repo.ui.warn(_('warning: internal %s cannot merge change/delete '
378 repo.ui.warn(_('warning: internal %s cannot merge change/delete '
378 'conflict for %s\n') % (tool, fcd.path()))
379 'conflict for %s\n') % (tool, fcd.path()))
379 return False
380 return False
380 return True
381 return True
381
382
382 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
383 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
383 """
384 """
384 Uses the internal non-interactive simple merge algorithm for merging
385 Uses the internal non-interactive simple merge algorithm for merging
385 files. It will fail if there are any conflicts and leave markers in
386 files. It will fail if there are any conflicts and leave markers in
386 the partially merged file. Markers will have two sections, one for each side
387 the partially merged file. Markers will have two sections, one for each side
387 of merge, unless mode equals 'union' which suppresses the markers."""
388 of merge, unless mode equals 'union' which suppresses the markers."""
388 ui = repo.ui
389 ui = repo.ui
389
390
390 r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode)
391 r = simplemerge.simplemerge(ui, fcd, fca, fco, label=labels, mode=mode)
391 return True, r, False
392 return True, r, False
392
393
393 @internaltool('union', fullmerge,
394 @internaltool('union', fullmerge,
394 _("warning: conflicts while merging %s! "
395 _("warning: conflicts while merging %s! "
395 "(edit, then use 'hg resolve --mark')\n"),
396 "(edit, then use 'hg resolve --mark')\n"),
396 precheck=_mergecheck)
397 precheck=_mergecheck)
397 def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
398 def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
398 """
399 """
399 Uses the internal non-interactive simple merge algorithm for merging
400 Uses the internal non-interactive simple merge algorithm for merging
400 files. It will use both left and right sides for conflict regions.
401 files. It will use both left and right sides for conflict regions.
401 No markers are inserted."""
402 No markers are inserted."""
402 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
403 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
403 files, labels, 'union')
404 files, labels, 'union')
404
405
405 @internaltool('merge', fullmerge,
406 @internaltool('merge', fullmerge,
406 _("warning: conflicts while merging %s! "
407 _("warning: conflicts while merging %s! "
407 "(edit, then use 'hg resolve --mark')\n"),
408 "(edit, then use 'hg resolve --mark')\n"),
408 precheck=_mergecheck)
409 precheck=_mergecheck)
409 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
410 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
410 """
411 """
411 Uses the internal non-interactive simple merge algorithm for merging
412 Uses the internal non-interactive simple merge algorithm for merging
412 files. It will fail if there are any conflicts and leave markers in
413 files. It will fail if there are any conflicts and leave markers in
413 the partially merged file. Markers will have two sections, one for each side
414 the partially merged file. Markers will have two sections, one for each side
414 of merge."""
415 of merge."""
415 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
416 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
416 files, labels, 'merge')
417 files, labels, 'merge')
417
418
418 @internaltool('merge3', fullmerge,
419 @internaltool('merge3', fullmerge,
419 _("warning: conflicts while merging %s! "
420 _("warning: conflicts while merging %s! "
420 "(edit, then use 'hg resolve --mark')\n"),
421 "(edit, then use 'hg resolve --mark')\n"),
421 precheck=_mergecheck)
422 precheck=_mergecheck)
422 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
423 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
423 """
424 """
424 Uses the internal non-interactive simple merge algorithm for merging
425 Uses the internal non-interactive simple merge algorithm for merging
425 files. It will fail if there are any conflicts and leave markers in
426 files. It will fail if there are any conflicts and leave markers in
426 the partially merged file. Marker will have three sections, one from each
427 the partially merged file. Marker will have three sections, one from each
427 side of the merge and one for the base content."""
428 side of the merge and one for the base content."""
428 if not labels:
429 if not labels:
429 labels = _defaultconflictlabels
430 labels = _defaultconflictlabels
430 if len(labels) < 3:
431 if len(labels) < 3:
431 labels.append('base')
432 labels.append('base')
432 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
433 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
433
434
434 def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files,
435 def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files,
435 labels=None, localorother=None):
436 labels=None, localorother=None):
436 """
437 """
437 Generic driver for _imergelocal and _imergeother
438 Generic driver for _imergelocal and _imergeother
438 """
439 """
439 assert localorother is not None
440 assert localorother is not None
440 tool, toolpath, binary, symlink, scriptfn = toolconf
441 tool, toolpath, binary, symlink, scriptfn = toolconf
441 r = simplemerge.simplemerge(repo.ui, fcd, fca, fco, label=labels,
442 r = simplemerge.simplemerge(repo.ui, fcd, fca, fco, label=labels,
442 localorother=localorother)
443 localorother=localorother)
443 return True, r
444 return True, r
444
445
445 @internaltool('merge-local', mergeonly, precheck=_mergecheck)
446 @internaltool('merge-local', mergeonly, precheck=_mergecheck)
446 def _imergelocal(*args, **kwargs):
447 def _imergelocal(*args, **kwargs):
447 """
448 """
448 Like :merge, but resolve all conflicts non-interactively in favor
449 Like :merge, but resolve all conflicts non-interactively in favor
449 of the local `p1()` changes."""
450 of the local `p1()` changes."""
450 success, status = _imergeauto(localorother='local', *args, **kwargs)
451 success, status = _imergeauto(localorother='local', *args, **kwargs)
451 return success, status, False
452 return success, status, False
452
453
453 @internaltool('merge-other', mergeonly, precheck=_mergecheck)
454 @internaltool('merge-other', mergeonly, precheck=_mergecheck)
454 def _imergeother(*args, **kwargs):
455 def _imergeother(*args, **kwargs):
455 """
456 """
456 Like :merge, but resolve all conflicts non-interactively in favor
457 Like :merge, but resolve all conflicts non-interactively in favor
457 of the other `p2()` changes."""
458 of the other `p2()` changes."""
458 success, status = _imergeauto(localorother='other', *args, **kwargs)
459 success, status = _imergeauto(localorother='other', *args, **kwargs)
459 return success, status, False
460 return success, status, False
460
461
461 @internaltool('tagmerge', mergeonly,
462 @internaltool('tagmerge', mergeonly,
462 _("automatic tag merging of %s failed! "
463 _("automatic tag merging of %s failed! "
463 "(use 'hg resolve --tool :merge' or another merge "
464 "(use 'hg resolve --tool :merge' or another merge "
464 "tool of your choice)\n"))
465 "tool of your choice)\n"))
465 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
466 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
466 """
467 """
467 Uses the internal tag merge algorithm (experimental).
468 Uses the internal tag merge algorithm (experimental).
468 """
469 """
469 success, status = tagmerge.merge(repo, fcd, fco, fca)
470 success, status = tagmerge.merge(repo, fcd, fco, fca)
470 return success, status, False
471 return success, status, False
471
472
472 @internaltool('dump', fullmerge)
473 @internaltool('dump', fullmerge)
473 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
474 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
474 """
475 """
475 Creates three versions of the files to merge, containing the
476 Creates three versions of the files to merge, containing the
476 contents of local, other and base. These files can then be used to
477 contents of local, other and base. These files can then be used to
477 perform a merge manually. If the file to be merged is named
478 perform a merge manually. If the file to be merged is named
478 ``a.txt``, these files will accordingly be named ``a.txt.local``,
479 ``a.txt``, these files will accordingly be named ``a.txt.local``,
479 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
480 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
480 same directory as ``a.txt``.
481 same directory as ``a.txt``.
481
482
482 This implies premerge. Therefore, files aren't dumped, if premerge
483 This implies premerge. Therefore, files aren't dumped, if premerge
483 runs successfully. Use :forcedump to forcibly write files out.
484 runs successfully. Use :forcedump to forcibly write files out.
484 """
485 """
485 a = _workingpath(repo, fcd)
486 a = _workingpath(repo, fcd)
486 fd = fcd.path()
487 fd = fcd.path()
487
488
488 from . import context
489 from . import context
489 if isinstance(fcd, context.overlayworkingfilectx):
490 if isinstance(fcd, context.overlayworkingfilectx):
490 raise error.InMemoryMergeConflictsError('in-memory merge does not '
491 raise error.InMemoryMergeConflictsError('in-memory merge does not '
491 'support the :dump tool.')
492 'support the :dump tool.')
492
493
493 util.writefile(a + ".local", fcd.decodeddata())
494 util.writefile(a + ".local", fcd.decodeddata())
494 repo.wwrite(fd + ".other", fco.data(), fco.flags())
495 repo.wwrite(fd + ".other", fco.data(), fco.flags())
495 repo.wwrite(fd + ".base", fca.data(), fca.flags())
496 repo.wwrite(fd + ".base", fca.data(), fca.flags())
496 return False, 1, False
497 return False, 1, False
497
498
498 @internaltool('forcedump', mergeonly)
499 @internaltool('forcedump', mergeonly)
499 def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
500 def _forcedump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
500 labels=None):
501 labels=None):
501 """
502 """
502 Creates three versions of the files as same as :dump, but omits premerge.
503 Creates three versions of the files as same as :dump, but omits premerge.
503 """
504 """
504 return _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
505 return _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files,
505 labels=labels)
506 labels=labels)
506
507
507 def _xmergeimm(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
508 def _xmergeimm(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
508 # In-memory merge simply raises an exception on all external merge tools,
509 # In-memory merge simply raises an exception on all external merge tools,
509 # for now.
510 # for now.
510 #
511 #
511 # It would be possible to run most tools with temporary files, but this
512 # It would be possible to run most tools with temporary files, but this
512 # raises the question of what to do if the user only partially resolves the
513 # raises the question of what to do if the user only partially resolves the
513 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/
514 # file -- we can't leave a merge state. (Copy to somewhere in the .hg/
514 # directory and tell the user how to get it is my best idea, but it's
515 # directory and tell the user how to get it is my best idea, but it's
515 # clunky.)
516 # clunky.)
516 raise error.InMemoryMergeConflictsError('in-memory merge does not support '
517 raise error.InMemoryMergeConflictsError('in-memory merge does not support '
517 'external merge tools')
518 'external merge tools')
518
519
519 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
520 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
520 tool, toolpath, binary, symlink, scriptfn = toolconf
521 tool, toolpath, binary, symlink, scriptfn = toolconf
521 if fcd.isabsent() or fco.isabsent():
522 if fcd.isabsent() or fco.isabsent():
522 repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
523 repo.ui.warn(_('warning: %s cannot merge change/delete conflict '
523 'for %s\n') % (tool, fcd.path()))
524 'for %s\n') % (tool, fcd.path()))
524 return False, 1, None
525 return False, 1, None
525 unused, unused, unused, back = files
526 unused, unused, unused, back = files
526 localpath = _workingpath(repo, fcd)
527 localpath = _workingpath(repo, fcd)
527 args = _toolstr(repo.ui, tool, "args")
528 args = _toolstr(repo.ui, tool, "args")
528
529
529 with _maketempfiles(repo, fco, fca, repo.wvfs.join(back.path()),
530 with _maketempfiles(repo, fco, fca, repo.wvfs.join(back.path()),
530 "$output" in args) as temppaths:
531 "$output" in args) as temppaths:
531 basepath, otherpath, localoutputpath = temppaths
532 basepath, otherpath, localoutputpath = temppaths
532 outpath = ""
533 outpath = ""
533 mylabel, otherlabel = labels[:2]
534 mylabel, otherlabel = labels[:2]
534 if len(labels) >= 3:
535 if len(labels) >= 3:
535 baselabel = labels[2]
536 baselabel = labels[2]
536 else:
537 else:
537 baselabel = 'base'
538 baselabel = 'base'
538 env = {'HG_FILE': fcd.path(),
539 env = {'HG_FILE': fcd.path(),
539 'HG_MY_NODE': short(mynode),
540 'HG_MY_NODE': short(mynode),
540 'HG_OTHER_NODE': short(fco.changectx().node()),
541 'HG_OTHER_NODE': short(fco.changectx().node()),
541 'HG_BASE_NODE': short(fca.changectx().node()),
542 'HG_BASE_NODE': short(fca.changectx().node()),
542 'HG_MY_ISLINK': 'l' in fcd.flags(),
543 'HG_MY_ISLINK': 'l' in fcd.flags(),
543 'HG_OTHER_ISLINK': 'l' in fco.flags(),
544 'HG_OTHER_ISLINK': 'l' in fco.flags(),
544 'HG_BASE_ISLINK': 'l' in fca.flags(),
545 'HG_BASE_ISLINK': 'l' in fca.flags(),
545 'HG_MY_LABEL': mylabel,
546 'HG_MY_LABEL': mylabel,
546 'HG_OTHER_LABEL': otherlabel,
547 'HG_OTHER_LABEL': otherlabel,
547 'HG_BASE_LABEL': baselabel,
548 'HG_BASE_LABEL': baselabel,
548 }
549 }
549 ui = repo.ui
550 ui = repo.ui
550
551
551 if "$output" in args:
552 if "$output" in args:
552 # read input from backup, write to original
553 # read input from backup, write to original
553 outpath = localpath
554 outpath = localpath
554 localpath = localoutputpath
555 localpath = localoutputpath
555 replace = {'local': localpath, 'base': basepath, 'other': otherpath,
556 replace = {'local': localpath, 'base': basepath, 'other': otherpath,
556 'output': outpath, 'labellocal': mylabel,
557 'output': outpath, 'labellocal': mylabel,
557 'labelother': otherlabel, 'labelbase': baselabel}
558 'labelother': otherlabel, 'labelbase': baselabel}
558 args = util.interpolate(
559 args = util.interpolate(
559 br'\$', replace, args,
560 br'\$', replace, args,
560 lambda s: procutil.shellquote(util.localpath(s)))
561 lambda s: procutil.shellquote(util.localpath(s)))
561 if _toolbool(ui, tool, "gui"):
562 if _toolbool(ui, tool, "gui"):
562 repo.ui.status(_('running merge tool %s for file %s\n') %
563 repo.ui.status(_('running merge tool %s for file %s\n') %
563 (tool, fcd.path()))
564 (tool, fcd.path()))
564 if scriptfn is None:
565 if scriptfn is None:
565 cmd = toolpath + ' ' + args
566 cmd = toolpath + ' ' + args
566 repo.ui.debug('launching merge tool: %s\n' % cmd)
567 repo.ui.debug('launching merge tool: %s\n' % cmd)
567 r = ui.system(cmd, cwd=repo.root, environ=env,
568 r = ui.system(cmd, cwd=repo.root, environ=env,
568 blockedtag='mergetool')
569 blockedtag='mergetool')
569 else:
570 else:
570 repo.ui.debug('launching python merge script: %s:%s\n' %
571 repo.ui.debug('launching python merge script: %s:%s\n' %
571 (toolpath, scriptfn))
572 (toolpath, scriptfn))
572 r = 0
573 r = 0
573 try:
574 try:
574 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil
575 # avoid cycle cmdutil->merge->filemerge->extensions->cmdutil
575 from . import extensions
576 from . import extensions
576 mod = extensions.loadpath(toolpath, 'hgmerge.%s' % tool)
577 mod = extensions.loadpath(toolpath, 'hgmerge.%s' % tool)
577 except Exception:
578 except Exception:
578 raise error.Abort(_("loading python merge script failed: %s") %
579 raise error.Abort(_("loading python merge script failed: %s") %
579 toolpath)
580 toolpath)
580 mergefn = getattr(mod, scriptfn, None)
581 mergefn = getattr(mod, scriptfn, None)
581 if mergefn is None:
582 if mergefn is None:
582 raise error.Abort(_("%s does not have function: %s") %
583 raise error.Abort(_("%s does not have function: %s") %
583 (toolpath, scriptfn))
584 (toolpath, scriptfn))
584 argslist = procutil.shellsplit(args)
585 argslist = procutil.shellsplit(args)
585 # avoid cycle cmdutil->merge->filemerge->hook->extensions->cmdutil
586 # avoid cycle cmdutil->merge->filemerge->hook->extensions->cmdutil
586 from . import hook
587 from . import hook
587 ret, raised = hook.pythonhook(ui, repo, "merge", toolpath,
588 ret, raised = hook.pythonhook(ui, repo, "merge", toolpath,
588 mergefn, {'args': argslist}, True)
589 mergefn, {'args': argslist}, True)
589 if raised:
590 if raised:
590 r = 1
591 r = 1
591 repo.ui.debug('merge tool returned: %d\n' % r)
592 repo.ui.debug('merge tool returned: %d\n' % r)
592 return True, r, False
593 return True, r, False
593
594
594 def _formatconflictmarker(ctx, template, label, pad):
595 def _formatconflictmarker(ctx, template, label, pad):
595 """Applies the given template to the ctx, prefixed by the label.
596 """Applies the given template to the ctx, prefixed by the label.
596
597
597 Pad is the minimum width of the label prefix, so that multiple markers
598 Pad is the minimum width of the label prefix, so that multiple markers
598 can have aligned templated parts.
599 can have aligned templated parts.
599 """
600 """
600 if ctx.node() is None:
601 if ctx.node() is None:
601 ctx = ctx.p1()
602 ctx = ctx.p1()
602
603
603 props = {'ctx': ctx}
604 props = {'ctx': ctx}
604 templateresult = template.renderdefault(props)
605 templateresult = template.renderdefault(props)
605
606
606 label = ('%s:' % label).ljust(pad + 1)
607 label = ('%s:' % label).ljust(pad + 1)
607 mark = '%s %s' % (label, templateresult)
608 mark = '%s %s' % (label, templateresult)
608
609
609 if mark:
610 if mark:
610 mark = mark.splitlines()[0] # split for safety
611 mark = mark.splitlines()[0] # split for safety
611
612
612 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
613 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
613 return stringutil.ellipsis(mark, 80 - 8)
614 return stringutil.ellipsis(mark, 80 - 8)
614
615
615 _defaultconflictlabels = ['local', 'other']
616 _defaultconflictlabels = ['local', 'other']
616
617
617 def _formatlabels(repo, fcd, fco, fca, labels, tool=None):
618 def _formatlabels(repo, fcd, fco, fca, labels, tool=None):
618 """Formats the given labels using the conflict marker template.
619 """Formats the given labels using the conflict marker template.
619
620
620 Returns a list of formatted labels.
621 Returns a list of formatted labels.
621 """
622 """
622 cd = fcd.changectx()
623 cd = fcd.changectx()
623 co = fco.changectx()
624 co = fco.changectx()
624 ca = fca.changectx()
625 ca = fca.changectx()
625
626
626 ui = repo.ui
627 ui = repo.ui
627 template = ui.config('ui', 'mergemarkertemplate')
628 template = ui.config('ui', 'mergemarkertemplate')
628 if tool is not None:
629 if tool is not None:
629 template = _toolstr(ui, tool, 'mergemarkertemplate', template)
630 template = _toolstr(ui, tool, 'mergemarkertemplate', template)
630 template = templater.unquotestring(template)
631 template = templater.unquotestring(template)
631 tres = formatter.templateresources(ui, repo)
632 tres = formatter.templateresources(ui, repo)
632 tmpl = formatter.maketemplater(ui, template, defaults=templatekw.keywords,
633 tmpl = formatter.maketemplater(ui, template, defaults=templatekw.keywords,
633 resources=tres)
634 resources=tres)
634
635
635 pad = max(len(l) for l in labels)
636 pad = max(len(l) for l in labels)
636
637
637 newlabels = [_formatconflictmarker(cd, tmpl, labels[0], pad),
638 newlabels = [_formatconflictmarker(cd, tmpl, labels[0], pad),
638 _formatconflictmarker(co, tmpl, labels[1], pad)]
639 _formatconflictmarker(co, tmpl, labels[1], pad)]
639 if len(labels) > 2:
640 if len(labels) > 2:
640 newlabels.append(_formatconflictmarker(ca, tmpl, labels[2], pad))
641 newlabels.append(_formatconflictmarker(ca, tmpl, labels[2], pad))
641 return newlabels
642 return newlabels
642
643
643 def partextras(labels):
644 def partextras(labels):
644 """Return a dictionary of extra labels for use in prompts to the user
645 """Return a dictionary of extra labels for use in prompts to the user
645
646
646 Intended use is in strings of the form "(l)ocal%(l)s".
647 Intended use is in strings of the form "(l)ocal%(l)s".
647 """
648 """
648 if labels is None:
649 if labels is None:
649 return {
650 return {
650 "l": "",
651 "l": "",
651 "o": "",
652 "o": "",
652 }
653 }
653
654
654 return {
655 return {
655 "l": " [%s]" % labels[0],
656 "l": " [%s]" % labels[0],
656 "o": " [%s]" % labels[1],
657 "o": " [%s]" % labels[1],
657 }
658 }
658
659
659 def _restorebackup(fcd, back):
660 def _restorebackup(fcd, back):
660 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
661 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
661 # util.copy here instead.
662 # util.copy here instead.
662 fcd.write(back.data(), fcd.flags())
663 fcd.write(back.data(), fcd.flags())
663
664
664 def _makebackup(repo, ui, wctx, fcd, premerge):
665 def _makebackup(repo, ui, wctx, fcd, premerge):
665 """Makes and returns a filectx-like object for ``fcd``'s backup file.
666 """Makes and returns a filectx-like object for ``fcd``'s backup file.
666
667
667 In addition to preserving the user's pre-existing modifications to `fcd`
668 In addition to preserving the user's pre-existing modifications to `fcd`
668 (if any), the backup is used to undo certain premerges, confirm whether a
669 (if any), the backup is used to undo certain premerges, confirm whether a
669 merge changed anything, and determine what line endings the new file should
670 merge changed anything, and determine what line endings the new file should
670 have.
671 have.
671
672
672 Backups only need to be written once (right before the premerge) since their
673 Backups only need to be written once (right before the premerge) since their
673 content doesn't change afterwards.
674 content doesn't change afterwards.
674 """
675 """
675 if fcd.isabsent():
676 if fcd.isabsent():
676 return None
677 return None
677 # TODO: Break this import cycle somehow. (filectx -> ctx -> fileset ->
678 # TODO: Break this import cycle somehow. (filectx -> ctx -> fileset ->
678 # merge -> filemerge). (I suspect the fileset import is the weakest link)
679 # merge -> filemerge). (I suspect the fileset import is the weakest link)
679 from . import context
680 from . import context
680 a = _workingpath(repo, fcd)
681 a = _workingpath(repo, fcd)
681 back = scmutil.origpath(ui, repo, a)
682 back = scmutil.origpath(ui, repo, a)
682 inworkingdir = (back.startswith(repo.wvfs.base) and not
683 inworkingdir = (back.startswith(repo.wvfs.base) and not
683 back.startswith(repo.vfs.base))
684 back.startswith(repo.vfs.base))
684 if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
685 if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
685 # If the backup file is to be in the working directory, and we're
686 # If the backup file is to be in the working directory, and we're
686 # merging in-memory, we must redirect the backup to the memory context
687 # merging in-memory, we must redirect the backup to the memory context
687 # so we don't disturb the working directory.
688 # so we don't disturb the working directory.
688 relpath = back[len(repo.wvfs.base) + 1:]
689 relpath = back[len(repo.wvfs.base) + 1:]
689 if premerge:
690 if premerge:
690 wctx[relpath].write(fcd.data(), fcd.flags())
691 wctx[relpath].write(fcd.data(), fcd.flags())
691 return wctx[relpath]
692 return wctx[relpath]
692 else:
693 else:
693 if premerge:
694 if premerge:
694 # Otherwise, write to wherever path the user specified the backups
695 # Otherwise, write to wherever path the user specified the backups
695 # should go. We still need to switch based on whether the source is
696 # should go. We still need to switch based on whether the source is
696 # in-memory so we can use the fast path of ``util.copy`` if both are
697 # in-memory so we can use the fast path of ``util.copy`` if both are
697 # on disk.
698 # on disk.
698 if isinstance(fcd, context.overlayworkingfilectx):
699 if isinstance(fcd, context.overlayworkingfilectx):
699 util.writefile(back, fcd.data())
700 util.writefile(back, fcd.data())
700 else:
701 else:
701 util.copyfile(a, back)
702 util.copyfile(a, back)
702 # A arbitraryfilectx is returned, so we can run the same functions on
703 # A arbitraryfilectx is returned, so we can run the same functions on
703 # the backup context regardless of where it lives.
704 # the backup context regardless of where it lives.
704 return context.arbitraryfilectx(back, repo=repo)
705 return context.arbitraryfilectx(back, repo=repo)
705
706
706 @contextlib.contextmanager
707 @contextlib.contextmanager
707 def _maketempfiles(repo, fco, fca, localpath, uselocalpath):
708 def _maketempfiles(repo, fco, fca, localpath, uselocalpath):
708 """Writes out `fco` and `fca` as temporary files, and (if uselocalpath)
709 """Writes out `fco` and `fca` as temporary files, and (if uselocalpath)
709 copies `localpath` to another temporary file, so an external merge tool may
710 copies `localpath` to another temporary file, so an external merge tool may
710 use them.
711 use them.
711 """
712 """
712 tmproot = None
713 tmproot = None
713 tmprootprefix = repo.ui.config('experimental', 'mergetempdirprefix')
714 tmprootprefix = repo.ui.config('experimental', 'mergetempdirprefix')
714 if tmprootprefix:
715 if tmprootprefix:
715 tmproot = pycompat.mkdtemp(prefix=tmprootprefix)
716 tmproot = pycompat.mkdtemp(prefix=tmprootprefix)
716
717
717 def maketempfrompath(prefix, path):
718 def maketempfrompath(prefix, path):
718 fullbase, ext = os.path.splitext(path)
719 fullbase, ext = os.path.splitext(path)
719 pre = "%s~%s" % (os.path.basename(fullbase), prefix)
720 pre = "%s~%s" % (os.path.basename(fullbase), prefix)
720 if tmproot:
721 if tmproot:
721 name = os.path.join(tmproot, pre)
722 name = os.path.join(tmproot, pre)
722 if ext:
723 if ext:
723 name += ext
724 name += ext
724 f = open(name, r"wb")
725 f = open(name, r"wb")
725 else:
726 else:
726 fd, name = pycompat.mkstemp(prefix=pre + '.', suffix=ext)
727 fd, name = pycompat.mkstemp(prefix=pre + '.', suffix=ext)
727 f = os.fdopen(fd, r"wb")
728 f = os.fdopen(fd, r"wb")
728 return f, name
729 return f, name
729
730
730 def tempfromcontext(prefix, ctx):
731 def tempfromcontext(prefix, ctx):
731 f, name = maketempfrompath(prefix, ctx.path())
732 f, name = maketempfrompath(prefix, ctx.path())
732 data = repo.wwritedata(ctx.path(), ctx.data())
733 data = repo.wwritedata(ctx.path(), ctx.data())
733 f.write(data)
734 f.write(data)
734 f.close()
735 f.close()
735 return name
736 return name
736
737
737 b = tempfromcontext("base", fca)
738 b = tempfromcontext("base", fca)
738 c = tempfromcontext("other", fco)
739 c = tempfromcontext("other", fco)
739 d = localpath
740 d = localpath
740 if uselocalpath:
741 if uselocalpath:
741 # We start off with this being the backup filename, so remove the .orig
742 # We start off with this being the backup filename, so remove the .orig
742 # to make syntax-highlighting more likely.
743 # to make syntax-highlighting more likely.
743 if d.endswith('.orig'):
744 if d.endswith('.orig'):
744 d, _ = os.path.splitext(d)
745 d, _ = os.path.splitext(d)
745 f, d = maketempfrompath("local", d)
746 f, d = maketempfrompath("local", d)
746 with open(localpath, 'rb') as src:
747 with open(localpath, 'rb') as src:
747 f.write(src.read())
748 f.write(src.read())
748 f.close()
749 f.close()
749
750
750 try:
751 try:
751 yield b, c, d
752 yield b, c, d
752 finally:
753 finally:
753 if tmproot:
754 if tmproot:
754 shutil.rmtree(tmproot)
755 shutil.rmtree(tmproot)
755 else:
756 else:
756 util.unlink(b)
757 util.unlink(b)
757 util.unlink(c)
758 util.unlink(c)
758 # if not uselocalpath, d is the 'orig'/backup file which we
759 # if not uselocalpath, d is the 'orig'/backup file which we
759 # shouldn't delete.
760 # shouldn't delete.
760 if d and uselocalpath:
761 if d and uselocalpath:
761 util.unlink(d)
762 util.unlink(d)
762
763
763 def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
764 def _filemerge(premerge, repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
764 """perform a 3-way merge in the working directory
765 """perform a 3-way merge in the working directory
765
766
766 premerge = whether this is a premerge
767 premerge = whether this is a premerge
767 mynode = parent node before merge
768 mynode = parent node before merge
768 orig = original local filename before merge
769 orig = original local filename before merge
769 fco = other file context
770 fco = other file context
770 fca = ancestor file context
771 fca = ancestor file context
771 fcd = local file context for current/destination file
772 fcd = local file context for current/destination file
772
773
773 Returns whether the merge is complete, the return value of the merge, and
774 Returns whether the merge is complete, the return value of the merge, and
774 a boolean indicating whether the file was deleted from disk."""
775 a boolean indicating whether the file was deleted from disk."""
775
776
776 if not fco.cmp(fcd): # files identical?
777 if not fco.cmp(fcd): # files identical?
777 return True, None, False
778 return True, None, False
778
779
779 ui = repo.ui
780 ui = repo.ui
780 fd = fcd.path()
781 fd = fcd.path()
781 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
782 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
782 symlink = 'l' in fcd.flags() + fco.flags()
783 symlink = 'l' in fcd.flags() + fco.flags()
783 changedelete = fcd.isabsent() or fco.isabsent()
784 changedelete = fcd.isabsent() or fco.isabsent()
784 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete)
785 tool, toolpath = _picktool(repo, ui, fd, binary, symlink, changedelete)
785 scriptfn = None
786 scriptfn = None
786 if tool in internals and tool.startswith('internal:'):
787 if tool in internals and tool.startswith('internal:'):
787 # normalize to new-style names (':merge' etc)
788 # normalize to new-style names (':merge' etc)
788 tool = tool[len('internal'):]
789 tool = tool[len('internal'):]
789 if toolpath and toolpath.startswith('python:'):
790 if toolpath and toolpath.startswith('python:'):
790 invalidsyntax = False
791 invalidsyntax = False
791 if toolpath.count(':') >= 2:
792 if toolpath.count(':') >= 2:
792 script, scriptfn = toolpath[7:].rsplit(':', 1)
793 script, scriptfn = toolpath[7:].rsplit(':', 1)
793 if not scriptfn:
794 if not scriptfn:
794 invalidsyntax = True
795 invalidsyntax = True
795 # missing :callable can lead to spliting on windows drive letter
796 # missing :callable can lead to spliting on windows drive letter
796 if '\\' in scriptfn or '/' in scriptfn:
797 if '\\' in scriptfn or '/' in scriptfn:
797 invalidsyntax = True
798 invalidsyntax = True
798 else:
799 else:
799 invalidsyntax = True
800 invalidsyntax = True
800 if invalidsyntax:
801 if invalidsyntax:
801 raise error.Abort(_("invalid 'python:' syntax: %s") % toolpath)
802 raise error.Abort(_("invalid 'python:' syntax: %s") % toolpath)
802 toolpath = script
803 toolpath = script
803 ui.debug("picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n"
804 ui.debug("picked tool '%s' for %s (binary %s symlink %s changedelete %s)\n"
804 % (tool, fd, pycompat.bytestr(binary), pycompat.bytestr(symlink),
805 % (tool, fd, pycompat.bytestr(binary), pycompat.bytestr(symlink),
805 pycompat.bytestr(changedelete)))
806 pycompat.bytestr(changedelete)))
806
807
807 if tool in internals:
808 if tool in internals:
808 func = internals[tool]
809 func = internals[tool]
809 mergetype = func.mergetype
810 mergetype = func.mergetype
810 onfailure = func.onfailure
811 onfailure = func.onfailure
811 precheck = func.precheck
812 precheck = func.precheck
812 isexternal = False
813 isexternal = False
813 else:
814 else:
814 if wctx.isinmemory():
815 if wctx.isinmemory():
815 func = _xmergeimm
816 func = _xmergeimm
816 else:
817 else:
817 func = _xmerge
818 func = _xmerge
818 mergetype = fullmerge
819 mergetype = fullmerge
819 onfailure = _("merging %s failed!\n")
820 onfailure = _("merging %s failed!\n")
820 precheck = None
821 precheck = None
821 isexternal = True
822 isexternal = True
822
823
823 toolconf = tool, toolpath, binary, symlink, scriptfn
824 toolconf = tool, toolpath, binary, symlink, scriptfn
824
825
825 if mergetype == nomerge:
826 if mergetype == nomerge:
826 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
827 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf, labels)
827 return True, r, deleted
828 return True, r, deleted
828
829
829 if premerge:
830 if premerge:
830 if orig != fco.path():
831 if orig != fco.path():
831 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
832 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
832 else:
833 else:
833 ui.status(_("merging %s\n") % fd)
834 ui.status(_("merging %s\n") % fd)
834
835
835 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
836 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
836
837
837 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
838 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
838 toolconf):
839 toolconf):
839 if onfailure:
840 if onfailure:
840 if wctx.isinmemory():
841 if wctx.isinmemory():
841 raise error.InMemoryMergeConflictsError('in-memory merge does '
842 raise error.InMemoryMergeConflictsError('in-memory merge does '
842 'not support merge '
843 'not support merge '
843 'conflicts')
844 'conflicts')
844 ui.warn(onfailure % fd)
845 ui.warn(onfailure % fd)
845 return True, 1, False
846 return True, 1, False
846
847
847 back = _makebackup(repo, ui, wctx, fcd, premerge)
848 back = _makebackup(repo, ui, wctx, fcd, premerge)
848 files = (None, None, None, back)
849 files = (None, None, None, back)
849 r = 1
850 r = 1
850 try:
851 try:
851 internalmarkerstyle = ui.config('ui', 'mergemarkers')
852 internalmarkerstyle = ui.config('ui', 'mergemarkers')
852 if isexternal:
853 if isexternal:
853 markerstyle = _toolstr(ui, tool, 'mergemarkers')
854 markerstyle = _toolstr(ui, tool, 'mergemarkers')
854 else:
855 else:
855 markerstyle = internalmarkerstyle
856 markerstyle = internalmarkerstyle
856
857
857 if not labels:
858 if not labels:
858 labels = _defaultconflictlabels
859 labels = _defaultconflictlabels
859 formattedlabels = labels
860 formattedlabels = labels
860 if markerstyle != 'basic':
861 if markerstyle != 'basic':
861 formattedlabels = _formatlabels(repo, fcd, fco, fca, labels,
862 formattedlabels = _formatlabels(repo, fcd, fco, fca, labels,
862 tool=tool)
863 tool=tool)
863
864
864 if premerge and mergetype == fullmerge:
865 if premerge and mergetype == fullmerge:
865 # conflict markers generated by premerge will use 'detailed'
866 # conflict markers generated by premerge will use 'detailed'
866 # settings if either ui.mergemarkers or the tool's mergemarkers
867 # settings if either ui.mergemarkers or the tool's mergemarkers
867 # setting is 'detailed'. This way tools can have basic labels in
868 # setting is 'detailed'. This way tools can have basic labels in
868 # space-constrained areas of the UI, but still get full information
869 # space-constrained areas of the UI, but still get full information
869 # in conflict markers if premerge is 'keep' or 'keep-merge3'.
870 # in conflict markers if premerge is 'keep' or 'keep-merge3'.
870 premergelabels = labels
871 premergelabels = labels
871 labeltool = None
872 labeltool = None
872 if markerstyle != 'basic':
873 if markerstyle != 'basic':
873 # respect 'tool's mergemarkertemplate (which defaults to
874 # respect 'tool's mergemarkertemplate (which defaults to
874 # ui.mergemarkertemplate)
875 # ui.mergemarkertemplate)
875 labeltool = tool
876 labeltool = tool
876 if internalmarkerstyle != 'basic' or markerstyle != 'basic':
877 if internalmarkerstyle != 'basic' or markerstyle != 'basic':
877 premergelabels = _formatlabels(repo, fcd, fco, fca,
878 premergelabels = _formatlabels(repo, fcd, fco, fca,
878 premergelabels, tool=labeltool)
879 premergelabels, tool=labeltool)
879
880
880 r = _premerge(repo, fcd, fco, fca, toolconf, files,
881 r = _premerge(repo, fcd, fco, fca, toolconf, files,
881 labels=premergelabels)
882 labels=premergelabels)
882 # complete if premerge successful (r is 0)
883 # complete if premerge successful (r is 0)
883 return not r, r, False
884 return not r, r, False
884
885
885 needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca,
886 needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca,
886 toolconf, files, labels=formattedlabels)
887 toolconf, files, labels=formattedlabels)
887
888
888 if needcheck:
889 if needcheck:
889 r = _check(repo, r, ui, tool, fcd, files)
890 r = _check(repo, r, ui, tool, fcd, files)
890
891
891 if r:
892 if r:
892 if onfailure:
893 if onfailure:
893 if wctx.isinmemory():
894 if wctx.isinmemory():
894 raise error.InMemoryMergeConflictsError('in-memory merge '
895 raise error.InMemoryMergeConflictsError('in-memory merge '
895 'does not support '
896 'does not support '
896 'merge conflicts')
897 'merge conflicts')
897 ui.warn(onfailure % fd)
898 ui.warn(onfailure % fd)
898 _onfilemergefailure(ui)
899 _onfilemergefailure(ui)
899
900
900 return True, r, deleted
901 return True, r, deleted
901 finally:
902 finally:
902 if not r and back is not None:
903 if not r and back is not None:
903 back.remove()
904 back.remove()
904
905
905 def _haltmerge():
906 def _haltmerge():
906 msg = _('merge halted after failed merge (see hg resolve)')
907 msg = _('merge halted after failed merge (see hg resolve)')
907 raise error.InterventionRequired(msg)
908 raise error.InterventionRequired(msg)
908
909
909 def _onfilemergefailure(ui):
910 def _onfilemergefailure(ui):
910 action = ui.config('merge', 'on-failure')
911 action = ui.config('merge', 'on-failure')
911 if action == 'prompt':
912 if action == 'prompt':
912 msg = _('continue merge operation (yn)?' '$$ &Yes $$ &No')
913 msg = _('continue merge operation (yn)?' '$$ &Yes $$ &No')
913 if ui.promptchoice(msg, 0) == 1:
914 if ui.promptchoice(msg, 0) == 1:
914 _haltmerge()
915 _haltmerge()
915 if action == 'halt':
916 if action == 'halt':
916 _haltmerge()
917 _haltmerge()
917 # default action is 'continue', in which case we neither prompt nor halt
918 # default action is 'continue', in which case we neither prompt nor halt
918
919
919 def hasconflictmarkers(data):
920 def hasconflictmarkers(data):
920 return bool(re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", data,
921 return bool(re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", data,
921 re.MULTILINE))
922 re.MULTILINE))
922
923
923 def _check(repo, r, ui, tool, fcd, files):
924 def _check(repo, r, ui, tool, fcd, files):
924 fd = fcd.path()
925 fd = fcd.path()
925 unused, unused, unused, back = files
926 unused, unused, unused, back = files
926
927
927 if not r and (_toolbool(ui, tool, "checkconflicts") or
928 if not r and (_toolbool(ui, tool, "checkconflicts") or
928 'conflicts' in _toollist(ui, tool, "check")):
929 'conflicts' in _toollist(ui, tool, "check")):
929 if hasconflictmarkers(fcd.data()):
930 if hasconflictmarkers(fcd.data()):
930 r = 1
931 r = 1
931
932
932 checked = False
933 checked = False
933 if 'prompt' in _toollist(ui, tool, "check"):
934 if 'prompt' in _toollist(ui, tool, "check"):
934 checked = True
935 checked = True
935 if ui.promptchoice(_("was merge of '%s' successful (yn)?"
936 if ui.promptchoice(_("was merge of '%s' successful (yn)?"
936 "$$ &Yes $$ &No") % fd, 1):
937 "$$ &Yes $$ &No") % fd, 1):
937 r = 1
938 r = 1
938
939
939 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
940 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
940 'changed' in
941 'changed' in
941 _toollist(ui, tool, "check")):
942 _toollist(ui, tool, "check")):
942 if back is not None and not fcd.cmp(back):
943 if back is not None and not fcd.cmp(back):
943 if ui.promptchoice(_(" output file %s appears unchanged\n"
944 if ui.promptchoice(_(" output file %s appears unchanged\n"
944 "was merge successful (yn)?"
945 "was merge successful (yn)?"
945 "$$ &Yes $$ &No") % fd, 1):
946 "$$ &Yes $$ &No") % fd, 1):
946 r = 1
947 r = 1
947
948
948 if back is not None and _toolbool(ui, tool, "fixeol"):
949 if back is not None and _toolbool(ui, tool, "fixeol"):
949 _matcheol(_workingpath(repo, fcd), back)
950 _matcheol(_workingpath(repo, fcd), back)
950
951
951 return r
952 return r
952
953
953 def _workingpath(repo, ctx):
954 def _workingpath(repo, ctx):
954 return repo.wjoin(ctx.path())
955 return repo.wjoin(ctx.path())
955
956
956 def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
957 def premerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
957 return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca,
958 return _filemerge(True, repo, wctx, mynode, orig, fcd, fco, fca,
958 labels=labels)
959 labels=labels)
959
960
960 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
961 def filemerge(repo, wctx, mynode, orig, fcd, fco, fca, labels=None):
961 return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,
962 return _filemerge(False, repo, wctx, mynode, orig, fcd, fco, fca,
962 labels=labels)
963 labels=labels)
963
964
964 def loadinternalmerge(ui, extname, registrarobj):
965 def loadinternalmerge(ui, extname, registrarobj):
965 """Load internal merge tool from specified registrarobj
966 """Load internal merge tool from specified registrarobj
966 """
967 """
967 for name, func in registrarobj._table.iteritems():
968 for name, func in registrarobj._table.iteritems():
968 fullname = ':' + name
969 fullname = ':' + name
969 internals[fullname] = func
970 internals[fullname] = func
970 internals['internal:' + name] = func
971 internals['internal:' + name] = func
971 internalsdoc[fullname] = func
972 internalsdoc[fullname] = func
972
973
973 # load built-in merge tools explicitly to setup internalsdoc
974 # load built-in merge tools explicitly to setup internalsdoc
974 loadinternalmerge(None, None, internaltool)
975 loadinternalmerge(None, None, internaltool)
975
976
976 # tell hggettext to extract docstrings from these functions:
977 # tell hggettext to extract docstrings from these functions:
977 i18nfunctions = internals.values()
978 i18nfunctions = internals.values()
@@ -1,1872 +1,1874 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 repo
4 $ hg init repo
5 $ cd repo
5 $ cd repo
6
6
7 revision 0
7 revision 0
8
8
9 $ echo "revision 0" > f
9 $ echo "revision 0" > f
10 $ echo "space" >> f
10 $ echo "space" >> f
11 $ hg commit -Am "revision 0"
11 $ hg commit -Am "revision 0"
12 adding f
12 adding f
13
13
14 revision 1
14 revision 1
15
15
16 $ echo "revision 1" > f
16 $ echo "revision 1" > f
17 $ echo "space" >> f
17 $ echo "space" >> f
18 $ hg commit -Am "revision 1"
18 $ hg commit -Am "revision 1"
19 $ hg update 0 > /dev/null
19 $ hg update 0 > /dev/null
20
20
21 revision 2
21 revision 2
22
22
23 $ echo "revision 2" > f
23 $ echo "revision 2" > f
24 $ echo "space" >> f
24 $ echo "space" >> f
25 $ hg commit -Am "revision 2"
25 $ hg commit -Am "revision 2"
26 created new head
26 created new head
27 $ hg update 0 > /dev/null
27 $ hg update 0 > /dev/null
28
28
29 revision 3 - simple to merge
29 revision 3 - simple to merge
30
30
31 $ echo "revision 3" >> f
31 $ echo "revision 3" >> f
32 $ hg commit -Am "revision 3"
32 $ hg commit -Am "revision 3"
33 created new head
33 created new head
34
34
35 revision 4 - hard to merge
35 revision 4 - hard to merge
36
36
37 $ hg update 0 > /dev/null
37 $ hg update 0 > /dev/null
38 $ echo "revision 4" > f
38 $ echo "revision 4" > f
39 $ hg commit -Am "revision 4"
39 $ hg commit -Am "revision 4"
40 created new head
40 created new head
41
41
42 $ echo "[merge-tools]" > .hg/hgrc
42 $ echo "[merge-tools]" > .hg/hgrc
43
43
44 $ beforemerge() {
44 $ beforemerge() {
45 > cat .hg/hgrc
45 > cat .hg/hgrc
46 > echo "# hg update -C 1"
46 > echo "# hg update -C 1"
47 > hg update -C 1 > /dev/null
47 > hg update -C 1 > /dev/null
48 > }
48 > }
49 $ aftermerge() {
49 $ aftermerge() {
50 > echo "# cat f"
50 > echo "# cat f"
51 > cat f
51 > cat f
52 > echo "# hg stat"
52 > echo "# hg stat"
53 > hg stat
53 > hg stat
54 > echo "# hg resolve --list"
54 > echo "# hg resolve --list"
55 > hg resolve --list
55 > hg resolve --list
56 > rm -f f.orig
56 > rm -f f.orig
57 > }
57 > }
58
58
59 Tool selection
59 Tool selection
60
60
61 default is internal merge:
61 default is internal merge:
62
62
63 $ beforemerge
63 $ beforemerge
64 [merge-tools]
64 [merge-tools]
65 # hg update -C 1
65 # hg update -C 1
66
66
67 hg merge -r 2
67 hg merge -r 2
68 override $PATH to ensure hgmerge not visible; use $PYTHON in case we're
68 override $PATH to ensure hgmerge not visible; use $PYTHON in case we're
69 running from a devel copy, not a temp installation
69 running from a devel copy, not a temp installation
70
70
71 $ PATH="$BINDIR:/usr/sbin" $PYTHON "$BINDIR"/hg merge -r 2
71 $ PATH="$BINDIR:/usr/sbin" $PYTHON "$BINDIR"/hg merge -r 2
72 merging f
72 merging f
73 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
73 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
74 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
74 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
75 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
75 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
76 [1]
76 [1]
77 $ aftermerge
77 $ aftermerge
78 # cat f
78 # cat f
79 <<<<<<< working copy: ef83787e2614 - test: revision 1
79 <<<<<<< working copy: ef83787e2614 - test: revision 1
80 revision 1
80 revision 1
81 =======
81 =======
82 revision 2
82 revision 2
83 >>>>>>> merge rev: 0185f4e0cf02 - test: revision 2
83 >>>>>>> merge rev: 0185f4e0cf02 - test: revision 2
84 space
84 space
85 # hg stat
85 # hg stat
86 M f
86 M f
87 ? f.orig
87 ? f.orig
88 # hg resolve --list
88 # hg resolve --list
89 U f
89 U f
90
90
91 simplest hgrc using false for merge:
91 simplest hgrc using false for merge:
92
92
93 $ echo "false.whatever=" >> .hg/hgrc
93 $ echo "false.whatever=" >> .hg/hgrc
94 $ beforemerge
94 $ beforemerge
95 [merge-tools]
95 [merge-tools]
96 false.whatever=
96 false.whatever=
97 # hg update -C 1
97 # hg update -C 1
98 $ hg merge -r 2
98 $ hg merge -r 2
99 merging f
99 merging f
100 merging f failed!
100 merging f failed!
101 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
101 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
102 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
102 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
103 [1]
103 [1]
104 $ aftermerge
104 $ aftermerge
105 # cat f
105 # cat f
106 revision 1
106 revision 1
107 space
107 space
108 # hg stat
108 # hg stat
109 M f
109 M f
110 ? f.orig
110 ? f.orig
111 # hg resolve --list
111 # hg resolve --list
112 U f
112 U f
113
113
114 #if unix-permissions
114 #if unix-permissions
115
115
116 unexecutable file in $PATH shouldn't be found:
116 unexecutable file in $PATH shouldn't be found:
117
117
118 $ echo "echo fail" > false
118 $ echo "echo fail" > false
119 $ hg up -qC 1
119 $ hg up -qC 1
120 $ PATH="`pwd`:$BINDIR:/usr/sbin" $PYTHON "$BINDIR"/hg merge -r 2
120 $ PATH="`pwd`:$BINDIR:/usr/sbin" $PYTHON "$BINDIR"/hg merge -r 2
121 merging f
121 merging f
122 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
122 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
123 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
123 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
124 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
124 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
125 [1]
125 [1]
126 $ rm false
126 $ rm false
127
127
128 #endif
128 #endif
129
129
130 executable directory in $PATH shouldn't be found:
130 executable directory in $PATH shouldn't be found:
131
131
132 $ mkdir false
132 $ mkdir false
133 $ hg up -qC 1
133 $ hg up -qC 1
134 $ PATH="`pwd`:$BINDIR:/usr/sbin" $PYTHON "$BINDIR"/hg merge -r 2
134 $ PATH="`pwd`:$BINDIR:/usr/sbin" $PYTHON "$BINDIR"/hg merge -r 2
135 merging f
135 merging f
136 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
136 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
137 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
137 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
138 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
138 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
139 [1]
139 [1]
140 $ rmdir false
140 $ rmdir false
141
141
142 true with higher .priority gets precedence:
142 true with higher .priority gets precedence:
143
143
144 $ echo "true.priority=1" >> .hg/hgrc
144 $ echo "true.priority=1" >> .hg/hgrc
145 $ beforemerge
145 $ beforemerge
146 [merge-tools]
146 [merge-tools]
147 false.whatever=
147 false.whatever=
148 true.priority=1
148 true.priority=1
149 # hg update -C 1
149 # hg update -C 1
150 $ hg merge -r 2
150 $ hg merge -r 2
151 merging f
151 merging f
152 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
152 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
153 (branch merge, don't forget to commit)
153 (branch merge, don't forget to commit)
154 $ aftermerge
154 $ aftermerge
155 # cat f
155 # cat f
156 revision 1
156 revision 1
157 space
157 space
158 # hg stat
158 # hg stat
159 M f
159 M f
160 # hg resolve --list
160 # hg resolve --list
161 R f
161 R f
162
162
163 unless lowered on command line:
163 unless lowered on command line:
164
164
165 $ beforemerge
165 $ beforemerge
166 [merge-tools]
166 [merge-tools]
167 false.whatever=
167 false.whatever=
168 true.priority=1
168 true.priority=1
169 # hg update -C 1
169 # hg update -C 1
170 $ hg merge -r 2 --config merge-tools.true.priority=-7
170 $ hg merge -r 2 --config merge-tools.true.priority=-7
171 merging f
171 merging f
172 merging f failed!
172 merging f failed!
173 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
173 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
174 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
174 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
175 [1]
175 [1]
176 $ aftermerge
176 $ aftermerge
177 # cat f
177 # cat f
178 revision 1
178 revision 1
179 space
179 space
180 # hg stat
180 # hg stat
181 M f
181 M f
182 ? f.orig
182 ? f.orig
183 # hg resolve --list
183 # hg resolve --list
184 U f
184 U f
185
185
186 or false set higher on command line:
186 or false set higher on command line:
187
187
188 $ beforemerge
188 $ beforemerge
189 [merge-tools]
189 [merge-tools]
190 false.whatever=
190 false.whatever=
191 true.priority=1
191 true.priority=1
192 # hg update -C 1
192 # hg update -C 1
193 $ hg merge -r 2 --config merge-tools.false.priority=117
193 $ hg merge -r 2 --config merge-tools.false.priority=117
194 merging f
194 merging f
195 merging f failed!
195 merging f failed!
196 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
196 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
197 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
197 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
198 [1]
198 [1]
199 $ aftermerge
199 $ aftermerge
200 # cat f
200 # cat f
201 revision 1
201 revision 1
202 space
202 space
203 # hg stat
203 # hg stat
204 M f
204 M f
205 ? f.orig
205 ? f.orig
206 # hg resolve --list
206 # hg resolve --list
207 U f
207 U f
208
208
209 or true set to disabled:
209 or true set to disabled:
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.disabled=yes
215 $ hg merge -r 2 --config merge-tools.true.disabled=yes
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 merge --abort' to abandon
219 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' 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 # hg resolve --list
228 # hg resolve --list
229 U f
229 U f
230
230
231 or true.executable not found in PATH:
231 or true.executable not found in PATH:
232
232
233 $ beforemerge
233 $ beforemerge
234 [merge-tools]
234 [merge-tools]
235 false.whatever=
235 false.whatever=
236 true.priority=1
236 true.priority=1
237 # hg update -C 1
237 # hg update -C 1
238 $ hg merge -r 2 --config merge-tools.true.executable=nonexistentmergetool
238 $ hg merge -r 2 --config merge-tools.true.executable=nonexistentmergetool
239 merging f
239 merging f
240 merging f failed!
240 merging f failed!
241 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
241 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
242 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
242 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
243 [1]
243 [1]
244 $ aftermerge
244 $ aftermerge
245 # cat f
245 # cat f
246 revision 1
246 revision 1
247 space
247 space
248 # hg stat
248 # hg stat
249 M f
249 M f
250 ? f.orig
250 ? f.orig
251 # hg resolve --list
251 # hg resolve --list
252 U f
252 U f
253
253
254 or true.executable with bogus path:
254 or true.executable with bogus path:
255
255
256 $ beforemerge
256 $ beforemerge
257 [merge-tools]
257 [merge-tools]
258 false.whatever=
258 false.whatever=
259 true.priority=1
259 true.priority=1
260 # hg update -C 1
260 # hg update -C 1
261 $ hg merge -r 2 --config merge-tools.true.executable=/nonexistent/mergetool
261 $ hg merge -r 2 --config merge-tools.true.executable=/nonexistent/mergetool
262 merging f
262 merging f
263 merging f failed!
263 merging f failed!
264 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
264 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
265 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
265 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
266 [1]
266 [1]
267 $ aftermerge
267 $ aftermerge
268 # cat f
268 # cat f
269 revision 1
269 revision 1
270 space
270 space
271 # hg stat
271 # hg stat
272 M f
272 M f
273 ? f.orig
273 ? f.orig
274 # hg resolve --list
274 # hg resolve --list
275 U f
275 U f
276
276
277 but true.executable set to cat found in PATH works:
277 but true.executable set to cat found in PATH works:
278
278
279 $ echo "true.executable=cat" >> .hg/hgrc
279 $ echo "true.executable=cat" >> .hg/hgrc
280 $ beforemerge
280 $ beforemerge
281 [merge-tools]
281 [merge-tools]
282 false.whatever=
282 false.whatever=
283 true.priority=1
283 true.priority=1
284 true.executable=cat
284 true.executable=cat
285 # hg update -C 1
285 # hg update -C 1
286 $ hg merge -r 2
286 $ hg merge -r 2
287 merging f
287 merging f
288 revision 1
288 revision 1
289 space
289 space
290 revision 0
290 revision 0
291 space
291 space
292 revision 2
292 revision 2
293 space
293 space
294 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
294 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
295 (branch merge, don't forget to commit)
295 (branch merge, don't forget to commit)
296 $ aftermerge
296 $ aftermerge
297 # cat f
297 # cat f
298 revision 1
298 revision 1
299 space
299 space
300 # hg stat
300 # hg stat
301 M f
301 M f
302 # hg resolve --list
302 # hg resolve --list
303 R f
303 R f
304
304
305 and true.executable set to cat with path works:
305 and true.executable set to cat with path works:
306
306
307 $ beforemerge
307 $ beforemerge
308 [merge-tools]
308 [merge-tools]
309 false.whatever=
309 false.whatever=
310 true.priority=1
310 true.priority=1
311 true.executable=cat
311 true.executable=cat
312 # hg update -C 1
312 # hg update -C 1
313 $ hg merge -r 2 --config merge-tools.true.executable=cat
313 $ hg merge -r 2 --config merge-tools.true.executable=cat
314 merging f
314 merging f
315 revision 1
315 revision 1
316 space
316 space
317 revision 0
317 revision 0
318 space
318 space
319 revision 2
319 revision 2
320 space
320 space
321 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
321 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
322 (branch merge, don't forget to commit)
322 (branch merge, don't forget to commit)
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 # hg resolve --list
329 # hg resolve --list
330 R f
330 R f
331
331
332 executable set to python script that succeeds:
332 executable set to python script that succeeds:
333
333
334 $ cat > "$TESTTMP/myworkingmerge.py" <<EOF
334 $ cat > "$TESTTMP/myworkingmerge.py" <<EOF
335 > def myworkingmergefn(ui, repo, args, **kwargs):
335 > def myworkingmergefn(ui, repo, args, **kwargs):
336 > return False
336 > return False
337 > EOF
337 > EOF
338 $ beforemerge
338 $ beforemerge
339 [merge-tools]
339 [merge-tools]
340 false.whatever=
340 false.whatever=
341 true.priority=1
341 true.priority=1
342 true.executable=cat
342 true.executable=cat
343 # hg update -C 1
343 # hg update -C 1
344 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:myworkingmergefn"
344 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:myworkingmergefn"
345 merging f
345 merging f
346 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
346 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
347 (branch merge, don't forget to commit)
347 (branch merge, don't forget to commit)
348 $ aftermerge
348 $ aftermerge
349 # cat f
349 # cat f
350 revision 1
350 revision 1
351 space
351 space
352 # hg stat
352 # hg stat
353 M f
353 M f
354 # hg resolve --list
354 # hg resolve --list
355 R f
355 R f
356
356
357 executable set to python script that fails:
357 executable set to python script that fails:
358
358
359 $ cat > "$TESTTMP/mybrokenmerge.py" <<EOF
359 $ cat > "$TESTTMP/mybrokenmerge.py" <<EOF
360 > def mybrokenmergefn(ui, repo, args, **kwargs):
360 > def mybrokenmergefn(ui, repo, args, **kwargs):
361 > ui.write(b"some fail message\n")
361 > ui.write(b"some fail message\n")
362 > return True
362 > return True
363 > EOF
363 > EOF
364 $ beforemerge
364 $ beforemerge
365 [merge-tools]
365 [merge-tools]
366 false.whatever=
366 false.whatever=
367 true.priority=1
367 true.priority=1
368 true.executable=cat
368 true.executable=cat
369 # hg update -C 1
369 # hg update -C 1
370 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/mybrokenmerge.py:mybrokenmergefn"
370 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/mybrokenmerge.py:mybrokenmergefn"
371 merging f
371 merging f
372 some fail message
372 some fail message
373 abort: $TESTTMP/mybrokenmerge.py hook failed
373 abort: $TESTTMP/mybrokenmerge.py hook failed
374 [255]
374 [255]
375 $ aftermerge
375 $ aftermerge
376 # cat f
376 # cat f
377 revision 1
377 revision 1
378 space
378 space
379 # hg stat
379 # hg stat
380 ? f.orig
380 ? f.orig
381 # hg resolve --list
381 # hg resolve --list
382 U f
382 U f
383
383
384 executable set to python script that is missing function:
384 executable set to python script that is missing function:
385
385
386 $ beforemerge
386 $ beforemerge
387 [merge-tools]
387 [merge-tools]
388 false.whatever=
388 false.whatever=
389 true.priority=1
389 true.priority=1
390 true.executable=cat
390 true.executable=cat
391 # hg update -C 1
391 # hg update -C 1
392 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:missingFunction"
392 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:missingFunction"
393 merging f
393 merging f
394 abort: $TESTTMP/myworkingmerge.py does not have function: missingFunction
394 abort: $TESTTMP/myworkingmerge.py does not have function: missingFunction
395 [255]
395 [255]
396 $ aftermerge
396 $ aftermerge
397 # cat f
397 # cat f
398 revision 1
398 revision 1
399 space
399 space
400 # hg stat
400 # hg stat
401 ? f.orig
401 ? f.orig
402 # hg resolve --list
402 # hg resolve --list
403 U f
403 U f
404
404
405 executable set to missing python script:
405 executable set to missing python script:
406
406
407 $ beforemerge
407 $ beforemerge
408 [merge-tools]
408 [merge-tools]
409 false.whatever=
409 false.whatever=
410 true.priority=1
410 true.priority=1
411 true.executable=cat
411 true.executable=cat
412 # hg update -C 1
412 # hg update -C 1
413 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/missingpythonscript.py:mergefn"
413 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/missingpythonscript.py:mergefn"
414 merging f
414 merging f
415 abort: loading python merge script failed: $TESTTMP/missingpythonscript.py
415 abort: loading python merge script failed: $TESTTMP/missingpythonscript.py
416 [255]
416 [255]
417 $ aftermerge
417 $ aftermerge
418 # cat f
418 # cat f
419 revision 1
419 revision 1
420 space
420 space
421 # hg stat
421 # hg stat
422 ? f.orig
422 ? f.orig
423 # hg resolve --list
423 # hg resolve --list
424 U f
424 U f
425
425
426 executable set to python script but callable function is missing:
426 executable set to python script but callable function is missing:
427
427
428 $ beforemerge
428 $ beforemerge
429 [merge-tools]
429 [merge-tools]
430 false.whatever=
430 false.whatever=
431 true.priority=1
431 true.priority=1
432 true.executable=cat
432 true.executable=cat
433 # hg update -C 1
433 # hg update -C 1
434 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py"
434 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py"
435 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py
435 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py
436 [255]
436 [255]
437 $ aftermerge
437 $ aftermerge
438 # cat f
438 # cat f
439 revision 1
439 revision 1
440 space
440 space
441 # hg stat
441 # hg stat
442 # hg resolve --list
442 # hg resolve --list
443 U f
443 U f
444
444
445 executable set to python script but callable function is empty string:
445 executable set to python script but callable function is empty string:
446
446
447 $ beforemerge
447 $ beforemerge
448 [merge-tools]
448 [merge-tools]
449 false.whatever=
449 false.whatever=
450 true.priority=1
450 true.priority=1
451 true.executable=cat
451 true.executable=cat
452 # hg update -C 1
452 # hg update -C 1
453 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:"
453 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/myworkingmerge.py:"
454 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py:
454 abort: invalid 'python:' syntax: python:$TESTTMP/myworkingmerge.py:
455 [255]
455 [255]
456 $ aftermerge
456 $ aftermerge
457 # cat f
457 # cat f
458 revision 1
458 revision 1
459 space
459 space
460 # hg stat
460 # hg stat
461 # hg resolve --list
461 # hg resolve --list
462 U f
462 U f
463
463
464 executable set to python script but callable function is missing and path contains colon:
464 executable set to python script but callable function is missing and path contains colon:
465
465
466 $ beforemerge
466 $ beforemerge
467 [merge-tools]
467 [merge-tools]
468 false.whatever=
468 false.whatever=
469 true.priority=1
469 true.priority=1
470 true.executable=cat
470 true.executable=cat
471 # hg update -C 1
471 # hg update -C 1
472 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/some:dir/myworkingmerge.py"
472 $ hg merge -r 2 --config merge-tools.true.executable="python:$TESTTMP/some:dir/myworkingmerge.py"
473 abort: invalid 'python:' syntax: python:$TESTTMP/some:dir/myworkingmerge.py
473 abort: invalid 'python:' syntax: python:$TESTTMP/some:dir/myworkingmerge.py
474 [255]
474 [255]
475 $ aftermerge
475 $ aftermerge
476 # cat f
476 # cat f
477 revision 1
477 revision 1
478 space
478 space
479 # hg stat
479 # hg stat
480 # hg resolve --list
480 # hg resolve --list
481 U f
481 U f
482
482
483 executable set to python script filename that contains spaces:
483 executable set to python script filename that contains spaces:
484
484
485 $ mkdir -p "$TESTTMP/my path"
485 $ mkdir -p "$TESTTMP/my path"
486 $ cat > "$TESTTMP/my path/my working merge with spaces in filename.py" <<EOF
486 $ cat > "$TESTTMP/my path/my working merge with spaces in filename.py" <<EOF
487 > def myworkingmergefn(ui, repo, args, **kwargs):
487 > def myworkingmergefn(ui, repo, args, **kwargs):
488 > return False
488 > return False
489 > EOF
489 > EOF
490 $ beforemerge
490 $ beforemerge
491 [merge-tools]
491 [merge-tools]
492 false.whatever=
492 false.whatever=
493 true.priority=1
493 true.priority=1
494 true.executable=cat
494 true.executable=cat
495 # hg update -C 1
495 # hg update -C 1
496 $ hg merge -r 2 --config "merge-tools.true.executable=python:$TESTTMP/my path/my working merge with spaces in filename.py:myworkingmergefn"
496 $ hg merge -r 2 --config "merge-tools.true.executable=python:$TESTTMP/my path/my working merge with spaces in filename.py:myworkingmergefn"
497 merging f
497 merging f
498 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
498 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
499 (branch merge, don't forget to commit)
499 (branch merge, don't forget to commit)
500 $ aftermerge
500 $ aftermerge
501 # cat f
501 # cat f
502 revision 1
502 revision 1
503 space
503 space
504 # hg stat
504 # hg stat
505 M f
505 M f
506 # hg resolve --list
506 # hg resolve --list
507 R f
507 R f
508
508
509 #if unix-permissions
509 #if unix-permissions
510
510
511 environment variables in true.executable are handled:
511 environment variables in true.executable are handled:
512
512
513 $ echo 'echo "custom merge tool"' > .hg/merge.sh
513 $ echo 'echo "custom merge tool"' > .hg/merge.sh
514 $ beforemerge
514 $ beforemerge
515 [merge-tools]
515 [merge-tools]
516 false.whatever=
516 false.whatever=
517 true.priority=1
517 true.priority=1
518 true.executable=cat
518 true.executable=cat
519 # hg update -C 1
519 # hg update -C 1
520 $ hg --config merge-tools.true.executable='sh' \
520 $ hg --config merge-tools.true.executable='sh' \
521 > --config merge-tools.true.args=.hg/merge.sh \
521 > --config merge-tools.true.args=.hg/merge.sh \
522 > merge -r 2
522 > merge -r 2
523 merging f
523 merging f
524 custom merge tool
524 custom merge tool
525 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
525 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
526 (branch merge, don't forget to commit)
526 (branch merge, don't forget to commit)
527 $ aftermerge
527 $ aftermerge
528 # cat f
528 # cat f
529 revision 1
529 revision 1
530 space
530 space
531 # hg stat
531 # hg stat
532 M f
532 M f
533 # hg resolve --list
533 # hg resolve --list
534 R f
534 R f
535
535
536 #endif
536 #endif
537
537
538 Tool selection and merge-patterns
538 Tool selection and merge-patterns
539
539
540 merge-patterns specifies new tool false:
540 merge-patterns specifies new tool false:
541
541
542 $ beforemerge
542 $ beforemerge
543 [merge-tools]
543 [merge-tools]
544 false.whatever=
544 false.whatever=
545 true.priority=1
545 true.priority=1
546 true.executable=cat
546 true.executable=cat
547 # hg update -C 1
547 # hg update -C 1
548 $ hg merge -r 2 --config merge-patterns.f=false
548 $ hg merge -r 2 --config merge-patterns.f=false
549 merging f
549 merging f
550 merging f failed!
550 merging f failed!
551 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
551 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
552 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
552 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
553 [1]
553 [1]
554 $ aftermerge
554 $ aftermerge
555 # cat f
555 # cat f
556 revision 1
556 revision 1
557 space
557 space
558 # hg stat
558 # hg stat
559 M f
559 M f
560 ? f.orig
560 ? f.orig
561 # hg resolve --list
561 # hg resolve --list
562 U f
562 U f
563
563
564 merge-patterns specifies executable not found in PATH and gets warning:
564 merge-patterns specifies executable not found in PATH and gets warning:
565
565
566 $ beforemerge
566 $ beforemerge
567 [merge-tools]
567 [merge-tools]
568 false.whatever=
568 false.whatever=
569 true.priority=1
569 true.priority=1
570 true.executable=cat
570 true.executable=cat
571 # hg update -C 1
571 # hg update -C 1
572 $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool
572 $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool
573 couldn't find merge tool true (for pattern f)
573 couldn't find merge tool true (for pattern f)
574 merging f
574 merging f
575 couldn't find merge tool true (for pattern f)
575 couldn't find merge tool true (for pattern 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 merge --abort' to abandon
578 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' 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 # hg resolve --list
587 # hg resolve --list
588 U f
588 U f
589
589
590 merge-patterns specifies executable with bogus path and gets warning:
590 merge-patterns specifies executable with bogus path and gets warning:
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 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexistent/mergetool
598 $ hg merge -r 2 --config merge-patterns.f=true --config merge-tools.true.executable=/nonexistent/mergetool
599 couldn't find merge tool true (for pattern f)
599 couldn't find merge tool true (for pattern f)
600 merging f
600 merging f
601 couldn't find merge tool true (for pattern f)
601 couldn't find merge tool true (for pattern f)
602 merging f failed!
602 merging f failed!
603 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
603 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
604 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
604 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
605 [1]
605 [1]
606 $ aftermerge
606 $ aftermerge
607 # cat f
607 # cat f
608 revision 1
608 revision 1
609 space
609 space
610 # hg stat
610 # hg stat
611 M f
611 M f
612 ? f.orig
612 ? f.orig
613 # hg resolve --list
613 # hg resolve --list
614 U f
614 U f
615
615
616 ui.merge overrules priority
616 ui.merge overrules priority
617
617
618 ui.merge specifies false:
618 ui.merge specifies false:
619
619
620 $ beforemerge
620 $ beforemerge
621 [merge-tools]
621 [merge-tools]
622 false.whatever=
622 false.whatever=
623 true.priority=1
623 true.priority=1
624 true.executable=cat
624 true.executable=cat
625 # hg update -C 1
625 # hg update -C 1
626 $ hg merge -r 2 --config ui.merge=false
626 $ hg merge -r 2 --config ui.merge=false
627 merging f
627 merging f
628 merging f failed!
628 merging f failed!
629 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
629 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
630 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
630 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
631 [1]
631 [1]
632 $ aftermerge
632 $ aftermerge
633 # cat f
633 # cat f
634 revision 1
634 revision 1
635 space
635 space
636 # hg stat
636 # hg stat
637 M f
637 M f
638 ? f.orig
638 ? f.orig
639 # hg resolve --list
639 # hg resolve --list
640 U f
640 U f
641
641
642 ui.merge specifies internal:fail:
642 ui.merge specifies internal:fail:
643
643
644 $ beforemerge
644 $ beforemerge
645 [merge-tools]
645 [merge-tools]
646 false.whatever=
646 false.whatever=
647 true.priority=1
647 true.priority=1
648 true.executable=cat
648 true.executable=cat
649 # hg update -C 1
649 # hg update -C 1
650 $ hg merge -r 2 --config ui.merge=internal:fail
650 $ hg merge -r 2 --config ui.merge=internal:fail
651 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
651 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
652 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
652 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
653 [1]
653 [1]
654 $ aftermerge
654 $ aftermerge
655 # cat f
655 # cat f
656 revision 1
656 revision 1
657 space
657 space
658 # hg stat
658 # hg stat
659 M f
659 M f
660 # hg resolve --list
660 # hg resolve --list
661 U f
661 U f
662
662
663 ui.merge specifies :local (without internal prefix):
663 ui.merge specifies :local (without internal prefix):
664
664
665 $ beforemerge
665 $ beforemerge
666 [merge-tools]
666 [merge-tools]
667 false.whatever=
667 false.whatever=
668 true.priority=1
668 true.priority=1
669 true.executable=cat
669 true.executable=cat
670 # hg update -C 1
670 # hg update -C 1
671 $ hg merge -r 2 --config ui.merge=:local
671 $ hg merge -r 2 --config ui.merge=:local
672 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
672 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
673 (branch merge, don't forget to commit)
673 (branch merge, don't forget to commit)
674 $ aftermerge
674 $ aftermerge
675 # cat f
675 # cat f
676 revision 1
676 revision 1
677 space
677 space
678 # hg stat
678 # hg stat
679 M f
679 M f
680 # hg resolve --list
680 # hg resolve --list
681 R f
681 R f
682
682
683 ui.merge specifies internal:other:
683 ui.merge specifies internal:other:
684
684
685 $ beforemerge
685 $ beforemerge
686 [merge-tools]
686 [merge-tools]
687 false.whatever=
687 false.whatever=
688 true.priority=1
688 true.priority=1
689 true.executable=cat
689 true.executable=cat
690 # hg update -C 1
690 # hg update -C 1
691 $ hg merge -r 2 --config ui.merge=internal:other
691 $ hg merge -r 2 --config ui.merge=internal:other
692 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
692 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
693 (branch merge, don't forget to commit)
693 (branch merge, don't forget to commit)
694 $ aftermerge
694 $ aftermerge
695 # cat f
695 # cat f
696 revision 2
696 revision 2
697 space
697 space
698 # hg stat
698 # hg stat
699 M f
699 M f
700 # hg resolve --list
700 # hg resolve --list
701 R f
701 R f
702
702
703 ui.merge specifies internal:prompt:
703 ui.merge specifies internal:prompt:
704
704
705 $ beforemerge
705 $ beforemerge
706 [merge-tools]
706 [merge-tools]
707 false.whatever=
707 false.whatever=
708 true.priority=1
708 true.priority=1
709 true.executable=cat
709 true.executable=cat
710 # hg update -C 1
710 # hg update -C 1
711 $ hg merge -r 2 --config ui.merge=internal:prompt
711 $ hg merge -r 2 --config ui.merge=internal:prompt
712 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f? u
712 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f? u
713 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
713 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
714 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
714 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
715 [1]
715 [1]
716 $ aftermerge
716 $ aftermerge
717 # cat f
717 # cat f
718 revision 1
718 revision 1
719 space
719 space
720 # hg stat
720 # hg stat
721 M f
721 M f
722 # hg resolve --list
722 # hg resolve --list
723 U f
723 U f
724
724
725 ui.merge specifies :prompt, with 'leave unresolved' chosen
725 ui.merge specifies :prompt, with 'leave unresolved' chosen
726
726
727 $ beforemerge
727 $ beforemerge
728 [merge-tools]
728 [merge-tools]
729 false.whatever=
729 false.whatever=
730 true.priority=1
730 true.priority=1
731 true.executable=cat
731 true.executable=cat
732 # hg update -C 1
732 # hg update -C 1
733 $ hg merge -r 2 --config ui.merge=:prompt --config ui.interactive=True << EOF
733 $ hg merge -r 2 --config ui.merge=:prompt --config ui.interactive=True << EOF
734 > u
734 > u
735 > EOF
735 > EOF
736 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f? u
736 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f? u
737 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
737 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
738 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
738 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
739 [1]
739 [1]
740 $ aftermerge
740 $ aftermerge
741 # cat f
741 # cat f
742 revision 1
742 revision 1
743 space
743 space
744 # hg stat
744 # hg stat
745 M f
745 M f
746 # hg resolve --list
746 # hg resolve --list
747 U f
747 U f
748
748
749 prompt with EOF
749 prompt with EOF
750
750
751 $ beforemerge
751 $ beforemerge
752 [merge-tools]
752 [merge-tools]
753 false.whatever=
753 false.whatever=
754 true.priority=1
754 true.priority=1
755 true.executable=cat
755 true.executable=cat
756 # hg update -C 1
756 # hg update -C 1
757 $ hg merge -r 2 --config ui.merge=internal:prompt --config ui.interactive=true
757 $ hg merge -r 2 --config ui.merge=internal:prompt --config ui.interactive=true
758 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f?
758 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f?
759 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
759 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
760 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
760 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
761 [1]
761 [1]
762 $ aftermerge
762 $ aftermerge
763 # cat f
763 # cat f
764 revision 1
764 revision 1
765 space
765 space
766 # hg stat
766 # hg stat
767 M f
767 M f
768 # hg resolve --list
768 # hg resolve --list
769 U f
769 U f
770 $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
770 $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
771 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f?
771 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f?
772 [1]
772 [1]
773 $ aftermerge
773 $ aftermerge
774 # cat f
774 # cat f
775 revision 1
775 revision 1
776 space
776 space
777 # hg stat
777 # hg stat
778 M f
778 M f
779 ? f.orig
779 ? f.orig
780 # hg resolve --list
780 # hg resolve --list
781 U f
781 U f
782 $ rm f
782 $ rm f
783 $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
783 $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
784 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f?
784 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f?
785 [1]
785 [1]
786 $ aftermerge
786 $ aftermerge
787 # cat f
787 # cat f
788 revision 1
788 revision 1
789 space
789 space
790 # hg stat
790 # hg stat
791 M f
791 M f
792 # hg resolve --list
792 # hg resolve --list
793 U f
793 U f
794 $ hg resolve --all --config ui.merge=internal:prompt
794 $ hg resolve --all --config ui.merge=internal:prompt
795 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f? u
795 keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for f? u
796 [1]
796 [1]
797 $ aftermerge
797 $ aftermerge
798 # cat f
798 # cat f
799 revision 1
799 revision 1
800 space
800 space
801 # hg stat
801 # hg stat
802 M f
802 M f
803 ? f.orig
803 ? f.orig
804 # hg resolve --list
804 # hg resolve --list
805 U f
805 U f
806
806
807 ui.merge specifies internal:dump:
807 ui.merge specifies internal:dump:
808
808
809 $ beforemerge
809 $ beforemerge
810 [merge-tools]
810 [merge-tools]
811 false.whatever=
811 false.whatever=
812 true.priority=1
812 true.priority=1
813 true.executable=cat
813 true.executable=cat
814 # hg update -C 1
814 # hg update -C 1
815 $ hg merge -r 2 --config ui.merge=internal:dump
815 $ hg merge -r 2 --config ui.merge=internal:dump
816 merging f
816 merging f
817 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
817 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
818 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
818 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
819 [1]
819 [1]
820 $ aftermerge
820 $ aftermerge
821 # cat f
821 # cat f
822 revision 1
822 revision 1
823 space
823 space
824 # hg stat
824 # hg stat
825 M f
825 M f
826 ? f.base
826 ? f.base
827 ? f.local
827 ? f.local
828 ? f.orig
828 ? f.orig
829 ? f.other
829 ? f.other
830 # hg resolve --list
830 # hg resolve --list
831 U f
831 U f
832
832
833 f.base:
833 f.base:
834
834
835 $ cat f.base
835 $ cat f.base
836 revision 0
836 revision 0
837 space
837 space
838
838
839 f.local:
839 f.local:
840
840
841 $ cat f.local
841 $ cat f.local
842 revision 1
842 revision 1
843 space
843 space
844
844
845 f.other:
845 f.other:
846
846
847 $ cat f.other
847 $ cat f.other
848 revision 2
848 revision 2
849 space
849 space
850 $ rm f.base f.local f.other
850 $ rm f.base f.local f.other
851
851
852 check that internal:dump doesn't dump files if premerge runs
852 check that internal:dump doesn't dump files if premerge runs
853 successfully
853 successfully
854
854
855 $ beforemerge
855 $ beforemerge
856 [merge-tools]
856 [merge-tools]
857 false.whatever=
857 false.whatever=
858 true.priority=1
858 true.priority=1
859 true.executable=cat
859 true.executable=cat
860 # hg update -C 1
860 # hg update -C 1
861 $ hg merge -r 3 --config ui.merge=internal:dump
861 $ hg merge -r 3 --config ui.merge=internal:dump
862 merging f
862 merging f
863 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
863 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
864 (branch merge, don't forget to commit)
864 (branch merge, don't forget to commit)
865
865
866 $ aftermerge
866 $ aftermerge
867 # cat f
867 # cat f
868 revision 1
868 revision 1
869 space
869 space
870 revision 3
870 revision 3
871 # hg stat
871 # hg stat
872 M f
872 M f
873 # hg resolve --list
873 # hg resolve --list
874 R f
874 R f
875
875
876 check that internal:forcedump dumps files, even if local and other can
876 check that internal:forcedump dumps files, even if local and other can
877 be merged easily
877 be merged easily
878
878
879 $ beforemerge
879 $ beforemerge
880 [merge-tools]
880 [merge-tools]
881 false.whatever=
881 false.whatever=
882 true.priority=1
882 true.priority=1
883 true.executable=cat
883 true.executable=cat
884 # hg update -C 1
884 # hg update -C 1
885 $ hg merge -r 3 --config ui.merge=internal:forcedump
885 $ hg merge -r 3 --config ui.merge=internal:forcedump
886 merging f
886 merging f
887 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
887 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
888 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
888 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
889 [1]
889 [1]
890 $ aftermerge
890 $ aftermerge
891 # cat f
891 # cat f
892 revision 1
892 revision 1
893 space
893 space
894 # hg stat
894 # hg stat
895 M f
895 M f
896 ? f.base
896 ? f.base
897 ? f.local
897 ? f.local
898 ? f.orig
898 ? f.orig
899 ? f.other
899 ? f.other
900 # hg resolve --list
900 # hg resolve --list
901 U f
901 U f
902
902
903 $ cat f.base
903 $ cat f.base
904 revision 0
904 revision 0
905 space
905 space
906
906
907 $ cat f.local
907 $ cat f.local
908 revision 1
908 revision 1
909 space
909 space
910
910
911 $ cat f.other
911 $ cat f.other
912 revision 0
912 revision 0
913 space
913 space
914 revision 3
914 revision 3
915
915
916 $ rm -f f.base f.local f.other
916 $ rm -f f.base f.local f.other
917
917
918 ui.merge specifies internal:other but is overruled by pattern for false:
918 ui.merge specifies internal:other but is overruled by pattern for false:
919
919
920 $ beforemerge
920 $ beforemerge
921 [merge-tools]
921 [merge-tools]
922 false.whatever=
922 false.whatever=
923 true.priority=1
923 true.priority=1
924 true.executable=cat
924 true.executable=cat
925 # hg update -C 1
925 # hg update -C 1
926 $ hg merge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false
926 $ hg merge -r 2 --config ui.merge=internal:other --config merge-patterns.f=false
927 merging f
927 merging f
928 merging f failed!
928 merging f failed!
929 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
929 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
930 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
930 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
931 [1]
931 [1]
932 $ aftermerge
932 $ aftermerge
933 # cat f
933 # cat f
934 revision 1
934 revision 1
935 space
935 space
936 # hg stat
936 # hg stat
937 M f
937 M f
938 ? f.orig
938 ? f.orig
939 # hg resolve --list
939 # hg resolve --list
940 U f
940 U f
941
941
942 Premerge
942 Premerge
943
943
944 ui.merge specifies internal:other but is overruled by --tool=false
944 ui.merge specifies internal:other but is overruled by --tool=false
945
945
946 $ beforemerge
946 $ beforemerge
947 [merge-tools]
947 [merge-tools]
948 false.whatever=
948 false.whatever=
949 true.priority=1
949 true.priority=1
950 true.executable=cat
950 true.executable=cat
951 # hg update -C 1
951 # hg update -C 1
952 $ hg merge -r 2 --config ui.merge=internal:other --tool=false
952 $ hg merge -r 2 --config ui.merge=internal:other --tool=false
953 merging f
953 merging f
954 merging f failed!
954 merging f failed!
955 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
955 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
956 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
956 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
957 [1]
957 [1]
958 $ aftermerge
958 $ aftermerge
959 # cat f
959 # cat f
960 revision 1
960 revision 1
961 space
961 space
962 # hg stat
962 # hg stat
963 M f
963 M f
964 ? f.orig
964 ? f.orig
965 # hg resolve --list
965 # hg resolve --list
966 U f
966 U f
967
967
968 HGMERGE specifies internal:other but is overruled by --tool=false
968 HGMERGE specifies internal:other but is overruled by --tool=false
969
969
970 $ HGMERGE=internal:other ; export HGMERGE
970 $ HGMERGE=internal:other ; export HGMERGE
971 $ beforemerge
971 $ beforemerge
972 [merge-tools]
972 [merge-tools]
973 false.whatever=
973 false.whatever=
974 true.priority=1
974 true.priority=1
975 true.executable=cat
975 true.executable=cat
976 # hg update -C 1
976 # hg update -C 1
977 $ hg merge -r 2 --tool=false
977 $ hg merge -r 2 --tool=false
978 merging f
978 merging f
979 merging f failed!
979 merging f failed!
980 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
980 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
981 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
981 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
982 [1]
982 [1]
983 $ aftermerge
983 $ aftermerge
984 # cat f
984 # cat f
985 revision 1
985 revision 1
986 space
986 space
987 # hg stat
987 # hg stat
988 M f
988 M f
989 ? f.orig
989 ? f.orig
990 # hg resolve --list
990 # hg resolve --list
991 U f
991 U f
992
992
993 $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests
993 $ unset HGMERGE # make sure HGMERGE doesn't interfere with remaining tests
994
994
995 update is a merge ...
995 update is a merge ...
996
996
997 (this also tests that files reverted with '--rev REV' are treated as
997 (this also tests that files reverted with '--rev REV' are treated as
998 "modified", even if none of mode, size and timestamp of them isn't
998 "modified", even if none of mode, size and timestamp of them isn't
999 changed on the filesystem (see also issue4583))
999 changed on the filesystem (see also issue4583))
1000
1000
1001 $ cat >> $HGRCPATH <<EOF
1001 $ cat >> $HGRCPATH <<EOF
1002 > [fakedirstatewritetime]
1002 > [fakedirstatewritetime]
1003 > # emulate invoking dirstate.write() via repo.status()
1003 > # emulate invoking dirstate.write() via repo.status()
1004 > # at 2000-01-01 00:00
1004 > # at 2000-01-01 00:00
1005 > fakenow = 200001010000
1005 > fakenow = 200001010000
1006 > EOF
1006 > EOF
1007
1007
1008 $ beforemerge
1008 $ beforemerge
1009 [merge-tools]
1009 [merge-tools]
1010 false.whatever=
1010 false.whatever=
1011 true.priority=1
1011 true.priority=1
1012 true.executable=cat
1012 true.executable=cat
1013 # hg update -C 1
1013 # hg update -C 1
1014 $ hg update -q 0
1014 $ hg update -q 0
1015 $ f -s f
1015 $ f -s f
1016 f: size=17
1016 f: size=17
1017 $ touch -t 200001010000 f
1017 $ touch -t 200001010000 f
1018 $ hg debugrebuildstate
1018 $ hg debugrebuildstate
1019 $ cat >> $HGRCPATH <<EOF
1019 $ cat >> $HGRCPATH <<EOF
1020 > [extensions]
1020 > [extensions]
1021 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1021 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1022 > EOF
1022 > EOF
1023 $ hg revert -q -r 1 .
1023 $ hg revert -q -r 1 .
1024 $ cat >> $HGRCPATH <<EOF
1024 $ cat >> $HGRCPATH <<EOF
1025 > [extensions]
1025 > [extensions]
1026 > fakedirstatewritetime = !
1026 > fakedirstatewritetime = !
1027 > EOF
1027 > EOF
1028 $ f -s f
1028 $ f -s f
1029 f: size=17
1029 f: size=17
1030 $ touch -t 200001010000 f
1030 $ touch -t 200001010000 f
1031 $ hg status f
1031 $ hg status f
1032 M f
1032 M f
1033 $ hg update -r 2
1033 $ hg update -r 2
1034 merging f
1034 merging f
1035 revision 1
1035 revision 1
1036 space
1036 space
1037 revision 0
1037 revision 0
1038 space
1038 space
1039 revision 2
1039 revision 2
1040 space
1040 space
1041 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1041 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1042 $ aftermerge
1042 $ aftermerge
1043 # cat f
1043 # cat f
1044 revision 1
1044 revision 1
1045 space
1045 space
1046 # hg stat
1046 # hg stat
1047 M f
1047 M f
1048 # hg resolve --list
1048 # hg resolve --list
1049 R f
1049 R f
1050
1050
1051 update should also have --tool
1051 update should also have --tool
1052
1052
1053 $ beforemerge
1053 $ beforemerge
1054 [merge-tools]
1054 [merge-tools]
1055 false.whatever=
1055 false.whatever=
1056 true.priority=1
1056 true.priority=1
1057 true.executable=cat
1057 true.executable=cat
1058 # hg update -C 1
1058 # hg update -C 1
1059 $ hg update -q 0
1059 $ hg update -q 0
1060 $ f -s f
1060 $ f -s f
1061 f: size=17
1061 f: size=17
1062 $ touch -t 200001010000 f
1062 $ touch -t 200001010000 f
1063 $ hg debugrebuildstate
1063 $ hg debugrebuildstate
1064 $ cat >> $HGRCPATH <<EOF
1064 $ cat >> $HGRCPATH <<EOF
1065 > [extensions]
1065 > [extensions]
1066 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1066 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1067 > EOF
1067 > EOF
1068 $ hg revert -q -r 1 .
1068 $ hg revert -q -r 1 .
1069 $ cat >> $HGRCPATH <<EOF
1069 $ cat >> $HGRCPATH <<EOF
1070 > [extensions]
1070 > [extensions]
1071 > fakedirstatewritetime = !
1071 > fakedirstatewritetime = !
1072 > EOF
1072 > EOF
1073 $ f -s f
1073 $ f -s f
1074 f: size=17
1074 f: size=17
1075 $ touch -t 200001010000 f
1075 $ touch -t 200001010000 f
1076 $ hg status f
1076 $ hg status f
1077 M f
1077 M f
1078 $ hg update -r 2 --tool false
1078 $ hg update -r 2 --tool false
1079 merging f
1079 merging f
1080 merging f failed!
1080 merging f failed!
1081 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1081 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1082 use 'hg resolve' to retry unresolved file merges
1082 use 'hg resolve' to retry unresolved file merges
1083 [1]
1083 [1]
1084 $ aftermerge
1084 $ aftermerge
1085 # cat f
1085 # cat f
1086 revision 1
1086 revision 1
1087 space
1087 space
1088 # hg stat
1088 # hg stat
1089 M f
1089 M f
1090 ? f.orig
1090 ? f.orig
1091 # hg resolve --list
1091 # hg resolve --list
1092 U f
1092 U f
1093
1093
1094 Default is silent simplemerge:
1094 Default is silent simplemerge:
1095
1095
1096 $ beforemerge
1096 $ beforemerge
1097 [merge-tools]
1097 [merge-tools]
1098 false.whatever=
1098 false.whatever=
1099 true.priority=1
1099 true.priority=1
1100 true.executable=cat
1100 true.executable=cat
1101 # hg update -C 1
1101 # hg update -C 1
1102 $ hg merge -r 3
1102 $ hg merge -r 3
1103 merging f
1103 merging f
1104 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1104 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1105 (branch merge, don't forget to commit)
1105 (branch merge, don't forget to commit)
1106 $ aftermerge
1106 $ aftermerge
1107 # cat f
1107 # cat f
1108 revision 1
1108 revision 1
1109 space
1109 space
1110 revision 3
1110 revision 3
1111 # hg stat
1111 # hg stat
1112 M f
1112 M f
1113 # hg resolve --list
1113 # hg resolve --list
1114 R f
1114 R f
1115
1115
1116 .premerge=True is same:
1116 .premerge=True is same:
1117
1117
1118 $ beforemerge
1118 $ beforemerge
1119 [merge-tools]
1119 [merge-tools]
1120 false.whatever=
1120 false.whatever=
1121 true.priority=1
1121 true.priority=1
1122 true.executable=cat
1122 true.executable=cat
1123 # hg update -C 1
1123 # hg update -C 1
1124 $ hg merge -r 3 --config merge-tools.true.premerge=True
1124 $ hg merge -r 3 --config merge-tools.true.premerge=True
1125 merging f
1125 merging f
1126 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1126 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1127 (branch merge, don't forget to commit)
1127 (branch merge, don't forget to commit)
1128 $ aftermerge
1128 $ aftermerge
1129 # cat f
1129 # cat f
1130 revision 1
1130 revision 1
1131 space
1131 space
1132 revision 3
1132 revision 3
1133 # hg stat
1133 # hg stat
1134 M f
1134 M f
1135 # hg resolve --list
1135 # hg resolve --list
1136 R f
1136 R f
1137
1137
1138 .premerge=False executes merge-tool:
1138 .premerge=False executes merge-tool:
1139
1139
1140 $ beforemerge
1140 $ beforemerge
1141 [merge-tools]
1141 [merge-tools]
1142 false.whatever=
1142 false.whatever=
1143 true.priority=1
1143 true.priority=1
1144 true.executable=cat
1144 true.executable=cat
1145 # hg update -C 1
1145 # hg update -C 1
1146 $ hg merge -r 3 --config merge-tools.true.premerge=False
1146 $ hg merge -r 3 --config merge-tools.true.premerge=False
1147 merging f
1147 merging f
1148 revision 1
1148 revision 1
1149 space
1149 space
1150 revision 0
1150 revision 0
1151 space
1151 space
1152 revision 0
1152 revision 0
1153 space
1153 space
1154 revision 3
1154 revision 3
1155 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1155 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1156 (branch merge, don't forget to commit)
1156 (branch merge, don't forget to commit)
1157 $ aftermerge
1157 $ aftermerge
1158 # cat f
1158 # cat f
1159 revision 1
1159 revision 1
1160 space
1160 space
1161 # hg stat
1161 # hg stat
1162 M f
1162 M f
1163 # hg resolve --list
1163 # hg resolve --list
1164 R f
1164 R f
1165
1165
1166 premerge=keep keeps conflict markers in:
1166 premerge=keep keeps conflict markers in:
1167
1167
1168 $ beforemerge
1168 $ beforemerge
1169 [merge-tools]
1169 [merge-tools]
1170 false.whatever=
1170 false.whatever=
1171 true.priority=1
1171 true.priority=1
1172 true.executable=cat
1172 true.executable=cat
1173 # hg update -C 1
1173 # hg update -C 1
1174 $ hg merge -r 4 --config merge-tools.true.premerge=keep
1174 $ hg merge -r 4 --config merge-tools.true.premerge=keep
1175 merging f
1175 merging f
1176 <<<<<<< working copy: ef83787e2614 - test: revision 1
1176 <<<<<<< working copy: ef83787e2614 - test: revision 1
1177 revision 1
1177 revision 1
1178 space
1178 space
1179 =======
1179 =======
1180 revision 4
1180 revision 4
1181 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1181 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1182 revision 0
1182 revision 0
1183 space
1183 space
1184 revision 4
1184 revision 4
1185 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1185 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1186 (branch merge, don't forget to commit)
1186 (branch merge, don't forget to commit)
1187 $ aftermerge
1187 $ aftermerge
1188 # cat f
1188 # cat f
1189 <<<<<<< working copy: ef83787e2614 - test: revision 1
1189 <<<<<<< working copy: ef83787e2614 - test: revision 1
1190 revision 1
1190 revision 1
1191 space
1191 space
1192 =======
1192 =======
1193 revision 4
1193 revision 4
1194 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1194 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1195 # hg stat
1195 # hg stat
1196 M f
1196 M f
1197 # hg resolve --list
1197 # hg resolve --list
1198 R f
1198 R f
1199
1199
1200 premerge=keep-merge3 keeps conflict markers with base content:
1200 premerge=keep-merge3 keeps conflict markers with base content:
1201
1201
1202 $ beforemerge
1202 $ beforemerge
1203 [merge-tools]
1203 [merge-tools]
1204 false.whatever=
1204 false.whatever=
1205 true.priority=1
1205 true.priority=1
1206 true.executable=cat
1206 true.executable=cat
1207 # hg update -C 1
1207 # hg update -C 1
1208 $ hg merge -r 4 --config merge-tools.true.premerge=keep-merge3
1208 $ hg merge -r 4 --config merge-tools.true.premerge=keep-merge3
1209 merging f
1209 merging f
1210 <<<<<<< working copy: ef83787e2614 - test: revision 1
1210 <<<<<<< working copy: ef83787e2614 - test: revision 1
1211 revision 1
1211 revision 1
1212 space
1212 space
1213 ||||||| base
1213 ||||||| base
1214 revision 0
1214 revision 0
1215 space
1215 space
1216 =======
1216 =======
1217 revision 4
1217 revision 4
1218 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1218 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1219 revision 0
1219 revision 0
1220 space
1220 space
1221 revision 4
1221 revision 4
1222 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1222 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1223 (branch merge, don't forget to commit)
1223 (branch merge, don't forget to commit)
1224 $ aftermerge
1224 $ aftermerge
1225 # cat f
1225 # cat f
1226 <<<<<<< working copy: ef83787e2614 - test: revision 1
1226 <<<<<<< working copy: ef83787e2614 - test: revision 1
1227 revision 1
1227 revision 1
1228 space
1228 space
1229 ||||||| base
1229 ||||||| base
1230 revision 0
1230 revision 0
1231 space
1231 space
1232 =======
1232 =======
1233 revision 4
1233 revision 4
1234 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1234 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1235 # hg stat
1235 # hg stat
1236 M f
1236 M f
1237 # hg resolve --list
1237 # hg resolve --list
1238 R f
1238 R f
1239
1239
1240 premerge=keep respects ui.mergemarkers=basic:
1240 premerge=keep respects ui.mergemarkers=basic:
1241
1241
1242 $ beforemerge
1242 $ beforemerge
1243 [merge-tools]
1243 [merge-tools]
1244 false.whatever=
1244 false.whatever=
1245 true.priority=1
1245 true.priority=1
1246 true.executable=cat
1246 true.executable=cat
1247 # hg update -C 1
1247 # hg update -C 1
1248 $ hg merge -r 4 --config merge-tools.true.premerge=keep --config ui.mergemarkers=basic
1248 $ hg merge -r 4 --config merge-tools.true.premerge=keep --config ui.mergemarkers=basic
1249 merging f
1249 merging f
1250 <<<<<<< working copy
1250 <<<<<<< working copy
1251 revision 1
1251 revision 1
1252 space
1252 space
1253 =======
1253 =======
1254 revision 4
1254 revision 4
1255 >>>>>>> merge rev
1255 >>>>>>> merge rev
1256 revision 0
1256 revision 0
1257 space
1257 space
1258 revision 4
1258 revision 4
1259 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1259 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1260 (branch merge, don't forget to commit)
1260 (branch merge, don't forget to commit)
1261 $ aftermerge
1261 $ aftermerge
1262 # cat f
1262 # cat f
1263 <<<<<<< working copy
1263 <<<<<<< working copy
1264 revision 1
1264 revision 1
1265 space
1265 space
1266 =======
1266 =======
1267 revision 4
1267 revision 4
1268 >>>>>>> merge rev
1268 >>>>>>> merge rev
1269 # hg stat
1269 # hg stat
1270 M f
1270 M f
1271 # hg resolve --list
1271 # hg resolve --list
1272 R f
1272 R f
1273
1273
1274 premerge=keep ignores ui.mergemarkers=basic if true.mergemarkers=detailed:
1274 premerge=keep ignores ui.mergemarkers=basic if true.mergemarkers=detailed:
1275
1275
1276 $ beforemerge
1276 $ beforemerge
1277 [merge-tools]
1277 [merge-tools]
1278 false.whatever=
1278 false.whatever=
1279 true.priority=1
1279 true.priority=1
1280 true.executable=cat
1280 true.executable=cat
1281 # hg update -C 1
1281 # hg update -C 1
1282 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1282 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1283 > --config ui.mergemarkers=basic \
1283 > --config ui.mergemarkers=basic \
1284 > --config merge-tools.true.mergemarkers=detailed
1284 > --config merge-tools.true.mergemarkers=detailed
1285 merging f
1285 merging f
1286 <<<<<<< working copy: ef83787e2614 - test: revision 1
1286 <<<<<<< working copy: ef83787e2614 - test: revision 1
1287 revision 1
1287 revision 1
1288 space
1288 space
1289 =======
1289 =======
1290 revision 4
1290 revision 4
1291 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1291 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1292 revision 0
1292 revision 0
1293 space
1293 space
1294 revision 4
1294 revision 4
1295 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1295 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1296 (branch merge, don't forget to commit)
1296 (branch merge, don't forget to commit)
1297 $ aftermerge
1297 $ aftermerge
1298 # cat f
1298 # cat f
1299 <<<<<<< working copy: ef83787e2614 - test: revision 1
1299 <<<<<<< working copy: ef83787e2614 - test: revision 1
1300 revision 1
1300 revision 1
1301 space
1301 space
1302 =======
1302 =======
1303 revision 4
1303 revision 4
1304 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1304 >>>>>>> merge rev: 81448d39c9a0 - test: revision 4
1305 # hg stat
1305 # hg stat
1306 M f
1306 M f
1307 # hg resolve --list
1307 # hg resolve --list
1308 R f
1308 R f
1309
1309
1310 premerge=keep respects ui.mergemarkertemplate instead of
1310 premerge=keep respects ui.mergemarkertemplate instead of
1311 true.mergemarkertemplate if true.mergemarkers=basic:
1311 true.mergemarkertemplate if true.mergemarkers=basic:
1312
1312
1313 $ beforemerge
1313 $ beforemerge
1314 [merge-tools]
1314 [merge-tools]
1315 false.whatever=
1315 false.whatever=
1316 true.priority=1
1316 true.priority=1
1317 true.executable=cat
1317 true.executable=cat
1318 # hg update -C 1
1318 # hg update -C 1
1319 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1319 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1320 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1320 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1321 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}'
1321 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}'
1322 merging f
1322 merging f
1323 <<<<<<< working copy: uitmpl 1
1323 <<<<<<< working copy: uitmpl 1
1324 revision 1
1324 revision 1
1325 space
1325 space
1326 =======
1326 =======
1327 revision 4
1327 revision 4
1328 >>>>>>> merge rev: uitmpl 4
1328 >>>>>>> merge rev: uitmpl 4
1329 revision 0
1329 revision 0
1330 space
1330 space
1331 revision 4
1331 revision 4
1332 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1332 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1333 (branch merge, don't forget to commit)
1333 (branch merge, don't forget to commit)
1334 $ aftermerge
1334 $ aftermerge
1335 # cat f
1335 # cat f
1336 <<<<<<< working copy: uitmpl 1
1336 <<<<<<< working copy: uitmpl 1
1337 revision 1
1337 revision 1
1338 space
1338 space
1339 =======
1339 =======
1340 revision 4
1340 revision 4
1341 >>>>>>> merge rev: uitmpl 4
1341 >>>>>>> merge rev: uitmpl 4
1342 # hg stat
1342 # hg stat
1343 M f
1343 M f
1344 # hg resolve --list
1344 # hg resolve --list
1345 R f
1345 R f
1346
1346
1347 premerge=keep respects true.mergemarkertemplate instead of
1347 premerge=keep respects true.mergemarkertemplate instead of
1348 true.mergemarkertemplate if true.mergemarkers=detailed:
1348 true.mergemarkertemplate if true.mergemarkers=detailed:
1349
1349
1350 $ beforemerge
1350 $ beforemerge
1351 [merge-tools]
1351 [merge-tools]
1352 false.whatever=
1352 false.whatever=
1353 true.priority=1
1353 true.priority=1
1354 true.executable=cat
1354 true.executable=cat
1355 # hg update -C 1
1355 # hg update -C 1
1356 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1356 $ hg merge -r 4 --config merge-tools.true.premerge=keep \
1357 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1357 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1358 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1358 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1359 > --config merge-tools.true.mergemarkers=detailed
1359 > --config merge-tools.true.mergemarkers=detailed
1360 merging f
1360 merging f
1361 <<<<<<< working copy: tooltmpl ef83787e2614
1361 <<<<<<< working copy: tooltmpl ef83787e2614
1362 revision 1
1362 revision 1
1363 space
1363 space
1364 =======
1364 =======
1365 revision 4
1365 revision 4
1366 >>>>>>> merge rev: tooltmpl 81448d39c9a0
1366 >>>>>>> merge rev: tooltmpl 81448d39c9a0
1367 revision 0
1367 revision 0
1368 space
1368 space
1369 revision 4
1369 revision 4
1370 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1370 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1371 (branch merge, don't forget to commit)
1371 (branch merge, don't forget to commit)
1372 $ aftermerge
1372 $ aftermerge
1373 # cat f
1373 # cat f
1374 <<<<<<< working copy: tooltmpl ef83787e2614
1374 <<<<<<< working copy: tooltmpl ef83787e2614
1375 revision 1
1375 revision 1
1376 space
1376 space
1377 =======
1377 =======
1378 revision 4
1378 revision 4
1379 >>>>>>> merge rev: tooltmpl 81448d39c9a0
1379 >>>>>>> merge rev: tooltmpl 81448d39c9a0
1380 # hg stat
1380 # hg stat
1381 M f
1381 M f
1382 # hg resolve --list
1382 # hg resolve --list
1383 R f
1383 R f
1384
1384
1385 Tool execution
1385 Tool execution
1386
1386
1387 set tools.args explicit to include $base $local $other $output:
1387 set tools.args explicit to include $base $local $other $output:
1388
1388
1389 $ beforemerge
1389 $ beforemerge
1390 [merge-tools]
1390 [merge-tools]
1391 false.whatever=
1391 false.whatever=
1392 true.priority=1
1392 true.priority=1
1393 true.executable=cat
1393 true.executable=cat
1394 # hg update -C 1
1394 # hg update -C 1
1395 $ hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \
1395 $ hg merge -r 2 --config merge-tools.true.executable=head --config merge-tools.true.args='$base $local $other $output' \
1396 > | sed 's,==> .* <==,==> ... <==,g'
1396 > | sed 's,==> .* <==,==> ... <==,g'
1397 merging f
1397 merging f
1398 ==> ... <==
1398 ==> ... <==
1399 revision 0
1399 revision 0
1400 space
1400 space
1401
1401
1402 ==> ... <==
1402 ==> ... <==
1403 revision 1
1403 revision 1
1404 space
1404 space
1405
1405
1406 ==> ... <==
1406 ==> ... <==
1407 revision 2
1407 revision 2
1408 space
1408 space
1409
1409
1410 ==> ... <==
1410 ==> ... <==
1411 revision 1
1411 revision 1
1412 space
1412 space
1413 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1413 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1414 (branch merge, don't forget to commit)
1414 (branch merge, don't forget to commit)
1415 $ aftermerge
1415 $ aftermerge
1416 # cat f
1416 # cat f
1417 revision 1
1417 revision 1
1418 space
1418 space
1419 # hg stat
1419 # hg stat
1420 M f
1420 M f
1421 # hg resolve --list
1421 # hg resolve --list
1422 R f
1422 R f
1423
1423
1424 Merge with "echo mergeresult > $local":
1424 Merge with "echo mergeresult > $local":
1425
1425
1426 $ beforemerge
1426 $ beforemerge
1427 [merge-tools]
1427 [merge-tools]
1428 false.whatever=
1428 false.whatever=
1429 true.priority=1
1429 true.priority=1
1430 true.executable=cat
1430 true.executable=cat
1431 # hg update -C 1
1431 # hg update -C 1
1432 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local'
1432 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $local'
1433 merging f
1433 merging f
1434 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1434 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1435 (branch merge, don't forget to commit)
1435 (branch merge, don't forget to commit)
1436 $ aftermerge
1436 $ aftermerge
1437 # cat f
1437 # cat f
1438 mergeresult
1438 mergeresult
1439 # hg stat
1439 # hg stat
1440 M f
1440 M f
1441 # hg resolve --list
1441 # hg resolve --list
1442 R f
1442 R f
1443
1443
1444 - and $local is the file f:
1444 - and $local is the file f:
1445
1445
1446 $ beforemerge
1446 $ beforemerge
1447 [merge-tools]
1447 [merge-tools]
1448 false.whatever=
1448 false.whatever=
1449 true.priority=1
1449 true.priority=1
1450 true.executable=cat
1450 true.executable=cat
1451 # hg update -C 1
1451 # hg update -C 1
1452 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f'
1452 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > f'
1453 merging f
1453 merging f
1454 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1454 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1455 (branch merge, don't forget to commit)
1455 (branch merge, don't forget to commit)
1456 $ aftermerge
1456 $ aftermerge
1457 # cat f
1457 # cat f
1458 mergeresult
1458 mergeresult
1459 # hg stat
1459 # hg stat
1460 M f
1460 M f
1461 # hg resolve --list
1461 # hg resolve --list
1462 R f
1462 R f
1463
1463
1464 Merge with "echo mergeresult > $output" - the variable is a bit magic:
1464 Merge with "echo mergeresult > $output" - the variable is a bit magic:
1465
1465
1466 $ beforemerge
1466 $ beforemerge
1467 [merge-tools]
1467 [merge-tools]
1468 false.whatever=
1468 false.whatever=
1469 true.priority=1
1469 true.priority=1
1470 true.executable=cat
1470 true.executable=cat
1471 # hg update -C 1
1471 # hg update -C 1
1472 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output'
1472 $ hg merge -r 2 --config merge-tools.true.executable=echo --config merge-tools.true.args='mergeresult > $output'
1473 merging f
1473 merging f
1474 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1474 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1475 (branch merge, don't forget to commit)
1475 (branch merge, don't forget to commit)
1476 $ aftermerge
1476 $ aftermerge
1477 # cat f
1477 # cat f
1478 mergeresult
1478 mergeresult
1479 # hg stat
1479 # hg stat
1480 M f
1480 M f
1481 # hg resolve --list
1481 # hg resolve --list
1482 R f
1482 R f
1483
1483
1484 Merge using tool with a path that must be quoted:
1484 Merge using tool with a path that must be quoted:
1485
1485
1486 $ beforemerge
1486 $ beforemerge
1487 [merge-tools]
1487 [merge-tools]
1488 false.whatever=
1488 false.whatever=
1489 true.priority=1
1489 true.priority=1
1490 true.executable=cat
1490 true.executable=cat
1491 # hg update -C 1
1491 # hg update -C 1
1492 $ cat <<EOF > 'my merge tool'
1492 $ cat <<EOF > 'my merge tool'
1493 > cat "\$1" "\$2" "\$3" > "\$4"
1493 > cat "\$1" "\$2" "\$3" > "\$4"
1494 > EOF
1494 > EOF
1495 $ hg --config merge-tools.true.executable='sh' \
1495 $ hg --config merge-tools.true.executable='sh' \
1496 > --config merge-tools.true.args='"./my merge tool" $base $local $other $output' \
1496 > --config merge-tools.true.args='"./my merge tool" $base $local $other $output' \
1497 > merge -r 2
1497 > merge -r 2
1498 merging f
1498 merging f
1499 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1499 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1500 (branch merge, don't forget to commit)
1500 (branch merge, don't forget to commit)
1501 $ rm -f 'my merge tool'
1501 $ rm -f 'my merge tool'
1502 $ aftermerge
1502 $ aftermerge
1503 # cat f
1503 # cat f
1504 revision 0
1504 revision 0
1505 space
1505 space
1506 revision 1
1506 revision 1
1507 space
1507 space
1508 revision 2
1508 revision 2
1509 space
1509 space
1510 # hg stat
1510 # hg stat
1511 M f
1511 M f
1512 # hg resolve --list
1512 # hg resolve --list
1513 R f
1513 R f
1514
1514
1515 Merge using a tool that supports labellocal, labelother, and labelbase, checking
1515 Merge using a tool that supports labellocal, labelother, and labelbase, checking
1516 that they're quoted properly as well. This is using the default 'basic'
1516 that they're quoted properly as well. This is using the default 'basic'
1517 mergemarkers even though ui.mergemarkers is 'detailed', so it's ignoring both
1517 mergemarkers even though ui.mergemarkers is 'detailed', so it's ignoring both
1518 mergemarkertemplate settings:
1518 mergemarkertemplate settings:
1519
1519
1520 $ beforemerge
1520 $ beforemerge
1521 [merge-tools]
1521 [merge-tools]
1522 false.whatever=
1522 false.whatever=
1523 true.priority=1
1523 true.priority=1
1524 true.executable=cat
1524 true.executable=cat
1525 # hg update -C 1
1525 # hg update -C 1
1526 $ cat <<EOF > printargs_merge_tool
1526 $ cat <<EOF > printargs_merge_tool
1527 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1527 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1528 > EOF
1528 > EOF
1529 $ hg --config merge-tools.true.executable='sh' \
1529 $ hg --config merge-tools.true.executable='sh' \
1530 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1530 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1531 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1531 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1532 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1532 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1533 > --config ui.mergemarkers=detailed \
1533 > --config ui.mergemarkers=detailed \
1534 > merge -r 2
1534 > merge -r 2
1535 merging f
1535 merging f
1536 arg: "ll:working copy"
1536 arg: "ll:working copy"
1537 arg: "lo:"
1537 arg: "lo:"
1538 arg: "merge rev"
1538 arg: "merge rev"
1539 arg: "lb:base: */f~base.*" (glob)
1539 arg: "lb:base: */f~base.*" (glob)
1540 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1540 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1541 (branch merge, don't forget to commit)
1541 (branch merge, don't forget to commit)
1542 $ rm -f 'printargs_merge_tool'
1542 $ rm -f 'printargs_merge_tool'
1543
1543
1544 Same test with experimental.mergetempdirprefix set:
1544 Same test with experimental.mergetempdirprefix set:
1545
1545
1546 $ beforemerge
1546 $ beforemerge
1547 [merge-tools]
1547 [merge-tools]
1548 false.whatever=
1548 false.whatever=
1549 true.priority=1
1549 true.priority=1
1550 true.executable=cat
1550 true.executable=cat
1551 # hg update -C 1
1551 # hg update -C 1
1552 $ cat <<EOF > printargs_merge_tool
1552 $ cat <<EOF > printargs_merge_tool
1553 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1553 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1554 > EOF
1554 > EOF
1555 $ hg --config experimental.mergetempdirprefix=$TESTTMP/hgmerge. \
1555 $ hg --config experimental.mergetempdirprefix=$TESTTMP/hgmerge. \
1556 > --config merge-tools.true.executable='sh' \
1556 > --config merge-tools.true.executable='sh' \
1557 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1557 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1558 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1558 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1559 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1559 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1560 > --config ui.mergemarkers=detailed \
1560 > --config ui.mergemarkers=detailed \
1561 > merge -r 2
1561 > merge -r 2
1562 merging f
1562 merging f
1563 arg: "ll:working copy"
1563 arg: "ll:working copy"
1564 arg: "lo:"
1564 arg: "lo:"
1565 arg: "merge rev"
1565 arg: "merge rev"
1566 arg: "lb:base: */hgmerge.*/f~base" (glob)
1566 arg: "lb:base: */hgmerge.*/f~base" (glob)
1567 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1567 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1568 (branch merge, don't forget to commit)
1568 (branch merge, don't forget to commit)
1569 $ rm -f 'printargs_merge_tool'
1569 $ rm -f 'printargs_merge_tool'
1570
1570
1571 Merge using a tool that supports labellocal, labelother, and labelbase, checking
1571 Merge using a tool that supports labellocal, labelother, and labelbase, checking
1572 that they're quoted properly as well. This is using 'detailed' mergemarkers,
1572 that they're quoted properly as well. This is using 'detailed' mergemarkers,
1573 even though ui.mergemarkers is 'basic', and using the tool's
1573 even though ui.mergemarkers is 'basic', and using the tool's
1574 mergemarkertemplate:
1574 mergemarkertemplate:
1575
1575
1576 $ beforemerge
1576 $ beforemerge
1577 [merge-tools]
1577 [merge-tools]
1578 false.whatever=
1578 false.whatever=
1579 true.priority=1
1579 true.priority=1
1580 true.executable=cat
1580 true.executable=cat
1581 # hg update -C 1
1581 # hg update -C 1
1582 $ cat <<EOF > printargs_merge_tool
1582 $ cat <<EOF > printargs_merge_tool
1583 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1583 > while test \$# -gt 0; do echo arg: \"\$1\"; shift; done
1584 > EOF
1584 > EOF
1585 $ hg --config merge-tools.true.executable='sh' \
1585 $ hg --config merge-tools.true.executable='sh' \
1586 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1586 > --config merge-tools.true.args='./printargs_merge_tool ll:$labellocal lo: $labelother lb:$labelbase": "$base' \
1587 > --config merge-tools.true.mergemarkers=detailed \
1587 > --config merge-tools.true.mergemarkers=detailed \
1588 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1588 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1589 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1589 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1590 > --config ui.mergemarkers=basic \
1590 > --config ui.mergemarkers=basic \
1591 > merge -r 2
1591 > merge -r 2
1592 merging f
1592 merging f
1593 arg: "ll:working copy: tooltmpl ef83787e2614"
1593 arg: "ll:working copy: tooltmpl ef83787e2614"
1594 arg: "lo:"
1594 arg: "lo:"
1595 arg: "merge rev: tooltmpl 0185f4e0cf02"
1595 arg: "merge rev: tooltmpl 0185f4e0cf02"
1596 arg: "lb:base: */f~base.*" (glob)
1596 arg: "lb:base: */f~base.*" (glob)
1597 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1597 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1598 (branch merge, don't forget to commit)
1598 (branch merge, don't forget to commit)
1599 $ rm -f 'printargs_merge_tool'
1599 $ rm -f 'printargs_merge_tool'
1600
1600
1601 The merge tool still gets labellocal and labelother as 'basic' even when
1601 The merge tool still gets labellocal and labelother as 'basic' even when
1602 premerge=keep is used and has 'detailed' markers:
1602 premerge=keep is used and has 'detailed' markers:
1603
1603
1604 $ beforemerge
1604 $ beforemerge
1605 [merge-tools]
1605 [merge-tools]
1606 false.whatever=
1606 false.whatever=
1607 true.priority=1
1607 true.priority=1
1608 true.executable=cat
1608 true.executable=cat
1609 # hg update -C 1
1609 # hg update -C 1
1610 $ cat <<EOF > mytool
1610 $ cat <<EOF > mytool
1611 > echo labellocal: \"\$1\"
1611 > echo labellocal: \"\$1\"
1612 > echo labelother: \"\$2\"
1612 > echo labelother: \"\$2\"
1613 > echo "output (arg)": \"\$3\"
1613 > echo "output (arg)": \"\$3\"
1614 > echo "output (contents)":
1614 > echo "output (contents)":
1615 > cat "\$3"
1615 > cat "\$3"
1616 > EOF
1616 > EOF
1617 $ hg --config merge-tools.true.executable='sh' \
1617 $ hg --config merge-tools.true.executable='sh' \
1618 > --config merge-tools.true.args='mytool $labellocal $labelother $output' \
1618 > --config merge-tools.true.args='mytool $labellocal $labelother $output' \
1619 > --config merge-tools.true.premerge=keep \
1619 > --config merge-tools.true.premerge=keep \
1620 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1620 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1621 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1621 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1622 > --config ui.mergemarkers=detailed \
1622 > --config ui.mergemarkers=detailed \
1623 > merge -r 2
1623 > merge -r 2
1624 merging f
1624 merging f
1625 labellocal: "working copy"
1625 labellocal: "working copy"
1626 labelother: "merge rev"
1626 labelother: "merge rev"
1627 output (arg): "$TESTTMP/repo/f"
1627 output (arg): "$TESTTMP/repo/f"
1628 output (contents):
1628 output (contents):
1629 <<<<<<< working copy: uitmpl 1
1629 <<<<<<< working copy: uitmpl 1
1630 revision 1
1630 revision 1
1631 =======
1631 =======
1632 revision 2
1632 revision 2
1633 >>>>>>> merge rev: uitmpl 2
1633 >>>>>>> merge rev: uitmpl 2
1634 space
1634 space
1635 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1635 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1636 (branch merge, don't forget to commit)
1636 (branch merge, don't forget to commit)
1637 $ rm -f 'mytool'
1637 $ rm -f 'mytool'
1638
1638
1639 premerge=keep uses the *tool's* mergemarkertemplate if tool's
1639 premerge=keep uses the *tool's* mergemarkertemplate if tool's
1640 mergemarkers=detailed; labellocal and labelother also use the tool's template
1640 mergemarkers=detailed; labellocal and labelother also use the tool's template
1641
1641
1642 $ beforemerge
1642 $ beforemerge
1643 [merge-tools]
1643 [merge-tools]
1644 false.whatever=
1644 false.whatever=
1645 true.priority=1
1645 true.priority=1
1646 true.executable=cat
1646 true.executable=cat
1647 # hg update -C 1
1647 # hg update -C 1
1648 $ cat <<EOF > mytool
1648 $ cat <<EOF > mytool
1649 > echo labellocal: \"\$1\"
1649 > echo labellocal: \"\$1\"
1650 > echo labelother: \"\$2\"
1650 > echo labelother: \"\$2\"
1651 > echo "output (arg)": \"\$3\"
1651 > echo "output (arg)": \"\$3\"
1652 > echo "output (contents)":
1652 > echo "output (contents)":
1653 > cat "\$3"
1653 > cat "\$3"
1654 > EOF
1654 > EOF
1655 $ hg --config merge-tools.true.executable='sh' \
1655 $ hg --config merge-tools.true.executable='sh' \
1656 > --config merge-tools.true.args='mytool $labellocal $labelother $output' \
1656 > --config merge-tools.true.args='mytool $labellocal $labelother $output' \
1657 > --config merge-tools.true.premerge=keep \
1657 > --config merge-tools.true.premerge=keep \
1658 > --config merge-tools.true.mergemarkers=detailed \
1658 > --config merge-tools.true.mergemarkers=detailed \
1659 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1659 > --config merge-tools.true.mergemarkertemplate='tooltmpl {short(node)}' \
1660 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1660 > --config ui.mergemarkertemplate='uitmpl {rev}' \
1661 > --config ui.mergemarkers=detailed \
1661 > --config ui.mergemarkers=detailed \
1662 > merge -r 2
1662 > merge -r 2
1663 merging f
1663 merging f
1664 labellocal: "working copy: tooltmpl ef83787e2614"
1664 labellocal: "working copy: tooltmpl ef83787e2614"
1665 labelother: "merge rev: tooltmpl 0185f4e0cf02"
1665 labelother: "merge rev: tooltmpl 0185f4e0cf02"
1666 output (arg): "$TESTTMP/repo/f"
1666 output (arg): "$TESTTMP/repo/f"
1667 output (contents):
1667 output (contents):
1668 <<<<<<< working copy: tooltmpl ef83787e2614
1668 <<<<<<< working copy: tooltmpl ef83787e2614
1669 revision 1
1669 revision 1
1670 =======
1670 =======
1671 revision 2
1671 revision 2
1672 >>>>>>> merge rev: tooltmpl 0185f4e0cf02
1672 >>>>>>> merge rev: tooltmpl 0185f4e0cf02
1673 space
1673 space
1674 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1674 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1675 (branch merge, don't forget to commit)
1675 (branch merge, don't forget to commit)
1676 $ rm -f 'mytool'
1676 $ rm -f 'mytool'
1677
1677
1678 Issue3581: Merging a filename that needs to be quoted
1678 Issue3581: Merging a filename that needs to be quoted
1679 (This test doesn't work on Windows filesystems even on Linux, so check
1679 (This test doesn't work on Windows filesystems even on Linux, so check
1680 for Unix-like permission)
1680 for Unix-like permission)
1681
1681
1682 #if unix-permissions
1682 #if unix-permissions
1683 $ beforemerge
1683 $ beforemerge
1684 [merge-tools]
1684 [merge-tools]
1685 false.whatever=
1685 false.whatever=
1686 true.priority=1
1686 true.priority=1
1687 true.executable=cat
1687 true.executable=cat
1688 # hg update -C 1
1688 # hg update -C 1
1689 $ echo "revision 5" > '"; exit 1; echo "'
1689 $ echo "revision 5" > '"; exit 1; echo "'
1690 $ hg commit -Am "revision 5"
1690 $ hg commit -Am "revision 5"
1691 adding "; exit 1; echo "
1691 adding "; exit 1; echo "
1692 warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "'
1692 warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "'
1693 $ hg update -C 1 > /dev/null
1693 $ hg update -C 1 > /dev/null
1694 $ echo "revision 6" > '"; exit 1; echo "'
1694 $ echo "revision 6" > '"; exit 1; echo "'
1695 $ hg commit -Am "revision 6"
1695 $ hg commit -Am "revision 6"
1696 adding "; exit 1; echo "
1696 adding "; exit 1; echo "
1697 warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "'
1697 warning: filename contains '"', which is reserved on Windows: '"; exit 1; echo "'
1698 created new head
1698 created new head
1699 $ hg merge --config merge-tools.true.executable="true" -r 5
1699 $ hg merge --config merge-tools.true.executable="true" -r 5
1700 merging "; exit 1; echo "
1700 merging "; exit 1; echo "
1701 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1701 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1702 (branch merge, don't forget to commit)
1702 (branch merge, don't forget to commit)
1703 $ hg update -C 1 > /dev/null
1703 $ hg update -C 1 > /dev/null
1704 #endif
1704 #endif
1705
1705
1706 Merge post-processing
1706 Merge post-processing
1707
1707
1708 cat is a bad merge-tool and doesn't change:
1708 cat is a bad merge-tool and doesn't change:
1709
1709
1710 $ beforemerge
1710 $ beforemerge
1711 [merge-tools]
1711 [merge-tools]
1712 false.whatever=
1712 false.whatever=
1713 true.priority=1
1713 true.priority=1
1714 true.executable=cat
1714 true.executable=cat
1715 # hg update -C 1
1715 # hg update -C 1
1716 $ hg merge -y -r 2 --config merge-tools.true.checkchanged=1
1716 $ hg merge -y -r 2 --config merge-tools.true.checkchanged=1
1717 merging f
1717 merging f
1718 revision 1
1718 revision 1
1719 space
1719 space
1720 revision 0
1720 revision 0
1721 space
1721 space
1722 revision 2
1722 revision 2
1723 space
1723 space
1724 output file f appears unchanged
1724 output file f appears unchanged
1725 was merge successful (yn)? n
1725 was merge successful (yn)? n
1726 merging f failed!
1726 merging f failed!
1727 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1727 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1728 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1728 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1729 [1]
1729 [1]
1730 $ aftermerge
1730 $ aftermerge
1731 # cat f
1731 # cat f
1732 revision 1
1732 revision 1
1733 space
1733 space
1734 # hg stat
1734 # hg stat
1735 M f
1735 M f
1736 ? f.orig
1736 ? f.orig
1737 # hg resolve --list
1737 # hg resolve --list
1738 U f
1738 U f
1739
1739
1740 missingbinary is a merge-tool that doesn't exist:
1740 missingbinary is a merge-tool that doesn't exist:
1741
1741
1742 $ echo "missingbinary.executable=doesnotexist" >> .hg/hgrc
1742 $ echo "missingbinary.executable=doesnotexist" >> .hg/hgrc
1743 $ beforemerge
1743 $ beforemerge
1744 [merge-tools]
1744 [merge-tools]
1745 false.whatever=
1745 false.whatever=
1746 true.priority=1
1746 true.priority=1
1747 true.executable=cat
1747 true.executable=cat
1748 missingbinary.executable=doesnotexist
1748 missingbinary.executable=doesnotexist
1749 # hg update -C 1
1749 # hg update -C 1
1750 $ hg merge -y -r 2 --config ui.merge=missingbinary
1750 $ hg merge -y -r 2 --config ui.merge=missingbinary
1751 couldn't find merge tool missingbinary (for pattern f)
1751 merging f
1752 merging f
1753 couldn't find merge tool missingbinary (for pattern f)
1752 revision 1
1754 revision 1
1753 space
1755 space
1754 revision 0
1756 revision 0
1755 space
1757 space
1756 revision 2
1758 revision 2
1757 space
1759 space
1758 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1760 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1759 (branch merge, don't forget to commit)
1761 (branch merge, don't forget to commit)
1760
1762
1761 #if symlink
1763 #if symlink
1762
1764
1763 internal merge cannot handle symlinks and shouldn't try:
1765 internal merge cannot handle symlinks and shouldn't try:
1764
1766
1765 $ hg update -q -C 1
1767 $ hg update -q -C 1
1766 $ rm f
1768 $ rm f
1767 $ ln -s symlink f
1769 $ ln -s symlink f
1768 $ hg commit -qm 'f is symlink'
1770 $ hg commit -qm 'f is symlink'
1769 $ hg merge -r 2 --tool internal:merge
1771 $ hg merge -r 2 --tool internal:merge
1770 merging f
1772 merging f
1771 warning: internal :merge cannot merge symlinks for f
1773 warning: internal :merge cannot merge symlinks for f
1772 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
1774 warning: conflicts while merging f! (edit, then use 'hg resolve --mark')
1773 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1775 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1774 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1776 use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
1775 [1]
1777 [1]
1776
1778
1777 #endif
1779 #endif
1778
1780
1779 Verify naming of temporary files and that extension is preserved:
1781 Verify naming of temporary files and that extension is preserved:
1780
1782
1781 $ hg update -q -C 1
1783 $ hg update -q -C 1
1782 $ hg mv f f.txt
1784 $ hg mv f f.txt
1783 $ hg ci -qm "f.txt"
1785 $ hg ci -qm "f.txt"
1784 $ hg update -q -C 2
1786 $ hg update -q -C 2
1785 $ hg merge -y -r tip --tool echo --config merge-tools.echo.args='$base $local $other $output'
1787 $ hg merge -y -r tip --tool echo --config merge-tools.echo.args='$base $local $other $output'
1786 merging f and f.txt to f.txt
1788 merging f and f.txt to f.txt
1787 */f~base.* */f~local.*.txt */f~other.*.txt $TESTTMP/repo/f.txt (glob)
1789 */f~base.* */f~local.*.txt */f~other.*.txt $TESTTMP/repo/f.txt (glob)
1788 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1790 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1789 (branch merge, don't forget to commit)
1791 (branch merge, don't forget to commit)
1790
1792
1791 Verify naming of temporary files and that extension is preserved
1793 Verify naming of temporary files and that extension is preserved
1792 (experimental.mergetempdirprefix version):
1794 (experimental.mergetempdirprefix version):
1793
1795
1794 $ hg update -q -C 1
1796 $ hg update -q -C 1
1795 $ hg mv f f.txt
1797 $ hg mv f f.txt
1796 $ hg ci -qm "f.txt"
1798 $ hg ci -qm "f.txt"
1797 $ hg update -q -C 2
1799 $ hg update -q -C 2
1798 $ hg merge -y -r tip --tool echo \
1800 $ hg merge -y -r tip --tool echo \
1799 > --config merge-tools.echo.args='$base $local $other $output' \
1801 > --config merge-tools.echo.args='$base $local $other $output' \
1800 > --config experimental.mergetempdirprefix=$TESTTMP/hgmerge.
1802 > --config experimental.mergetempdirprefix=$TESTTMP/hgmerge.
1801 merging f and f.txt to f.txt
1803 merging f and f.txt to f.txt
1802 $TESTTMP/hgmerge.*/f~base $TESTTMP/hgmerge.*/f~local.txt $TESTTMP/hgmerge.*/f~other.txt $TESTTMP/repo/f.txt (glob)
1804 $TESTTMP/hgmerge.*/f~base $TESTTMP/hgmerge.*/f~local.txt $TESTTMP/hgmerge.*/f~other.txt $TESTTMP/repo/f.txt (glob)
1803 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1805 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1804 (branch merge, don't forget to commit)
1806 (branch merge, don't forget to commit)
1805
1807
1806 Check that debugpicktool examines which merge tool is chosen for
1808 Check that debugpicktool examines which merge tool is chosen for
1807 specified file as expected
1809 specified file as expected
1808
1810
1809 $ beforemerge
1811 $ beforemerge
1810 [merge-tools]
1812 [merge-tools]
1811 false.whatever=
1813 false.whatever=
1812 true.priority=1
1814 true.priority=1
1813 true.executable=cat
1815 true.executable=cat
1814 missingbinary.executable=doesnotexist
1816 missingbinary.executable=doesnotexist
1815 # hg update -C 1
1817 # hg update -C 1
1816
1818
1817 (default behavior: checking files in the working parent context)
1819 (default behavior: checking files in the working parent context)
1818
1820
1819 $ hg manifest
1821 $ hg manifest
1820 f
1822 f
1821 $ hg debugpickmergetool
1823 $ hg debugpickmergetool
1822 f = true
1824 f = true
1823
1825
1824 (-X/-I and file patterns limmit examination targets)
1826 (-X/-I and file patterns limmit examination targets)
1825
1827
1826 $ hg debugpickmergetool -X f
1828 $ hg debugpickmergetool -X f
1827 $ hg debugpickmergetool unknown
1829 $ hg debugpickmergetool unknown
1828 unknown: no such file in rev ef83787e2614
1830 unknown: no such file in rev ef83787e2614
1829
1831
1830 (--changedelete emulates merging change and delete)
1832 (--changedelete emulates merging change and delete)
1831
1833
1832 $ hg debugpickmergetool --changedelete
1834 $ hg debugpickmergetool --changedelete
1833 f = :prompt
1835 f = :prompt
1834
1836
1835 (-r REV causes checking files in specified revision)
1837 (-r REV causes checking files in specified revision)
1836
1838
1837 $ hg manifest -r tip
1839 $ hg manifest -r tip
1838 f.txt
1840 f.txt
1839 $ hg debugpickmergetool -r tip
1841 $ hg debugpickmergetool -r tip
1840 f.txt = true
1842 f.txt = true
1841
1843
1842 #if symlink
1844 #if symlink
1843
1845
1844 (symlink causes chosing :prompt)
1846 (symlink causes chosing :prompt)
1845
1847
1846 $ hg debugpickmergetool -r 6d00b3726f6e
1848 $ hg debugpickmergetool -r 6d00b3726f6e
1847 f = :prompt
1849 f = :prompt
1848
1850
1849 #endif
1851 #endif
1850
1852
1851 (--verbose shows some configurations)
1853 (--verbose shows some configurations)
1852
1854
1853 $ hg debugpickmergetool --tool foobar -v
1855 $ hg debugpickmergetool --tool foobar -v
1854 with --tool 'foobar'
1856 with --tool 'foobar'
1855 f = foobar
1857 f = foobar
1856
1858
1857 $ HGMERGE=false hg debugpickmergetool -v
1859 $ HGMERGE=false hg debugpickmergetool -v
1858 with HGMERGE='false'
1860 with HGMERGE='false'
1859 f = false
1861 f = false
1860
1862
1861 $ hg debugpickmergetool --config ui.merge=false -v
1863 $ hg debugpickmergetool --config ui.merge=false -v
1862 with ui.merge='false'
1864 with ui.merge='false'
1863 f = false
1865 f = false
1864
1866
1865 (--debug shows errors detected intermediately)
1867 (--debug shows errors detected intermediately)
1866
1868
1867 $ hg debugpickmergetool --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool --debug f
1869 $ hg debugpickmergetool --config merge-patterns.f=true --config merge-tools.true.executable=nonexistentmergetool --debug f
1868 couldn't find merge tool true (for pattern f)
1870 couldn't find merge tool true (for pattern f)
1869 couldn't find merge tool true
1871 couldn't find merge tool true
1870 f = false
1872 f = false
1871
1873
1872 $ cd ..
1874 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now