##// END OF EJS Templates
phabricator: try to fetch differential revisions in batch...
Jun Wu -
r33269:ead67493 default
parent child Browse files
Show More
@@ -358,14 +358,34 b' def querydrev(repo, params, stack=False)'
358 order that the latter ones depend on the former ones. Otherwise, return a
358 order that the latter ones depend on the former ones. Otherwise, return a
359 list of a unique "Differential Revision dict".
359 list of a unique "Differential Revision dict".
360 """
360 """
361 prefetched = {} # {id or phid: drev}
362 def fetch(params):
363 """params -> single drev or None"""
364 key = (params.get(r'ids') or params.get(r'phids') or [None])[0]
365 if key in prefetched:
366 return prefetched[key]
367 # Otherwise, send the request. If we're fetching a stack, be smarter
368 # and fetch more ids in one batch, even if it could be unnecessary.
369 batchparams = params
370 if stack and len(params.get(r'ids', [])) == 1:
371 i = int(params[r'ids'][0])
372 # developer config: phabricator.batchsize
373 batchsize = repo.ui.configint('phabricator', 'batchsize', 12)
374 batchparams = {'ids': range(max(1, i - batchsize), i + 1)}
375 drevs = callconduit(repo, 'differential.query', batchparams)
376 # Fill prefetched with the result
377 for drev in drevs:
378 prefetched[drev[r'phid']] = drev
379 prefetched[int(drev[r'id'])] = drev
380 if key not in prefetched:
381 raise error.Abort(_('cannot get Differential Revision %r') % params)
382 return prefetched[key]
383
361 result = []
384 result = []
362 queue = [params]
385 queue = [params]
363 while queue:
386 while queue:
364 params = queue.pop()
387 params = queue.pop()
365 drevs = callconduit(repo, 'differential.query', params)
388 drev = fetch(params)
366 if len(drevs) != 1:
367 raise error.Abort(_('cannot get Differential Revision %r') % params)
368 drev = drevs[0]
369 result.append(drev)
389 result.append(drev)
370 if stack:
390 if stack:
371 auxiliary = drev.get(r'auxiliary', {})
391 auxiliary = drev.get(r'auxiliary', {})
General Comments 0
You need to be logged in to leave comments. Login now