comparison mercurial/discovery.py @ 32706:993f58db2045

headssummary: directly feed the function with the 'pushop' object Our goal is to be able to perform the post processing directly into the '_headssummary' function. However before this patch the '_headsummary' function only had access to repo, remote, outgoing while the '_postprocessobsolete' function takes a 'pushop' object. Experience shows that having the 'pushop' object helps extensions so we update '_headssummary' to take a pushop object as argument.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 29 May 2017 10:56:00 +0200
parents 70a020daf0b9
children 32c8f98aebf4
comparison
equal deleted inserted replaced
32705:70a020daf0b9 32706:993f58db2045
180 commonheads = set(og.commonheads) 180 commonheads = set(og.commonheads)
181 og.missingheads = [h for h in og.missingheads if h not in commonheads] 181 og.missingheads = [h for h in og.missingheads if h not in commonheads]
182 182
183 return og 183 return og
184 184
185 def _headssummary(repo, remote, outgoing): 185 def _headssummary(pushop):
186 """compute a summary of branch and heads status before and after push 186 """compute a summary of branch and heads status before and after push
187 187
188 return {'branch': ([remoteheads], [newheads], [unsyncedheads])} mapping 188 return {'branch': ([remoteheads], [newheads], [unsyncedheads])} mapping
189 189
190 - branch: the branch name 190 - branch: the branch name
191 - remoteheads: the list of remote heads known locally 191 - remoteheads: the list of remote heads known locally
192 None if the branch is new 192 None if the branch is new
193 - newheads: the new remote heads (known locally) with outgoing pushed 193 - newheads: the new remote heads (known locally) with outgoing pushed
194 - unsyncedheads: the list of remote heads unknown locally. 194 - unsyncedheads: the list of remote heads unknown locally.
195 """ 195 """
196 repo = pushop.repo.unfiltered()
197 remote = pushop.remote
198 outgoing = pushop.outgoing
196 cl = repo.changelog 199 cl = repo.changelog
197 headssum = {} 200 headssum = {}
198 # A. Create set of branches involved in the push. 201 # A. Create set of branches involved in the push.
199 branches = set(repo[n].branch() for n in outgoing.missing) 202 branches = set(repo[n].branch() for n in outgoing.missing)
200 remotemap = remote.branchmap() 203 remotemap = remote.branchmap()
309 if remoteheads == [nullid]: 312 if remoteheads == [nullid]:
310 # remote is empty, nothing to check. 313 # remote is empty, nothing to check.
311 return 314 return
312 315
313 if remote.capable('branchmap'): 316 if remote.capable('branchmap'):
314 headssum = _headssummary(repo, remote, outgoing) 317 headssum = _headssummary(pushop)
315 else: 318 else:
316 headssum = _oldheadssummary(repo, remoteheads, outgoing, inc) 319 headssum = _oldheadssummary(repo, remoteheads, outgoing, inc)
317 newbranches = [branch for branch, heads in headssum.iteritems() 320 newbranches = [branch for branch, heads in headssum.iteritems()
318 if heads[0] is None] 321 if heads[0] is None]
319 # 1. Check for new branches on the remote. 322 # 1. Check for new branches on the remote.