Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filemerge.py @ 26575:d60815664c34
filemerge: move post-merge checks into a separate function
This makes the overall filemerge function easier to follow, and makes upcoming
work simpler.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 07 Oct 2015 23:35:30 -0700 |
parents | f82cb7dffb49 |
children | fb388aa26453 |
comparison
equal
deleted
inserted
replaced
26574:f82cb7dffb49 | 26575:d60815664c34 |
---|---|
519 needcheck = False | 519 needcheck = False |
520 else: | 520 else: |
521 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, | 521 needcheck, r = func(repo, mynode, orig, fcd, fco, fca, toolconf, |
522 files, labels=labels) | 522 files, labels=labels) |
523 | 523 |
524 if not needcheck: | 524 if needcheck: |
525 if r: | 525 r = _check(r, ui, tool, fcd, files) |
526 if onfailure: | |
527 ui.warn(onfailure % fd) | |
528 else: | |
529 util.unlink(back) | |
530 | |
531 util.unlink(b) | |
532 util.unlink(c) | |
533 return r | |
534 | |
535 if not r and (_toolbool(ui, tool, "checkconflicts") or | |
536 'conflicts' in _toollist(ui, tool, "check")): | |
537 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), | |
538 re.MULTILINE): | |
539 r = 1 | |
540 | |
541 checked = False | |
542 if 'prompt' in _toollist(ui, tool, "check"): | |
543 checked = True | |
544 if ui.promptchoice(_("was merge of '%s' successful (yn)?" | |
545 "$$ &Yes $$ &No") % fd, 1): | |
546 r = 1 | |
547 | |
548 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | |
549 'changed' in | |
550 _toollist(ui, tool, "check")): | |
551 if filecmp.cmp(a, back): | |
552 if ui.promptchoice(_(" output file %s appears unchanged\n" | |
553 "was merge successful (yn)?" | |
554 "$$ &Yes $$ &No") % fd, 1): | |
555 r = 1 | |
556 | |
557 if _toolbool(ui, tool, "fixeol"): | |
558 _matcheol(a, back) | |
559 | 526 |
560 if r: | 527 if r: |
561 if onfailure: | 528 if onfailure: |
562 ui.warn(onfailure % fd) | 529 ui.warn(onfailure % fd) |
563 else: | 530 else: |
565 | 532 |
566 util.unlink(b) | 533 util.unlink(b) |
567 util.unlink(c) | 534 util.unlink(c) |
568 return r | 535 return r |
569 | 536 |
537 def _check(r, ui, tool, fcd, files): | |
538 fd = fcd.path() | |
539 a, b, c, back = files | |
540 | |
541 if not r and (_toolbool(ui, tool, "checkconflicts") or | |
542 'conflicts' in _toollist(ui, tool, "check")): | |
543 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), | |
544 re.MULTILINE): | |
545 r = 1 | |
546 | |
547 checked = False | |
548 if 'prompt' in _toollist(ui, tool, "check"): | |
549 checked = True | |
550 if ui.promptchoice(_("was merge of '%s' successful (yn)?" | |
551 "$$ &Yes $$ &No") % fd, 1): | |
552 r = 1 | |
553 | |
554 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or | |
555 'changed' in | |
556 _toollist(ui, tool, "check")): | |
557 if filecmp.cmp(a, back): | |
558 if ui.promptchoice(_(" output file %s appears unchanged\n" | |
559 "was merge successful (yn)?" | |
560 "$$ &Yes $$ &No") % fd, 1): | |
561 r = 1 | |
562 | |
563 if _toolbool(ui, tool, "fixeol"): | |
564 _matcheol(a, back) | |
565 | |
566 return r | |
567 | |
570 # tell hggettext to extract docstrings from these functions: | 568 # tell hggettext to extract docstrings from these functions: |
571 i18nfunctions = internals.values() | 569 i18nfunctions = internals.values() |