Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 27034:86ede9eda252
filemerge: return whether the file was deleted
This is required for change/delete conflict resolution -- see previous patches
for more details.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 18 Nov 2015 14:22:52 -0800 |
parents | 089dab8794dc |
children | 63d6bc874dea |
comparison
equal
deleted
inserted
replaced
27033:089dab8794dc | 27034:86ede9eda252 |
---|---|
495 orig = original local filename before merge | 495 orig = original local filename before merge |
496 fco = other file context | 496 fco = other file context |
497 fca = ancestor file context | 497 fca = ancestor file context |
498 fcd = local file context for current/destination file | 498 fcd = local file context for current/destination file |
499 | 499 |
500 Returns whether the merge is complete, and the return value of the merge. | 500 Returns whether the merge is complete, the return value of the merge, and |
501 """ | 501 a boolean indicating whether the file was deleted from disk.""" |
502 | 502 |
503 def temp(prefix, ctx): | 503 def temp(prefix, ctx): |
504 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) | 504 pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) |
505 (fd, name) = tempfile.mkstemp(prefix=pre) | 505 (fd, name) = tempfile.mkstemp(prefix=pre) |
506 data = repo.wwritedata(ctx.path(), ctx.data()) | 506 data = repo.wwritedata(ctx.path(), ctx.data()) |
508 f.write(data) | 508 f.write(data) |
509 f.close() | 509 f.close() |
510 return name | 510 return name |
511 | 511 |
512 if not fco.cmp(fcd): # files identical? | 512 if not fco.cmp(fcd): # files identical? |
513 return True, None | 513 return True, None, False |
514 | 514 |
515 ui = repo.ui | 515 ui = repo.ui |
516 fd = fcd.path() | 516 fd = fcd.path() |
517 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() | 517 binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() |
518 symlink = 'l' in fcd.flags() + fco.flags() | 518 symlink = 'l' in fcd.flags() + fco.flags() |
536 | 536 |
537 toolconf = tool, toolpath, binary, symlink | 537 toolconf = tool, toolpath, binary, symlink |
538 | 538 |
539 if mergetype == nomerge: | 539 if mergetype == nomerge: |
540 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf) | 540 r, deleted = func(repo, mynode, orig, fcd, fco, fca, toolconf) |
541 return True, r | 541 return True, r, deleted |
542 | 542 |
543 if premerge: | 543 if premerge: |
544 if orig != fco.path(): | 544 if orig != fco.path(): |
545 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) | 545 ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) |
546 else: | 546 else: |
550 | 550 |
551 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, | 551 if precheck and not precheck(repo, mynode, orig, fcd, fco, fca, |
552 toolconf): | 552 toolconf): |
553 if onfailure: | 553 if onfailure: |
554 ui.warn(onfailure % fd) | 554 ui.warn(onfailure % fd) |
555 return True, 1 | 555 return True, 1, False |
556 | 556 |
557 a = repo.wjoin(fd) | 557 a = repo.wjoin(fd) |
558 b = temp("base", fca) | 558 b = temp("base", fca) |
559 c = temp("other", fco) | 559 c = temp("other", fco) |
560 back = cmdutil.origpath(ui, repo, a) | 560 back = cmdutil.origpath(ui, repo, a) |
571 labels = _formatlabels(repo, fcd, fco, fca, labels) | 571 labels = _formatlabels(repo, fcd, fco, fca, labels) |
572 | 572 |
573 if premerge and mergetype == fullmerge: | 573 if premerge and mergetype == fullmerge: |
574 r = _premerge(repo, toolconf, files, labels=labels) | 574 r = _premerge(repo, toolconf, files, labels=labels) |
575 # complete if premerge successful (r is 0) | 575 # complete if premerge successful (r is 0) |
576 return not r, r | 576 return not r, r, False |
577 | 577 |
578 needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca, | 578 needcheck, r, deleted = func(repo, mynode, orig, fcd, fco, fca, |
579 toolconf, files, labels=labels) | 579 toolconf, files, labels=labels) |
580 | 580 |
581 if needcheck: | 581 if needcheck: |
583 | 583 |
584 if r: | 584 if r: |
585 if onfailure: | 585 if onfailure: |
586 ui.warn(onfailure % fd) | 586 ui.warn(onfailure % fd) |
587 | 587 |
588 return True, r | 588 return True, r, deleted |
589 finally: | 589 finally: |
590 if not r: | 590 if not r: |
591 util.unlink(back) | 591 util.unlink(back) |
592 util.unlink(b) | 592 util.unlink(b) |
593 util.unlink(c) | 593 util.unlink(c) |