mercurial/filemerge.py
changeset 26608 ae5b60d3294f
parent 26607 45a6233d5f50
child 26609 47681e77e484
equal deleted inserted replaced
26607:45a6233d5f50 26608:ae5b60d3294f
   446     fcd = local file context for current/destination file
   446     fcd = local file context for current/destination file
   447 
   447 
   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
   459 
   460 
   460     if not fco.cmp(fcd): # files identical?
   461         if not fco.cmp(fcd): # files identical?
   461         return True, None
   462             return True, None
   462 
   463 
   463     ui = repo.ui
   464         ui = repo.ui
   464     fd = fcd.path()
   465         fd = fcd.path()
   465     binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
   466         binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
   466     symlink = 'l' in fcd.flags() + fco.flags()
   467         symlink = 'l' in fcd.flags() + fco.flags()
   467     tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
   468         tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
   468     if tool in internals and tool.startswith('internal:'):
   469         if tool in internals and tool.startswith('internal:'):
   469         # normalize to new-style names (':merge' etc)
   470             # normalize to new-style names (':merge' etc)
   470         tool = tool[len('internal'):]
   471             tool = tool[len('internal'):]
   471     ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
   472         ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
   472                (tool, fd, binary, symlink))
   473                    (tool, fd, binary, symlink))
   473 
   474 
   474     if tool in internals:
   475         if tool in internals:
   475         func = internals[tool]
   476             func = internals[tool]
   476         mergetype = func.mergetype
   477             mergetype = func.mergetype
   477         onfailure = func.onfailure
   478             onfailure = func.onfailure
   478         precheck = func.precheck
   479             precheck = func.precheck
   479     else:
   480         else:
   480         func = _xmerge
   481             func = _xmerge
   481         mergetype = fullmerge
   482             mergetype = fullmerge
   482         onfailure = _("merging %s failed!\n")
   483             onfailure = _("merging %s failed!\n")
   483         precheck = None
   484             precheck = None
   484 
   485 
   485     toolconf = tool, toolpath, binary, symlink
   486         toolconf = tool, toolpath, binary, symlink
   486 
   487 
   487     if mergetype == nomerge:
   488         if mergetype == nomerge:
   488         return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
   489             return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
   489 
   490 
   490     if orig != fco.path():
   491         if orig != fco.path():
   491         ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
   492             ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
   492     else:
   493         else:
   493         ui.status(_("merging %s\n") % fd)
   494             ui.status(_("merging %s\n") % fd)
   494 
   495 
   495     ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
   496         ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
   496 
   497 
   497     if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
   498         if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
   498                                  toolconf):
   499                                      toolconf):
   499         if onfailure:
   500             if onfailure:
   500             ui.warn(onfailure % fd)
   501                 ui.warn(onfailure % fd)
   501         return True, 1
   502             return True, 1
   502 
   503 
   503     a = repo.wjoin(fd)
   504         a = repo.wjoin(fd)
   504     b = temp("base", fca)
   505         b = temp("base", fca)
   505     c = temp("other", fco)
   506         c = temp("other", fco)
   506     back = a + ".orig"
   507         back = a + ".orig"
   507     util.copyfile(a, back)
   508         util.copyfile(a, back)
   508     files = (a, b, c, back)
   509         files = (a, b, c, back)
       
   510 
   509 
   511     r = 1
   510     r = 1
   512     try:
   511     try:
   513         markerstyle = ui.config('ui', 'mergemarkers', 'basic')
   512         markerstyle = ui.config('ui', 'mergemarkers', 'basic')
   514         if not labels:
   513         if not labels: