comparison mercurial/destutil.py @ 26725:bde739aced83

destupdate: extract logic based on branch 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:33:09 +0100
parents 7fc759c0c430
children 8e6649616699
comparison
equal deleted inserted replaced
26724:7fc759c0c430 26725:bde739aced83
83 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None) 83 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
84 if node is not None: 84 if node is not None:
85 activemark = node 85 activemark = node
86 return node, movemark, activemark 86 return node, movemark, activemark
87 87
88 def _destupdatebranch(repo, clean, check):
89 """decide on an update destination from current branch"""
90 wc = repo[None]
91 movemark = node = None
92 try:
93 node = repo.branchtip(wc.branch())
94 if bookmarks.isactivewdirparent(repo):
95 movemark = repo['.'].node()
96 except error.RepoLookupError:
97 if wc.branch() == 'default': # no default branch!
98 node = repo.lookup('tip') # update to tip
99 else:
100 raise error.Abort(_("branch %s not found") % wc.branch())
101 return node, movemark, None
102
88 def destupdate(repo, clean=False, check=False): 103 def destupdate(repo, clean=False, check=False):
89 """destination for bare update operation 104 """destination for bare update operation
90 105
91 return (rev, movemark, activemark) 106 return (rev, movemark, activemark)
92 107
94 - movemark: node to move the active bookmark from 109 - movemark: node to move the active bookmark from
95 (cf bookmark.calculate update), 110 (cf bookmark.calculate update),
96 - activemark: a bookmark to activate at the end of the update. 111 - activemark: a bookmark to activate at the end of the update.
97 """ 112 """
98 node = None 113 node = None
99 wc = repo[None]
100 movemark = activemark = None 114 movemark = activemark = None
101 115
102 node, movemark, activemark = _destupdateobs(repo, clean, check) 116 node, movemark, activemark = _destupdateobs(repo, clean, check)
103 if node is None: 117 if node is None:
104 node, movemark, activemark = _destupdatebook(repo, clean, check) 118 node, movemark, activemark = _destupdatebook(repo, clean, check)
105
106 if node is None: 119 if node is None:
107 if node is None: 120 node, movemark, activemark = _destupdatebranch(repo, clean, check)
108 try:
109 node = repo.branchtip(wc.branch())
110 except error.RepoLookupError:
111 if wc.branch() == 'default': # no default branch!
112 node = repo.lookup('tip') # update to tip
113 else:
114 raise error.Abort(_("branch %s not found") % wc.branch())
115 rev = repo[node].rev() 121 rev = repo[node].rev()
116 122
117 _destupdatevalidate(repo, rev, clean, check) 123 _destupdatevalidate(repo, rev, clean, check)
118 124
119 return rev, movemark, activemark 125 return rev, movemark, activemark