comparison hgext3rd/pullbundle.py @ 5427:5b1011a5c824

pullbundle: compatibility with discovery.outgoing and ancestorsof in 5.5 outgoing.missingheads property and keyword argument to __init__() was renamed to ancestorsof.
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 21 Jul 2020 12:52:52 +0800
parents a4d081923c81
children fb543438704b
comparison
equal deleted inserted replaced
5426:86736040b0ec 5427:5b1011a5c824
188 missingrevs = set(rev(n) for n in outgoing.missing) 188 missingrevs = set(rev(n) for n in outgoing.missing)
189 if DEBUG: 189 if DEBUG:
190 ms = missingrevs.copy() 190 ms = missingrevs.copy()
191 ss = [] 191 ss = []
192 allslices = [] 192 allslices = []
193 missingheads = [rev(n) for n in sorted(outgoing.missingheads, reverse=True)] 193 # hg <= 5.4 (c93dd9d9f1e6)
194 if util.safehasattr(outgoing, 'ancestorsof'):
195 missingheads = outgoing.ancestorsof
196 else:
197 missingheads = outgoing.missingheads
198 missingheads = [rev(n) for n in sorted(missingheads, reverse=True)]
194 for head in missingheads: 199 for head in missingheads:
195 localslices = [] 200 localslices = []
196 localmissing = set(repo.revs(b'%ld and ::%d', missingrevs, head)) 201 localmissing = set(repo.revs(b'%ld and ::%d', missingrevs, head))
197 thisrunmissing = localmissing.copy() 202 thisrunmissing = localmissing.copy()
198 while localmissing: 203 while localmissing:
373 378
374 def poweroftwo(num): 379 def poweroftwo(num):
375 return num and not num & (num - 1) 380 return num and not num & (num - 1)
376 381
377 def outgoingfromnodes(repo, nodes): 382 def outgoingfromnodes(repo, nodes):
378 return discovery.outgoing(repo, 383 # hg <= 5.4 (c93dd9d9f1e6)
379 missingroots=nodes, 384 if r'ancestorsof' in discovery.outgoing.__init__.__code__.co_varnames:
380 missingheads=nodes) 385 return discovery.outgoing(repo, missingroots=nodes, ancestorsof=nodes)
386 else:
387 return discovery.outgoing(repo, missingroots=nodes, missingheads=nodes)
381 388
382 # changegroup part construction 389 # changegroup part construction
383 390
384 def _changegroupinfo(repo, nodes, source): 391 def _changegroupinfo(repo, nodes, source):
385 if repo.ui.verbose or source == b'bundle': 392 if repo.ui.verbose or source == b'bundle':