Mercurial > hg-stable
comparison mercurial/hg.py @ 28501:66513f6ca038
commands: centralize code to update with extra care for non-file components
This patch centralizes similar code paths to update the working
directory with extra care for non-file components (e.g. bookmark) into
newly added function updatetotally().
'if True' at the beginning of updatetotally() is redundant at this
patch, but useful to reduce amount of changes in subsequent patch.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 12 Mar 2016 04:35:42 +0900 |
parents | 549ff28a345f |
children | 138ec8835e63 |
comparison
equal
deleted
inserted
replaced
28500:2e1bceeea520 | 28501:66513f6ca038 |
---|---|
17 | 17 |
18 from . import ( | 18 from . import ( |
19 bookmarks, | 19 bookmarks, |
20 bundlerepo, | 20 bundlerepo, |
21 cmdutil, | 21 cmdutil, |
22 destutil, | |
22 discovery, | 23 discovery, |
23 error, | 24 error, |
24 exchange, | 25 exchange, |
25 extensions, | 26 extensions, |
26 httppeer, | 27 httppeer, |
692 util.unlinkpath(repo.join('graftstate'), ignoremissing=True) | 693 util.unlinkpath(repo.join('graftstate'), ignoremissing=True) |
693 if show_stats: | 694 if show_stats: |
694 _showstats(repo, stats, quietempty) | 695 _showstats(repo, stats, quietempty) |
695 return stats[3] > 0 | 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 def merge(repo, node, force=None, remind=True, mergeforce=False): | 755 def merge(repo, node, force=None, remind=True, mergeforce=False): |
698 """Branch merge with node, resolving changes. Return true if any | 756 """Branch merge with node, resolving changes. Return true if any |
699 unresolved conflicts.""" | 757 unresolved conflicts.""" |
700 stats = mergemod.update(repo, node, True, force, mergeforce=mergeforce) | 758 stats = mergemod.update(repo, node, True, force, mergeforce=mergeforce) |
701 _showstats(repo, stats) | 759 _showstats(repo, stats) |