comparison mercurial/destutil.py @ 26724:7fc759c0c430

destupdate: extract logic based on bookmarks in its own function One of the main goal of having consolidated destination function is to allow extension to play with this logic. We extract sub logic to make is wrapping more practical.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 15 Oct 2015 02:27:30 +0100
parents 52d08a93de1f
children bde739aced83
comparison
equal deleted inserted replaced
26723:52d08a93de1f 26724:7fc759c0c430
74 node = repo.revs('max(%ln)', successors).first() 74 node = repo.revs('max(%ln)', successors).first()
75 if bookmarks.isactivewdirparent(repo): 75 if bookmarks.isactivewdirparent(repo):
76 movemark = repo['.'].node() 76 movemark = repo['.'].node()
77 return node, movemark, None 77 return node, movemark, None
78 78
79 def _destupdatebook(repo, clean, check):
80 """decide on an update destination from active bookmark"""
81 # we also move the active bookmark, if any
82 activemark = None
83 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
84 if node is not None:
85 activemark = node
86 return node, movemark, activemark
87
79 def destupdate(repo, clean=False, check=False): 88 def destupdate(repo, clean=False, check=False):
80 """destination for bare update operation 89 """destination for bare update operation
81 90
82 return (rev, movemark, activemark) 91 return (rev, movemark, activemark)
83 92
89 node = None 98 node = None
90 wc = repo[None] 99 wc = repo[None]
91 movemark = activemark = None 100 movemark = activemark = None
92 101
93 node, movemark, activemark = _destupdateobs(repo, clean, check) 102 node, movemark, activemark = _destupdateobs(repo, clean, check)
103 if node is None:
104 node, movemark, activemark = _destupdatebook(repo, clean, check)
94 105
95 if node is None: 106 if node is None:
96 # we also move the active bookmark, if any
97 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
98 if node is not None:
99 activemark = node
100
101 if node is None: 107 if node is None:
102 try: 108 try:
103 node = repo.branchtip(wc.branch()) 109 node = repo.branchtip(wc.branch())
104 except error.RepoLookupError: 110 except error.RepoLookupError:
105 if wc.branch() == 'default': # no default branch! 111 if wc.branch() == 'default': # no default branch!