##// END OF EJS Templates
commands: centralize code to update with extra care for non-file components...
FUJIWARA Katsunori -
r28501:66513f6c default
parent child Browse files
Show More
@@ -5618,35 +5618,12 b' def postincoming(ui, repo, modheads, opt'
5618 5618 if modheads == 0:
5619 5619 return
5620 5620 if optupdate:
5621 warndest = False
5622 5621 try:
5623 movemarkfrom = None
5624 if not checkout:
5625 warndest = True
5626 updata = destutil.destupdate(repo)
5627 checkout, movemarkfrom, brev = updata
5628 ret = hg.update(repo, checkout)
5629 if warndest:
5630 destutil.statusotherdests(ui, repo)
5622 return hg.updatetotally(ui, repo, checkout, brev)
5631 5623 except error.UpdateAbort as inst:
5632 5624 msg = _("not updating: %s") % str(inst)
5633 5625 hint = inst.hint
5634 5626 raise error.UpdateAbort(msg, hint=hint)
5635 if not ret and movemarkfrom:
5636 if movemarkfrom == repo['.'].node():
5637 pass # no-op update
5638 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5639 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5640 elif brev in repo._bookmarks:
5641 if brev != repo._activebookmark:
5642 ui.status(_("(activating bookmark %s)\n") % brev)
5643 bookmarks.activate(repo, brev)
5644 elif brev:
5645 if repo._activebookmark:
5646 ui.status(_("(leaving bookmark %s)\n") %
5647 repo._activebookmark)
5648 bookmarks.deactivate(repo)
5649 return ret
5650 5627 if modheads > 1:
5651 5628 currentbranchheads = len(repo.branchheads())
5652 5629 if currentbranchheads == modheads:
@@ -7071,7 +7048,6 b' def update(ui, repo, node=None, rev=None'
7071 7048
7072 7049 Returns 0 on success, 1 if there are unresolved files.
7073 7050 """
7074 movemarkfrom = None
7075 7051 if rev and node:
7076 7052 raise error.Abort(_("please specify just one revision"))
7077 7053
@@ -7084,8 +7060,6 b' def update(ui, repo, node=None, rev=None'
7084 7060 if check and clean:
7085 7061 raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
7086 7062
7087 warndest = False
7088
7089 7063 with repo.wlock():
7090 7064 cmdutil.clearunfinished(repo)
7091 7065
@@ -7098,40 +7072,10 b' def update(ui, repo, node=None, rev=None'
7098 7072
7099 7073 if check:
7100 7074 cmdutil.bailifchanged(repo, merge=False)
7101 if rev is None:
7102 updata = destutil.destupdate(repo, clean=clean, check=check)
7103 rev, movemarkfrom, brev = updata
7104 warndest = True
7105 7075
7106 7076 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
7107 7077
7108 if clean:
7109 ret = hg.clean(repo, rev)
7110 else:
7111 ret = hg.update(repo, rev)
7112
7113 if not ret and movemarkfrom:
7114 if movemarkfrom == repo['.'].node():
7115 pass # no-op update
7116 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
7117 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
7118 else:
7119 # this can happen with a non-linear update
7120 ui.status(_("(leaving bookmark %s)\n") %
7121 repo._activebookmark)
7122 bookmarks.deactivate(repo)
7123 elif brev in repo._bookmarks:
7124 if brev != repo._activebookmark:
7125 ui.status(_("(activating bookmark %s)\n") % brev)
7126 bookmarks.activate(repo, brev)
7127 elif brev:
7128 if repo._activebookmark:
7129 ui.status(_("(leaving bookmark %s)\n") %
7130 repo._activebookmark)
7131 bookmarks.deactivate(repo)
7132 if warndest:
7133 destutil.statusotherdests(ui, repo)
7134 return ret
7078 return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check)
7135 7079
7136 7080 @command('verify', [])
7137 7081 def verify(ui, repo):
@@ -19,6 +19,7 b' from . import ('
19 19 bookmarks,
20 20 bundlerepo,
21 21 cmdutil,
22 destutil,
22 23 discovery,
23 24 error,
24 25 exchange,
@@ -694,6 +695,63 b' def clean(repo, node, show_stats=True, q'
694 695 _showstats(repo, stats, quietempty)
695 696 return stats[3] > 0
696 697
698 # naming conflict in updatetotally()
699 _clean = clean
700
701 def updatetotally(ui, repo, checkout, brev, clean=False, check=False):
702 """Update the working directory with extra care for non-file components
703
704 This takes care of non-file components below:
705
706 :bookmark: might be advanced or (in)activated
707
708 This takes arguments below:
709
710 :checkout: to which revision the working directory is updated
711 :brev: a name, which might be a bookmark to be activated after updating
712 :clean: whether changes in the working directory can be discarded
713 :check: whether changes in the working directory should be checked
714
715 This returns whether conflict is detected at updating or not.
716 """
717 if True:
718 movemarkfrom = None
719 warndest = False
720 if checkout is None:
721 updata = destutil.destupdate(repo, clean=clean, check=check)
722 checkout, movemarkfrom, brev = updata
723 warndest = True
724
725 if clean:
726 ret = _clean(repo, checkout)
727 else:
728 ret = _update(repo, checkout)
729
730 if not ret and movemarkfrom:
731 if movemarkfrom == repo['.'].node():
732 pass # no-op update
733 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
734 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
735 else:
736 # this can happen with a non-linear update
737 ui.status(_("(leaving bookmark %s)\n") %
738 repo._activebookmark)
739 bookmarks.deactivate(repo)
740 elif brev in repo._bookmarks:
741 if brev != repo._activebookmark:
742 ui.status(_("(activating bookmark %s)\n") % brev)
743 bookmarks.activate(repo, brev)
744 elif brev:
745 if repo._activebookmark:
746 ui.status(_("(leaving bookmark %s)\n") %
747 repo._activebookmark)
748 bookmarks.deactivate(repo)
749
750 if warndest:
751 destutil.statusotherdests(ui, repo)
752
753 return ret
754
697 755 def merge(repo, node, force=None, remind=True, mergeforce=False):
698 756 """Branch merge with node, resolving changes. Return true if any
699 757 unresolved conflicts."""
General Comments 0
You need to be logged in to leave comments. Login now