##// 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
@@ -448,65 +448,64 b' def _filemerge(premerge, repo, mynode, o'
448 Returns whether the merge is complete, and the return value of the merge.
448 Returns whether the merge is complete, and the return value of the merge.
449 """
449 """
450
450
451 if True:
451 def temp(prefix, ctx):
452 def temp(prefix, ctx):
452 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
453 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
453 (fd, name) = tempfile.mkstemp(prefix=pre)
454 (fd, name) = tempfile.mkstemp(prefix=pre)
454 data = repo.wwritedata(ctx.path(), ctx.data())
455 data = repo.wwritedata(ctx.path(), ctx.data())
455 f = os.fdopen(fd, "wb")
456 f = os.fdopen(fd, "wb")
456 f.write(data)
457 f.write(data)
457 f.close()
458 f.close()
458 return name
459 return name
460
459
461 if not fco.cmp(fcd): # files identical?
460 if not fco.cmp(fcd): # files identical?
462 return True, None
461 return True, None
463
462
464 ui = repo.ui
463 ui = repo.ui
465 fd = fcd.path()
464 fd = fcd.path()
466 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
465 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
467 symlink = 'l' in fcd.flags() + fco.flags()
466 symlink = 'l' in fcd.flags() + fco.flags()
468 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
467 tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
469 if tool in internals and tool.startswith('internal:'):
468 if tool in internals and tool.startswith('internal:'):
470 # normalize to new-style names (':merge' etc)
469 # normalize to new-style names (':merge' etc)
471 tool = tool[len('internal'):]
470 tool = tool[len('internal'):]
472 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
471 ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
473 (tool, fd, binary, symlink))
472 (tool, fd, binary, symlink))
474
473
475 if tool in internals:
474 if tool in internals:
476 func = internals[tool]
475 func = internals[tool]
477 mergetype = func.mergetype
476 mergetype = func.mergetype
478 onfailure = func.onfailure
477 onfailure = func.onfailure
479 precheck = func.precheck
478 precheck = func.precheck
480 else:
479 else:
481 func = _xmerge
480 func = _xmerge
482 mergetype = fullmerge
481 mergetype = fullmerge
483 onfailure = _("merging %s failed!\n")
482 onfailure = _("merging %s failed!\n")
484 precheck = None
483 precheck = None
485
484
486 toolconf = tool, toolpath, binary, symlink
485 toolconf = tool, toolpath, binary, symlink
487
486
488 if mergetype == nomerge:
487 if mergetype == nomerge:
489 return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
488 return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
490
489
491 if orig != fco.path():
490 if orig != fco.path():
492 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
491 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
493 else:
492 else:
494 ui.status(_("merging %s\n") % fd)
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,
497 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
499 toolconf):
498 toolconf):
500 if onfailure:
499 if onfailure:
501 ui.warn(onfailure % fd)
500 ui.warn(onfailure % fd)
502 return True, 1
501 return True, 1
503
502
504 a = repo.wjoin(fd)
503 a = repo.wjoin(fd)
505 b = temp("base", fca)
504 b = temp("base", fca)
506 c = temp("other", fco)
505 c = temp("other", fco)
507 back = a + ".orig"
506 back = a + ".orig"
508 util.copyfile(a, back)
507 util.copyfile(a, back)
509 files = (a, b, c, back)
508 files = (a, b, c, back)
510
509
511 r = 1
510 r = 1
512 try:
511 try:
General Comments 0
You need to be logged in to leave comments. Login now