Mercurial > public > mercurial-scm > hg
comparison hgext/phabricator.py @ 44419:df8053082364
phabricator: pass ui instead of repo to `querydrev()`
Also not a repository operation.
Differential Revision: https://phab.mercurial-scm.org/D8206
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 17 Feb 2020 13:08:01 -0500 |
parents | 41217dfa7a6d |
children | ddcb51390891 |
comparison
equal
deleted
inserted
replaced
44418:41217dfa7a6d | 44419:df8053082364 |
---|---|
1181 local=True, | 1181 local=True, |
1182 ) | 1182 ) |
1183 else: | 1183 else: |
1184 # Nothing changed. But still set "newrevphid" so the next revision | 1184 # Nothing changed. But still set "newrevphid" so the next revision |
1185 # could depend on this one and "newrevid" for the summary line. | 1185 # could depend on this one and "newrevid" for the summary line. |
1186 newrevphid = querydrev(repo, b'%d' % revid)[0][b'phid'] | 1186 newrevphid = querydrev(repo.ui, b'%d' % revid)[0][b'phid'] |
1187 newrevid = revid | 1187 newrevid = revid |
1188 action = b'skipped' | 1188 action = b'skipped' |
1189 | 1189 |
1190 actiondesc = ui.label( | 1190 actiondesc = ui.label( |
1191 { | 1191 { |
1396 drevs.update(r) | 1396 drevs.update(r) |
1397 ancestordrevs.update(a) | 1397 ancestordrevs.update(a) |
1398 return drevs, ancestordrevs | 1398 return drevs, ancestordrevs |
1399 | 1399 |
1400 | 1400 |
1401 def querydrev(repo, spec): | 1401 def querydrev(ui, spec): |
1402 """return a list of "Differential Revision" dicts | 1402 """return a list of "Differential Revision" dicts |
1403 | 1403 |
1404 spec is a string using a simple query language, see docstring in phabread | 1404 spec is a string using a simple query language, see docstring in phabread |
1405 for details. | 1405 for details. |
1406 | 1406 |
1447 def fetch(params): | 1447 def fetch(params): |
1448 """params -> single drev or None""" | 1448 """params -> single drev or None""" |
1449 key = (params.get(b'ids') or params.get(b'phids') or [None])[0] | 1449 key = (params.get(b'ids') or params.get(b'phids') or [None])[0] |
1450 if key in prefetched: | 1450 if key in prefetched: |
1451 return prefetched[key] | 1451 return prefetched[key] |
1452 drevs = callconduit(repo.ui, b'differential.query', params) | 1452 drevs = callconduit(ui, b'differential.query', params) |
1453 # Fill prefetched with the result | 1453 # Fill prefetched with the result |
1454 for drev in drevs: | 1454 for drev in drevs: |
1455 prefetched[drev[b'phid']] = drev | 1455 prefetched[drev[b'phid']] = drev |
1456 prefetched[int(drev[b'id'])] = drev | 1456 prefetched[int(drev[b'id'])] = drev |
1457 if key not in prefetched: | 1457 if key not in prefetched: |
1484 | 1484 |
1485 tree = _parse(spec) | 1485 tree = _parse(spec) |
1486 drevs, ancestordrevs = _prefetchdrevs(tree) | 1486 drevs, ancestordrevs = _prefetchdrevs(tree) |
1487 | 1487 |
1488 # developer config: phabricator.batchsize | 1488 # developer config: phabricator.batchsize |
1489 batchsize = repo.ui.configint(b'phabricator', b'batchsize') | 1489 batchsize = ui.configint(b'phabricator', b'batchsize') |
1490 | 1490 |
1491 # Prefetch Differential Revisions in batch | 1491 # Prefetch Differential Revisions in batch |
1492 tofetch = set(drevs) | 1492 tofetch = set(drevs) |
1493 for r in ancestordrevs: | 1493 for r in ancestordrevs: |
1494 tofetch.update(range(max(1, r - batchsize), r + 1)) | 1494 tofetch.update(range(max(1, r - batchsize), r + 1)) |
1666 It is equivalent to the ``:`` operator. | 1666 It is equivalent to the ``:`` operator. |
1667 """ | 1667 """ |
1668 opts = pycompat.byteskwargs(opts) | 1668 opts = pycompat.byteskwargs(opts) |
1669 if opts.get(b'stack'): | 1669 if opts.get(b'stack'): |
1670 spec = b':(%s)' % spec | 1670 spec = b':(%s)' % spec |
1671 drevs = querydrev(repo, spec) | 1671 drevs = querydrev(repo.ui, spec) |
1672 readpatch(repo.ui, drevs, ui.write) | 1672 readpatch(repo.ui, drevs, ui.write) |
1673 | 1673 |
1674 | 1674 |
1675 @vcrcommand( | 1675 @vcrcommand( |
1676 b'phabupdate', | 1676 b'phabupdate', |
1696 | 1696 |
1697 actions = [] | 1697 actions = [] |
1698 for f in flags: | 1698 for f in flags: |
1699 actions.append({b'type': f, b'value': True}) | 1699 actions.append({b'type': f, b'value': True}) |
1700 | 1700 |
1701 drevs = querydrev(repo, spec) | 1701 drevs = querydrev(repo.ui, spec) |
1702 for i, drev in enumerate(drevs): | 1702 for i, drev in enumerate(drevs): |
1703 if i + 1 == len(drevs) and opts.get(b'comment'): | 1703 if i + 1 == len(drevs) and opts.get(b'comment'): |
1704 actions.append({b'type': b'comment', b'value': opts[b'comment']}) | 1704 actions.append({b'type': b'comment', b'value': opts[b'comment']}) |
1705 if actions: | 1705 if actions: |
1706 params = { | 1706 params = { |