comparison mercurial/filemerge.py @ 26606:2a405d307f8c

filemerge: also return whether the merge is complete In future patches, we'll pause merges after the premerge step. After the premerge step we'll return complete = False.
author Siddharth Agarwal <sid0@fb.com>
date Sun, 11 Oct 2015 12:56:21 -0700
parents ef21a2c41629
children 45a6233d5f50
comparison
equal deleted inserted replaced
26605:ef21a2c41629 26606:2a405d307f8c
441 mynode = parent node before merge 441 mynode = parent node before merge
442 orig = original local filename before merge 442 orig = original local filename before merge
443 fco = other file context 443 fco = other file context
444 fca = ancestor file context 444 fca = ancestor file context
445 fcd = local file context for current/destination file 445 fcd = local file context for current/destination file
446
447 Returns whether the merge is complete, and the return value of the merge.
446 """ 448 """
447 449
448 if True: 450 if True:
449 def temp(prefix, ctx): 451 def temp(prefix, ctx):
450 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) 452 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
454 f.write(data) 456 f.write(data)
455 f.close() 457 f.close()
456 return name 458 return name
457 459
458 if not fco.cmp(fcd): # files identical? 460 if not fco.cmp(fcd): # files identical?
459 return None 461 return True, None
460 462
461 ui = repo.ui 463 ui = repo.ui
462 fd = fcd.path() 464 fd = fcd.path()
463 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() 465 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
464 symlink = 'l' in fcd.flags() + fco.flags() 466 symlink = 'l' in fcd.flags() + fco.flags()
481 precheck = None 483 precheck = None
482 484
483 toolconf = tool, toolpath, binary, symlink 485 toolconf = tool, toolpath, binary, symlink
484 486
485 if mergetype == nomerge: 487 if mergetype == nomerge:
486 return func(repo, mynode, orig, fcd, fco, fca, toolconf) 488 return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
487 489
488 if orig != fco.path(): 490 if orig != fco.path():
489 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))
490 else: 492 else:
491 ui.status(_("merging %s\n") % fd) 493 ui.status(_("merging %s\n") % fd)
494 496
495 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, 497 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
496 toolconf): 498 toolconf):
497 if onfailure: 499 if onfailure:
498 ui.warn(onfailure % fd) 500 ui.warn(onfailure % fd)
499 return 1 501 return True, 1
500 502
501 a = repo.wjoin(fd) 503 a = repo.wjoin(fd)
502 b = temp("base", fca) 504 b = temp("base", fca)
503 c = temp("other", fco) 505 c = temp("other", fco)
504 back = a + ".orig" 506 back = a + ".orig"
527 529
528 if r: 530 if r:
529 if onfailure: 531 if onfailure:
530 ui.warn(onfailure % fd) 532 ui.warn(onfailure % fd)
531 533
532 return r 534 return True, r
533 finally: 535 finally:
534 if not r: 536 if not r:
535 util.unlink(back) 537 util.unlink(back)
536 util.unlink(b) 538 util.unlink(b)
537 util.unlink(c) 539 util.unlink(c)