##// END OF EJS Templates
filemerge: indent filemerge.filemerge...
Siddharth Agarwal -
r26512:4c52dd40 default
parent child Browse files
Show More
@@ -441,62 +441,98 b' def filemerge(repo, mynode, orig, fcd, f'
441 fcd = local file context for current/destination file
441 fcd = local file context for current/destination file
442 """
442 """
443
443
444 def temp(prefix, ctx):
444 if True:
445 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
445 def temp(prefix, ctx):
446 (fd, name) = tempfile.mkstemp(prefix=pre)
446 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
447 data = repo.wwritedata(ctx.path(), ctx.data())
447 (fd, name) = tempfile.mkstemp(prefix=pre)
448 f = os.fdopen(fd, "wb")
448 data = repo.wwritedata(ctx.path(), ctx.data())
449 f.write(data)
449 f = os.fdopen(fd, "wb")
450 f.close()
450 f.write(data)
451 return name
451 f.close()
452 return name
453
454 if not fco.cmp(fcd): # files identical?
455 return None
456
457 ui = repo.ui
458 fd = fcd.path()
459 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
460 symlink = 'l' in fcd.flags() + fco.flags()
461 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
462 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
463 (tool, fd, binary, symlink))
452
464
453 if not fco.cmp(fcd): # files identical?
465 if tool in internals:
454 return None
466 func = internals[tool]
467 trymerge = func.trymerge
468 onfailure = func.onfailure
469 else:
470 func = _xmerge
471 trymerge = True
472 onfailure = _("merging %s failed!\n")
473
474 toolconf = tool, toolpath, binary, symlink
455
475
456 ui = repo.ui
476 if not trymerge:
457 fd = fcd.path()
477 return func(repo, mynode, orig, fcd, fco, fca, toolconf)
458 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
478
459 symlink = 'l' in fcd.flags() + fco.flags()
479 a = repo.wjoin(fd)
460 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
480 b = temp("base", fca)
461 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
481 c = temp("other", fco)
462 (tool, fd, binary, symlink))
482 back = a + ".orig"
483 util.copyfile(a, back)
484
485 if orig != fco.path():
486 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
487 else:
488 ui.status(_("merging %s\n") % fd)
463
489
464 if tool in internals:
490 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
465 func = internals[tool]
491
466 trymerge = func.trymerge
492 markerstyle = ui.config('ui', 'mergemarkers', 'basic')
467 onfailure = func.onfailure
493 if not labels:
468 else:
494 labels = _defaultconflictlabels
469 func = _xmerge
495 if markerstyle != 'basic':
470 trymerge = True
496 labels = _formatlabels(repo, fcd, fco, fca, labels)
471 onfailure = _("merging %s failed!\n")
472
497
473 toolconf = tool, toolpath, binary, symlink
498 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
499 (a, b, c, back), labels=labels)
500 if not needcheck:
501 if r:
502 if onfailure:
503 ui.warn(onfailure % fd)
504 else:
505 util.unlink(back)
474
506
475 if not trymerge:
507 util.unlink(b)
476 return func(repo, mynode, orig, fcd, fco, fca, toolconf)
508 util.unlink(c)
509 return r
477
510
478 a = repo.wjoin(fd)
511 if not r and (_toolbool(ui, tool, "checkconflicts") or
479 b = temp("base", fca)
512 'conflicts' in _toollist(ui, tool, "check")):
480 c = temp("other", fco)
513 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(),
481 back = a + ".orig"
514 re.MULTILINE):
482 util.copyfile(a, back)
515 r = 1
483
516
484 if orig != fco.path():
517 checked = False
485 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
518 if 'prompt' in _toollist(ui, tool, "check"):
486 else:
519 checked = True
487 ui.status(_("merging %s\n") % fd)
520 if ui.promptchoice(_("was merge of '%s' successful (yn)?"
521 "$$ &Yes $$ &No") % fd, 1):
522 r = 1
488
523
489 ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
524 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
525 'changed' in
526 _toollist(ui, tool, "check")):
527 if filecmp.cmp(a, back):
528 if ui.promptchoice(_(" output file %s appears unchanged\n"
529 "was merge successful (yn)?"
530 "$$ &Yes $$ &No") % fd, 1):
531 r = 1
490
532
491 markerstyle = ui.config('ui', 'mergemarkers', 'basic')
533 if _toolbool(ui, tool, "fixeol"):
492 if not labels:
534 _matcheol(a, back)
493 labels = _defaultconflictlabels
494 if markerstyle != 'basic':
495 labels = _formatlabels(repo, fcd, fco, fca, labels)
496
535
497 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf,
498 (a, b, c, back), labels=labels)
499 if not needcheck:
500 if r:
536 if r:
501 if onfailure:
537 if onfailure:
502 ui.warn(onfailure % fd)
538 ui.warn(onfailure % fd)
@@ -507,39 +543,5 b' def filemerge(repo, mynode, orig, fcd, f'
507 util.unlink(c)
543 util.unlink(c)
508 return r
544 return r
509
545
510 if not r and (_toolbool(ui, tool, "checkconflicts") or
511 'conflicts' in _toollist(ui, tool, "check")):
512 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(),
513 re.MULTILINE):
514 r = 1
515
516 checked = False
517 if 'prompt' in _toollist(ui, tool, "check"):
518 checked = True
519 if ui.promptchoice(_("was merge of '%s' successful (yn)?"
520 "$$ &Yes $$ &No") % fd, 1):
521 r = 1
522
523 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or
524 'changed' in _toollist(ui, tool, "check")):
525 if filecmp.cmp(a, back):
526 if ui.promptchoice(_(" output file %s appears unchanged\n"
527 "was merge successful (yn)?"
528 "$$ &Yes $$ &No") % fd, 1):
529 r = 1
530
531 if _toolbool(ui, tool, "fixeol"):
532 _matcheol(a, back)
533
534 if r:
535 if onfailure:
536 ui.warn(onfailure % fd)
537 else:
538 util.unlink(back)
539
540 util.unlink(b)
541 util.unlink(c)
542 return r
543
544 # tell hggettext to extract docstrings from these functions:
546 # tell hggettext to extract docstrings from these functions:
545 i18nfunctions = internals.values()
547 i18nfunctions = internals.values()
General Comments 0
You need to be logged in to leave comments. Login now