##// END OF EJS Templates
filemerge: deindent the parts of filemerge outside the try block...
Siddharth Agarwal -
r26608:ae5b60d3 default
parent child Browse files
Show More
@@ -1,582 +1,581 b''
1 1 # filemerge.py - file-level merge handling for Mercurial
2 2 #
3 3 # Copyright 2006, 2007, 2008 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 import filecmp
11 11 import os
12 12 import re
13 13 import tempfile
14 14
15 15 from .i18n import _
16 16 from .node import short
17 17
18 18 from . import (
19 19 error,
20 20 match,
21 21 simplemerge,
22 22 tagmerge,
23 23 templatekw,
24 24 templater,
25 25 util,
26 26 )
27 27
28 28 def _toolstr(ui, tool, part, default=""):
29 29 return ui.config("merge-tools", tool + "." + part, default)
30 30
31 31 def _toolbool(ui, tool, part, default=False):
32 32 return ui.configbool("merge-tools", tool + "." + part, default)
33 33
34 34 def _toollist(ui, tool, part, default=[]):
35 35 return ui.configlist("merge-tools", tool + "." + part, default)
36 36
37 37 internals = {}
38 38 # Merge tools to document.
39 39 internalsdoc = {}
40 40
41 41 # internal tool merge types
42 42 nomerge = None
43 43 mergeonly = 'mergeonly' # just the full merge, no premerge
44 44 fullmerge = 'fullmerge' # both premerge and merge
45 45
46 46 def internaltool(name, mergetype, onfailure=None, precheck=None):
47 47 '''return a decorator for populating internal merge tool table'''
48 48 def decorator(func):
49 49 fullname = ':' + name
50 50 func.__doc__ = "``%s``\n" % fullname + func.__doc__.strip()
51 51 internals[fullname] = func
52 52 internals['internal:' + name] = func
53 53 internalsdoc[fullname] = func
54 54 func.mergetype = mergetype
55 55 func.onfailure = onfailure
56 56 func.precheck = precheck
57 57 return func
58 58 return decorator
59 59
60 60 def _findtool(ui, tool):
61 61 if tool in internals:
62 62 return tool
63 63 return findexternaltool(ui, tool)
64 64
65 65 def findexternaltool(ui, tool):
66 66 for kn in ("regkey", "regkeyalt"):
67 67 k = _toolstr(ui, tool, kn)
68 68 if not k:
69 69 continue
70 70 p = util.lookupreg(k, _toolstr(ui, tool, "regname"))
71 71 if p:
72 72 p = util.findexe(p + _toolstr(ui, tool, "regappend"))
73 73 if p:
74 74 return p
75 75 exe = _toolstr(ui, tool, "executable", tool)
76 76 return util.findexe(util.expandpath(exe))
77 77
78 78 def _picktool(repo, ui, path, binary, symlink):
79 79 def check(tool, pat, symlink, binary):
80 80 tmsg = tool
81 81 if pat:
82 82 tmsg += " specified for " + pat
83 83 if not _findtool(ui, tool):
84 84 if pat: # explicitly requested tool deserves a warning
85 85 ui.warn(_("couldn't find merge tool %s\n") % tmsg)
86 86 else: # configured but non-existing tools are more silent
87 87 ui.note(_("couldn't find merge tool %s\n") % tmsg)
88 88 elif symlink and not _toolbool(ui, tool, "symlink"):
89 89 ui.warn(_("tool %s can't handle symlinks\n") % tmsg)
90 90 elif binary and not _toolbool(ui, tool, "binary"):
91 91 ui.warn(_("tool %s can't handle binary\n") % tmsg)
92 92 elif not util.gui() and _toolbool(ui, tool, "gui"):
93 93 ui.warn(_("tool %s requires a GUI\n") % tmsg)
94 94 else:
95 95 return True
96 96 return False
97 97
98 98 # internal config: ui.forcemerge
99 99 # forcemerge comes from command line arguments, highest priority
100 100 force = ui.config('ui', 'forcemerge')
101 101 if force:
102 102 toolpath = _findtool(ui, force)
103 103 if toolpath:
104 104 return (force, util.shellquote(toolpath))
105 105 else:
106 106 # mimic HGMERGE if given tool not found
107 107 return (force, force)
108 108
109 109 # HGMERGE takes next precedence
110 110 hgmerge = os.environ.get("HGMERGE")
111 111 if hgmerge:
112 112 return (hgmerge, hgmerge)
113 113
114 114 # then patterns
115 115 for pat, tool in ui.configitems("merge-patterns"):
116 116 mf = match.match(repo.root, '', [pat])
117 117 if mf(path) and check(tool, pat, symlink, False):
118 118 toolpath = _findtool(ui, tool)
119 119 return (tool, util.shellquote(toolpath))
120 120
121 121 # then merge tools
122 122 tools = {}
123 123 for k, v in ui.configitems("merge-tools"):
124 124 t = k.split('.')[0]
125 125 if t not in tools:
126 126 tools[t] = int(_toolstr(ui, t, "priority", "0"))
127 127 names = tools.keys()
128 128 tools = sorted([(-p, t) for t, p in tools.items()])
129 129 uimerge = ui.config("ui", "merge")
130 130 if uimerge:
131 131 if uimerge not in names:
132 132 return (uimerge, uimerge)
133 133 tools.insert(0, (None, uimerge)) # highest priority
134 134 tools.append((None, "hgmerge")) # the old default, if found
135 135 for p, t in tools:
136 136 if check(t, None, symlink, binary):
137 137 toolpath = _findtool(ui, t)
138 138 return (t, util.shellquote(toolpath))
139 139
140 140 # internal merge or prompt as last resort
141 141 if symlink or binary:
142 142 return ":prompt", None
143 143 return ":merge", None
144 144
145 145 def _eoltype(data):
146 146 "Guess the EOL type of a file"
147 147 if '\0' in data: # binary
148 148 return None
149 149 if '\r\n' in data: # Windows
150 150 return '\r\n'
151 151 if '\r' in data: # Old Mac
152 152 return '\r'
153 153 if '\n' in data: # UNIX
154 154 return '\n'
155 155 return None # unknown
156 156
157 157 def _matcheol(file, origfile):
158 158 "Convert EOL markers in a file to match origfile"
159 159 tostyle = _eoltype(util.readfile(origfile))
160 160 if tostyle:
161 161 data = util.readfile(file)
162 162 style = _eoltype(data)
163 163 if style:
164 164 newdata = data.replace(style, tostyle)
165 165 if newdata != data:
166 166 util.writefile(file, newdata)
167 167
168 168 @internaltool('prompt', nomerge)
169 169 def _iprompt(repo, mynode, orig, fcd, fco, fca, toolconf):
170 170 """Asks the user which of the local or the other version to keep as
171 171 the merged version."""
172 172 ui = repo.ui
173 173 fd = fcd.path()
174 174
175 175 if ui.promptchoice(_(" no tool found to merge %s\n"
176 176 "keep (l)ocal or take (o)ther?"
177 177 "$$ &Local $$ &Other") % fd, 0):
178 178 return _iother(repo, mynode, orig, fcd, fco, fca, toolconf)
179 179 else:
180 180 return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
181 181
182 182 @internaltool('local', nomerge)
183 183 def _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf):
184 184 """Uses the local version of files as the merged version."""
185 185 return 0
186 186
187 187 @internaltool('other', nomerge)
188 188 def _iother(repo, mynode, orig, fcd, fco, fca, toolconf):
189 189 """Uses the other version of files as the merged version."""
190 190 repo.wwrite(fcd.path(), fco.data(), fco.flags())
191 191 return 0
192 192
193 193 @internaltool('fail', nomerge)
194 194 def _ifail(repo, mynode, orig, fcd, fco, fca, toolconf):
195 195 """
196 196 Rather than attempting to merge files that were modified on both
197 197 branches, it marks them as unresolved. The resolve command must be
198 198 used to resolve these conflicts."""
199 199 return 1
200 200
201 201 def _premerge(repo, toolconf, files, labels=None):
202 202 tool, toolpath, binary, symlink = toolconf
203 203 if symlink:
204 204 return 1
205 205 a, b, c, back = files
206 206
207 207 ui = repo.ui
208 208
209 209 validkeep = ['keep', 'keep-merge3']
210 210
211 211 # do we attempt to simplemerge first?
212 212 try:
213 213 premerge = _toolbool(ui, tool, "premerge", not binary)
214 214 except error.ConfigError:
215 215 premerge = _toolstr(ui, tool, "premerge").lower()
216 216 if premerge not in validkeep:
217 217 _valid = ', '.join(["'" + v + "'" for v in validkeep])
218 218 raise error.ConfigError(_("%s.premerge not valid "
219 219 "('%s' is neither boolean nor %s)") %
220 220 (tool, premerge, _valid))
221 221
222 222 if premerge:
223 223 if premerge == 'keep-merge3':
224 224 if not labels:
225 225 labels = _defaultconflictlabels
226 226 if len(labels) < 3:
227 227 labels.append('base')
228 228 r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels)
229 229 if not r:
230 230 ui.debug(" premerge successful\n")
231 231 return 0
232 232 if premerge not in validkeep:
233 233 util.copyfile(back, a) # restore from backup and try again
234 234 return 1 # continue merging
235 235
236 236 def _symlinkcheck(repo, mynode, orig, fcd, fco, fca, toolconf):
237 237 tool, toolpath, binary, symlink = toolconf
238 238 if symlink:
239 239 repo.ui.warn(_('warning: internal %s cannot merge symlinks '
240 240 'for %s\n') % (tool, fcd.path()))
241 241 return False
242 242 return True
243 243
244 244 def _merge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels, mode):
245 245 """
246 246 Uses the internal non-interactive simple merge algorithm for merging
247 247 files. It will fail if there are any conflicts and leave markers in
248 248 the partially merged file. Markers will have two sections, one for each side
249 249 of merge, unless mode equals 'union' which suppresses the markers."""
250 250 a, b, c, back = files
251 251
252 252 ui = repo.ui
253 253
254 254 r = simplemerge.simplemerge(ui, a, b, c, label=labels, mode=mode)
255 255 return True, r
256 256
257 257 @internaltool('union', fullmerge,
258 258 _("merging %s incomplete! "
259 259 "(edit conflicts, then use 'hg resolve --mark')\n"),
260 260 precheck=_symlinkcheck)
261 261 def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
262 262 """
263 263 Uses the internal non-interactive simple merge algorithm for merging
264 264 files. It will use both left and right sides for conflict regions.
265 265 No markers are inserted."""
266 266 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
267 267 files, labels, 'union')
268 268
269 269 @internaltool('merge', fullmerge,
270 270 _("merging %s incomplete! "
271 271 "(edit conflicts, then use 'hg resolve --mark')\n"),
272 272 precheck=_symlinkcheck)
273 273 def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
274 274 """
275 275 Uses the internal non-interactive simple merge algorithm for merging
276 276 files. It will fail if there are any conflicts and leave markers in
277 277 the partially merged file. Markers will have two sections, one for each side
278 278 of merge."""
279 279 return _merge(repo, mynode, orig, fcd, fco, fca, toolconf,
280 280 files, labels, 'merge')
281 281
282 282 @internaltool('merge3', fullmerge,
283 283 _("merging %s incomplete! "
284 284 "(edit conflicts, then use 'hg resolve --mark')\n"),
285 285 precheck=_symlinkcheck)
286 286 def _imerge3(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
287 287 """
288 288 Uses the internal non-interactive simple merge algorithm for merging
289 289 files. It will fail if there are any conflicts and leave markers in
290 290 the partially merged file. Marker will have three sections, one from each
291 291 side of the merge and one for the base content."""
292 292 if not labels:
293 293 labels = _defaultconflictlabels
294 294 if len(labels) < 3:
295 295 labels.append('base')
296 296 return _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels)
297 297
298 298 def _imergeauto(repo, mynode, orig, fcd, fco, fca, toolconf, files,
299 299 labels=None, localorother=None):
300 300 """
301 301 Generic driver for _imergelocal and _imergeother
302 302 """
303 303 assert localorother is not None
304 304 tool, toolpath, binary, symlink = toolconf
305 305 if symlink:
306 306 repo.ui.warn(_('warning: :merge-%s cannot merge symlinks '
307 307 'for %s\n') % (localorother, fcd.path()))
308 308 return False, 1
309 309 a, b, c, back = files
310 310 r = simplemerge.simplemerge(repo.ui, a, b, c, label=labels,
311 311 localorother=localorother)
312 312 return True, r
313 313
314 314 @internaltool('merge-local', mergeonly)
315 315 def _imergelocal(*args, **kwargs):
316 316 """
317 317 Like :merge, but resolve all conflicts non-interactively in favor
318 318 of the local changes."""
319 319 success, status = _imergeauto(localorother='local', *args, **kwargs)
320 320 return success, status
321 321
322 322 @internaltool('merge-other', mergeonly)
323 323 def _imergeother(*args, **kwargs):
324 324 """
325 325 Like :merge, but resolve all conflicts non-interactively in favor
326 326 of the other changes."""
327 327 success, status = _imergeauto(localorother='other', *args, **kwargs)
328 328 return success, status
329 329
330 330 @internaltool('tagmerge', mergeonly,
331 331 _("automatic tag merging of %s failed! "
332 332 "(use 'hg resolve --tool :merge' or another merge "
333 333 "tool of your choice)\n"))
334 334 def _itagmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
335 335 """
336 336 Uses the internal tag merge algorithm (experimental).
337 337 """
338 338 return tagmerge.merge(repo, fcd, fco, fca)
339 339
340 340 @internaltool('dump', fullmerge)
341 341 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
342 342 """
343 343 Creates three versions of the files to merge, containing the
344 344 contents of local, other and base. These files can then be used to
345 345 perform a merge manually. If the file to be merged is named
346 346 ``a.txt``, these files will accordingly be named ``a.txt.local``,
347 347 ``a.txt.other`` and ``a.txt.base`` and they will be placed in the
348 348 same directory as ``a.txt``."""
349 349 a, b, c, back = files
350 350
351 351 fd = fcd.path()
352 352
353 353 util.copyfile(a, a + ".local")
354 354 repo.wwrite(fd + ".other", fco.data(), fco.flags())
355 355 repo.wwrite(fd + ".base", fca.data(), fca.flags())
356 356 return False, 1
357 357
358 358 def _xmerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
359 359 tool, toolpath, binary, symlink = toolconf
360 360 a, b, c, back = files
361 361 out = ""
362 362 env = {'HG_FILE': fcd.path(),
363 363 'HG_MY_NODE': short(mynode),
364 364 'HG_OTHER_NODE': str(fco.changectx()),
365 365 'HG_BASE_NODE': str(fca.changectx()),
366 366 'HG_MY_ISLINK': 'l' in fcd.flags(),
367 367 'HG_OTHER_ISLINK': 'l' in fco.flags(),
368 368 'HG_BASE_ISLINK': 'l' in fca.flags(),
369 369 }
370 370
371 371 ui = repo.ui
372 372
373 373 args = _toolstr(ui, tool, "args", '$local $base $other')
374 374 if "$output" in args:
375 375 out, a = a, back # read input from backup, write to original
376 376 replace = {'local': a, 'base': b, 'other': c, 'output': out}
377 377 args = util.interpolate(r'\$', replace, args,
378 378 lambda s: util.shellquote(util.localpath(s)))
379 379 cmd = toolpath + ' ' + args
380 380 repo.ui.debug('launching merge tool: %s\n' % cmd)
381 381 r = ui.system(cmd, cwd=repo.root, environ=env)
382 382 repo.ui.debug('merge tool returned: %s\n' % r)
383 383 return True, r
384 384
385 385 def _formatconflictmarker(repo, ctx, template, label, pad):
386 386 """Applies the given template to the ctx, prefixed by the label.
387 387
388 388 Pad is the minimum width of the label prefix, so that multiple markers
389 389 can have aligned templated parts.
390 390 """
391 391 if ctx.node() is None:
392 392 ctx = ctx.p1()
393 393
394 394 props = templatekw.keywords.copy()
395 395 props['templ'] = template
396 396 props['ctx'] = ctx
397 397 props['repo'] = repo
398 398 templateresult = template('conflictmarker', **props)
399 399
400 400 label = ('%s:' % label).ljust(pad + 1)
401 401 mark = '%s %s' % (label, templater.stringify(templateresult))
402 402
403 403 if mark:
404 404 mark = mark.splitlines()[0] # split for safety
405 405
406 406 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
407 407 return util.ellipsis(mark, 80 - 8)
408 408
409 409 _defaultconflictmarker = ('{node|short} ' +
410 410 '{ifeq(tags, "tip", "", "{tags} ")}' +
411 411 '{if(bookmarks, "{bookmarks} ")}' +
412 412 '{ifeq(branch, "default", "", "{branch} ")}' +
413 413 '- {author|user}: {desc|firstline}')
414 414
415 415 _defaultconflictlabels = ['local', 'other']
416 416
417 417 def _formatlabels(repo, fcd, fco, fca, labels):
418 418 """Formats the given labels using the conflict marker template.
419 419
420 420 Returns a list of formatted labels.
421 421 """
422 422 cd = fcd.changectx()
423 423 co = fco.changectx()
424 424 ca = fca.changectx()
425 425
426 426 ui = repo.ui
427 427 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker)
428 428 tmpl = templater.templater(None, cache={'conflictmarker': template})
429 429
430 430 pad = max(len(l) for l in labels)
431 431
432 432 newlabels = [_formatconflictmarker(repo, cd, tmpl, labels[0], pad),
433 433 _formatconflictmarker(repo, co, tmpl, labels[1], pad)]
434 434 if len(labels) > 2:
435 435 newlabels.append(_formatconflictmarker(repo, ca, tmpl, labels[2], pad))
436 436 return newlabels
437 437
438 438 def _filemerge(premerge, repo, mynode, orig, fcd, fco, fca, labels=None):
439 439 """perform a 3-way merge in the working directory
440 440
441 441 premerge = whether this is a premerge
442 442 mynode = parent node before merge
443 443 orig = original local filename before merge
444 444 fco = other file context
445 445 fca = ancestor file context
446 446 fcd = local file context for current/destination file
447 447
448 448 Returns whether the merge is complete, and the return value of the merge.
449 449 """
450 450
451 if True:
452 def temp(prefix, ctx):
453 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
454 (fd, name) = tempfile.mkstemp(prefix=pre)
455 data = repo.wwritedata(ctx.path(), ctx.data())
456 f = os.fdopen(fd, "wb")
457 f.write(data)
458 f.close()
459 return name
451 def temp(prefix, ctx):
452 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
453 (fd, name) = tempfile.mkstemp(prefix=pre)
454 data = repo.wwritedata(ctx.path(), ctx.data())
455 f = os.fdopen(fd, "wb")
456 f.write(data)
457 f.close()
458 return name
460 459
461 if not fco.cmp(fcd): # files identical?
462 return True, None
460 if not fco.cmp(fcd): # files identical?
461 return True, None
463 462
464 ui = repo.ui
465 fd = fcd.path()
466 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
467 symlink = 'l' in fcd.flags() + fco.flags()
468 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
469 if tool in internals and tool.startswith('internal:'):
470 # normalize to new-style names (':merge' etc)
471 tool = tool[len('internal'):]
472 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
473 (tool, fd, binary, symlink))
463 ui = repo.ui
464 fd = fcd.path()
465 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
466 symlink = 'l' in fcd.flags() + fco.flags()
467 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
468 if tool in internals and tool.startswith('internal:'):
469 # normalize to new-style names (':merge' etc)
470 tool = tool[len('internal'):]
471 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
472 (tool, fd, binary, symlink))
474 473
475 if tool in internals:
476 func = internals[tool]
477 mergetype = func.mergetype
478 onfailure = func.onfailure
479 precheck = func.precheck
480 else:
481 func = _xmerge
482 mergetype = fullmerge
483 onfailure = _("merging %s failed!\n")
484 precheck = None
474 if tool in internals:
475 func = internals[tool]
476 mergetype = func.mergetype
477 onfailure = func.onfailure
478 precheck = func.precheck
479 else:
480 func = _xmerge
481 mergetype = fullmerge
482 onfailure = _("merging %s failed!\n")
483 precheck = None
485 484
486 toolconf = tool, toolpath, binary, symlink
485 toolconf = tool, toolpath, binary, symlink
487 486
488 if mergetype == nomerge:
489 return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
487 if mergetype == nomerge:
488 return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
490 489
491 if orig != fco.path():
492 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
493 else:
494 ui.status(_("merging %s\n") % fd)
490 if orig != fco.path():
491 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
492 else:
493 ui.status(_("merging %s\n") % fd)
495 494
496 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
495 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
497 496
498 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
499 toolconf):
500 if onfailure:
501 ui.warn(onfailure % fd)
502 return True, 1
497 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
498 toolconf):
499 if onfailure:
500 ui.warn(onfailure % fd)
501 return True, 1
503 502
504 a = repo.wjoin(fd)
505 b = temp("base", fca)
506 c = temp("other", fco)
507 back = a + ".orig"
508 util.copyfile(a, back)
509 files = (a, b, c, back)
503 a = repo.wjoin(fd)
504 b = temp("base", fca)
505 c = temp("other", fco)
506 back = a + ".orig"
507 util.copyfile(a, back)
508 files = (a, b, c, back)
510 509
511 510 r = 1
512 511 try:
513 512 markerstyle = ui.config('ui', 'mergemarkers', 'basic')
514 513 if not labels:
515 514 labels = _defaultconflictlabels
516 515 if markerstyle != 'basic':
517 516 labels = _formatlabels(repo, fcd, fco, fca, labels)
518 517
519 518 if premerge and mergetype == fullmerge:
520 519 r = _premerge(repo, toolconf, files, labels=labels)
521 520
522 521 if not r: # premerge successfully merged the file
523 522 needcheck = False
524 523 else:
525 524 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
526 525 files, labels=labels)
527 526
528 527 if needcheck:
529 528 r = _check(r, ui, tool, fcd, files)
530 529
531 530 if r:
532 531 if onfailure:
533 532 ui.warn(onfailure % fd)
534 533
535 534 return True, r
536 535 finally:
537 536 if not r:
538 537 util.unlink(back)
539 538 util.unlink(b)
540 539 util.unlink(c)
541 540
542 541 def _check(r, ui, tool, fcd, files):
543 542 fd = fcd.path()
544 543 a, b, c, back = files
545 544
546 545 if not r and (_toolbool(ui, tool, "checkconflicts") or
547 546 'conflicts' in _toollist(ui, tool, "check")):
548 547 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(),
549 548 re.MULTILINE):
550 549 r = 1
551 550
552 551 checked = False
553 552 if 'prompt' in _toollist(ui, tool, "check"):
554 553 checked = True
555 554 if ui.promptchoice(_("was merge of '%s' successful (yn)?"
556 555 "$$ &Yes $$ &No") % fd, 1):
557 556 r = 1
558 557
559 558 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
560 559 'changed' in
561 560 _toollist(ui, tool, "check")):
562 561 if filecmp.cmp(a, back):
563 562 if ui.promptchoice(_(" output file %s appears unchanged\n"
564 563 "was merge successful (yn)?"
565 564 "$$ &Yes $$ &No") % fd, 1):
566 565 r = 1
567 566
568 567 if _toolbool(ui, tool, "fixeol"):
569 568 _matcheol(a, back)
570 569
571 570 return r
572 571
573 572 def premerge(repo, mynode, orig, fcd, fco, fca, labels=None):
574 573 return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
575 574
576 575 def filemerge(repo, mynode, orig, fcd, fco, fca, labels=None):
577 576 # premerge = True is temporary -- will be changed to False once premerge
578 577 # function above is ready
579 578 return _filemerge(True, repo, mynode, orig, fcd, fco, fca, labels=labels)
580 579
581 580 # tell hggettext to extract docstrings from these functions:
582 581 i18nfunctions = internals.values()
General Comments 0
You need to be logged in to leave comments. Login now