Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 31166:fad5e299cfc7
update: accept --merge to allow merging across topo branches (issue5125)
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 13 Feb 2017 12:58:37 -0800 |
parents | 23080c03a604 |
children | 696e321b304d |
comparison
equal
deleted
inserted
replaced
31165:81250d377611 | 31166:fad5e299cfc7 |
---|---|
689 if quietempty and not any(stats): | 689 if quietempty and not any(stats): |
690 return | 690 return |
691 repo.ui.status(_("%d files updated, %d files merged, " | 691 repo.ui.status(_("%d files updated, %d files merged, " |
692 "%d files removed, %d files unresolved\n") % stats) | 692 "%d files removed, %d files unresolved\n") % stats) |
693 | 693 |
694 def updaterepo(repo, node, overwrite): | 694 def updaterepo(repo, node, overwrite, updatecheck=None): |
695 """Update the working directory to node. | 695 """Update the working directory to node. |
696 | 696 |
697 When overwrite is set, changes are clobbered, merged else | 697 When overwrite is set, changes are clobbered, merged else |
698 | 698 |
699 returns stats (see pydoc mercurial.merge.applyupdates)""" | 699 returns stats (see pydoc mercurial.merge.applyupdates)""" |
700 return mergemod.update(repo, node, False, overwrite, | 700 return mergemod.update(repo, node, False, overwrite, |
701 labels=['working copy', 'destination']) | 701 labels=['working copy', 'destination'], |
702 | 702 updatecheck=updatecheck) |
703 def update(repo, node, quietempty=False): | 703 |
704 """update the working directory to node, merging linear changes""" | 704 def update(repo, node, quietempty=False, updatecheck=None): |
705 stats = updaterepo(repo, node, False) | 705 """update the working directory to node""" |
706 stats = updaterepo(repo, node, False, updatecheck=updatecheck) | |
706 _showstats(repo, stats, quietempty) | 707 _showstats(repo, stats, quietempty) |
707 if stats[3]: | 708 if stats[3]: |
708 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) | 709 repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) |
709 return stats[3] > 0 | 710 return stats[3] > 0 |
710 | 711 |
720 return stats[3] > 0 | 721 return stats[3] > 0 |
721 | 722 |
722 # naming conflict in updatetotally() | 723 # naming conflict in updatetotally() |
723 _clean = clean | 724 _clean = clean |
724 | 725 |
725 def updatetotally(ui, repo, checkout, brev, clean=False, check=False): | 726 def updatetotally(ui, repo, checkout, brev, clean=False, updatecheck=None): |
726 """Update the working directory with extra care for non-file components | 727 """Update the working directory with extra care for non-file components |
727 | 728 |
728 This takes care of non-file components below: | 729 This takes care of non-file components below: |
729 | 730 |
730 :bookmark: might be advanced or (in)activated | 731 :bookmark: might be advanced or (in)activated |
732 This takes arguments below: | 733 This takes arguments below: |
733 | 734 |
734 :checkout: to which revision the working directory is updated | 735 :checkout: to which revision the working directory is updated |
735 :brev: a name, which might be a bookmark to be activated after updating | 736 :brev: a name, which might be a bookmark to be activated after updating |
736 :clean: whether changes in the working directory can be discarded | 737 :clean: whether changes in the working directory can be discarded |
737 :check: whether changes in the working directory should be checked | 738 :updatecheck: how to deal with a dirty working directory |
739 | |
740 Valid values for updatecheck are (None => linear): | |
741 | |
742 * abort: abort if the working directory is dirty | |
743 * none: don't check (merge working directory changes into destination) | |
744 * linear: check that update is linear before merging working directory | |
745 changes into destination | |
738 | 746 |
739 This returns whether conflict is detected at updating or not. | 747 This returns whether conflict is detected at updating or not. |
740 """ | 748 """ |
749 if updatecheck is None: | |
750 updatecheck = 'linear' | |
741 with repo.wlock(): | 751 with repo.wlock(): |
742 movemarkfrom = None | 752 movemarkfrom = None |
743 warndest = False | 753 warndest = False |
744 if checkout is None: | 754 if checkout is None: |
745 updata = destutil.destupdate(repo, clean=clean) | 755 updata = destutil.destupdate(repo, clean=clean) |
747 warndest = True | 757 warndest = True |
748 | 758 |
749 if clean: | 759 if clean: |
750 ret = _clean(repo, checkout) | 760 ret = _clean(repo, checkout) |
751 else: | 761 else: |
752 if check: | 762 if updatecheck == 'abort': |
753 cmdutil.bailifchanged(repo, merge=False) | 763 cmdutil.bailifchanged(repo, merge=False) |
754 ret = _update(repo, checkout) | 764 updatecheck = 'none' |
765 ret = _update(repo, checkout, updatecheck=updatecheck) | |
755 | 766 |
756 if not ret and movemarkfrom: | 767 if not ret and movemarkfrom: |
757 if movemarkfrom == repo['.'].node(): | 768 if movemarkfrom == repo['.'].node(): |
758 pass # no-op update | 769 pass # no-op update |
759 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()): | 770 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()): |