Show More
@@ -441,62 +441,98 b' def filemerge(repo, mynode, orig, fcd, f' | |||
|
441 | 441 | fcd = local file context for current/destination file |
|
442 | 442 | """ |
|
443 | 443 | |
|
444 | def temp(prefix, ctx): | |
|
445 | pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) | |
|
446 | (fd, name) = tempfile.mkstemp(prefix=pre) | |
|
447 | data = repo.wwritedata(ctx.path(), ctx.data()) | |
|
448 | f = os.fdopen(fd, "wb") | |
|
449 | f.write(data) | |
|
450 |
f. |
|
|
451 | return name | |
|
444 | if True: | |
|
445 | def temp(prefix, ctx): | |
|
446 | pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) | |
|
447 | (fd, name) = tempfile.mkstemp(prefix=pre) | |
|
448 | data = repo.wwritedata(ctx.path(), ctx.data()) | |
|
449 | f = os.fdopen(fd, "wb") | |
|
450 | f.write(data) | |
|
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? | |
|
454 | return None | |
|
465 | if tool in internals: | |
|
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 | |
|
457 | fd = fcd.path() | |
|
458 | binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() | |
|
459 | symlink = 'l' in fcd.flags() + fco.flags() | |
|
460 | tool, toolpath = _picktool(repo, ui, fd, binary, symlink) | |
|
461 | ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % | |
|
462 | (tool, fd, binary, symlink)) | |
|
476 | if not trymerge: | |
|
477 | return func(repo, mynode, orig, fcd, fco, fca, toolconf) | |
|
478 | ||
|
479 | a = repo.wjoin(fd) | |
|
480 | b = temp("base", fca) | |
|
481 | c = temp("other", fco) | |
|
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: | |
|
465 | func = internals[tool] | |
|
466 | trymerge = func.trymerge | |
|
467 | onfailure = func.onfailure | |
|
468 | else: | |
|
469 | func = _xmerge | |
|
470 | trymerge = True | |
|
471 | onfailure = _("merging %s failed!\n") | |
|
490 | ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) | |
|
491 | ||
|
492 | markerstyle = ui.config('ui', 'mergemarkers', 'basic') | |
|
493 | if not labels: | |
|
494 | labels = _defaultconflictlabels | |
|
495 | if markerstyle != 'basic': | |
|
496 | labels = _formatlabels(repo, fcd, fco, fca, labels) | |
|
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: | |
|
476 | return func(repo, mynode, orig, fcd, fco, fca, toolconf) | |
|
507 | util.unlink(b) | |
|
508 | util.unlink(c) | |
|
509 | return r | |
|
477 | 510 | |
|
478 | a = repo.wjoin(fd) | |
|
479 | b = temp("base", fca) | |
|
480 | c = temp("other", fco) | |
|
481 | back = a + ".orig" | |
|
482 | util.copyfile(a, back) | |
|
511 | if not r and (_toolbool(ui, tool, "checkconflicts") or | |
|
512 | 'conflicts' in _toollist(ui, tool, "check")): | |
|
513 | if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), | |
|
514 | re.MULTILINE): | |
|
515 | r = 1 | |
|
483 | 516 | |
|
484 | if orig != fco.path(): | |
|
485 | ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) | |
|
486 | else: | |
|
487 | ui.status(_("merging %s\n") % fd) | |
|
517 | checked = False | |
|
518 | if 'prompt' in _toollist(ui, tool, "check"): | |
|
519 | checked = True | |
|
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') | |
|
492 | if not labels: | |
|
493 | labels = _defaultconflictlabels | |
|
494 | if markerstyle != 'basic': | |
|
495 | labels = _formatlabels(repo, fcd, fco, fca, labels) | |
|
533 | if _toolbool(ui, tool, "fixeol"): | |
|
534 | _matcheol(a, back) | |
|
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 | 536 | if r: |
|
501 | 537 | if onfailure: |
|
502 | 538 | ui.warn(onfailure % fd) |
@@ -507,39 +543,5 b' def filemerge(repo, mynode, orig, fcd, f' | |||
|
507 | 543 | util.unlink(c) |
|
508 | 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 | 546 | # tell hggettext to extract docstrings from these functions: |
|
545 | 547 | i18nfunctions = internals.values() |
General Comments 0
You need to be logged in to leave comments.
Login now