Also not a repository operation.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Also not a repository operation.
| Automatic diff as part of commit; lint not applicable. |
| Automatic diff as part of commit; unit tests not applicable. |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/phabricator.py (12 lines) |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 | ||
| Closed | mharbison72 |
| message=None, | message=None, | ||||
| user=None, | user=None, | ||||
| date=None, | date=None, | ||||
| local=True, | local=True, | ||||
| ) | ) | ||||
| else: | else: | ||||
| # Nothing changed. But still set "newrevphid" so the next revision | # Nothing changed. But still set "newrevphid" so the next revision | ||||
| # could depend on this one and "newrevid" for the summary line. | # could depend on this one and "newrevid" for the summary line. | ||||
| newrevphid = querydrev(repo, b'%d' % revid)[0][b'phid'] | newrevphid = querydrev(repo.ui, b'%d' % revid)[0][b'phid'] | ||||
| newrevid = revid | newrevid = revid | ||||
| action = b'skipped' | action = b'skipped' | ||||
| actiondesc = ui.label( | actiondesc = ui.label( | ||||
| { | { | ||||
| b'created': _(b'created'), | b'created': _(b'created'), | ||||
| b'skipped': _(b'skipped'), | b'skipped': _(b'skipped'), | ||||
| b'updated': _(b'updated'), | b'updated': _(b'updated'), | ||||
| else: | else: | ||||
| for t in tree[1:]: | for t in tree[1:]: | ||||
| r, a = _prefetchdrevs(t) | r, a = _prefetchdrevs(t) | ||||
| drevs.update(r) | drevs.update(r) | ||||
| ancestordrevs.update(a) | ancestordrevs.update(a) | ||||
| return drevs, ancestordrevs | return drevs, ancestordrevs | ||||
| def querydrev(repo, spec): | def querydrev(ui, spec): | ||||
| """return a list of "Differential Revision" dicts | """return a list of "Differential Revision" dicts | ||||
| spec is a string using a simple query language, see docstring in phabread | spec is a string using a simple query language, see docstring in phabread | ||||
| for details. | for details. | ||||
| A "Differential Revision dict" looks like: | A "Differential Revision dict" looks like: | ||||
| { | { | ||||
| # differential.diff.search because the former (and their output) are | # differential.diff.search because the former (and their output) are | ||||
| # frozen, and planned to be deprecated and removed. | # frozen, and planned to be deprecated and removed. | ||||
| def fetch(params): | def fetch(params): | ||||
| """params -> single drev or None""" | """params -> single drev or None""" | ||||
| key = (params.get(b'ids') or params.get(b'phids') or [None])[0] | key = (params.get(b'ids') or params.get(b'phids') or [None])[0] | ||||
| if key in prefetched: | if key in prefetched: | ||||
| return prefetched[key] | return prefetched[key] | ||||
| drevs = callconduit(repo.ui, b'differential.query', params) | drevs = callconduit(ui, b'differential.query', params) | ||||
| # Fill prefetched with the result | # Fill prefetched with the result | ||||
| for drev in drevs: | for drev in drevs: | ||||
| prefetched[drev[b'phid']] = drev | prefetched[drev[b'phid']] = drev | ||||
| prefetched[int(drev[b'id'])] = drev | prefetched[int(drev[b'id'])] = drev | ||||
| if key not in prefetched: | if key not in prefetched: | ||||
| raise error.Abort( | raise error.Abort( | ||||
| _(b'cannot get Differential Revision %r') % params | _(b'cannot get Differential Revision %r') % params | ||||
| ) | ) | ||||
| # Initialize prefetch cache | # Initialize prefetch cache | ||||
| prefetched = {} # {id or phid: drev} | prefetched = {} # {id or phid: drev} | ||||
| tree = _parse(spec) | tree = _parse(spec) | ||||
| drevs, ancestordrevs = _prefetchdrevs(tree) | drevs, ancestordrevs = _prefetchdrevs(tree) | ||||
| # developer config: phabricator.batchsize | # developer config: phabricator.batchsize | ||||
| batchsize = repo.ui.configint(b'phabricator', b'batchsize') | batchsize = ui.configint(b'phabricator', b'batchsize') | ||||
| # Prefetch Differential Revisions in batch | # Prefetch Differential Revisions in batch | ||||
| tofetch = set(drevs) | tofetch = set(drevs) | ||||
| for r in ancestordrevs: | for r in ancestordrevs: | ||||
| tofetch.update(range(max(1, r - batchsize), r + 1)) | tofetch.update(range(max(1, r - batchsize), r + 1)) | ||||
| if drevs: | if drevs: | ||||
| fetch({b'ids': list(tofetch)}) | fetch({b'ids': list(tofetch)}) | ||||
| validids = sorted(set(getstack(list(ancestordrevs))) | set(drevs)) | validids = sorted(set(getstack(list(ancestordrevs))) | set(drevs)) | ||||
| stack up to D9. | stack up to D9. | ||||
| If --stack is given, follow dependencies information and read all patches. | If --stack is given, follow dependencies information and read all patches. | ||||
| It is equivalent to the ``:`` operator. | It is equivalent to the ``:`` operator. | ||||
| """ | """ | ||||
| opts = pycompat.byteskwargs(opts) | opts = pycompat.byteskwargs(opts) | ||||
| if opts.get(b'stack'): | if opts.get(b'stack'): | ||||
| spec = b':(%s)' % spec | spec = b':(%s)' % spec | ||||
| drevs = querydrev(repo, spec) | drevs = querydrev(repo.ui, spec) | ||||
| readpatch(repo.ui, drevs, ui.write) | readpatch(repo.ui, drevs, ui.write) | ||||
| @vcrcommand( | @vcrcommand( | ||||
| b'phabupdate', | b'phabupdate', | ||||
| [ | [ | ||||
| (b'', b'accept', False, _(b'accept revisions')), | (b'', b'accept', False, _(b'accept revisions')), | ||||
| (b'', b'reject', False, _(b'reject revisions')), | (b'', b'reject', False, _(b'reject revisions')), | ||||
| flags = [n for n in b'accept reject abandon reclaim'.split() if opts.get(n)] | flags = [n for n in b'accept reject abandon reclaim'.split() if opts.get(n)] | ||||
| if len(flags) > 1: | if len(flags) > 1: | ||||
| raise error.Abort(_(b'%s cannot be used together') % b', '.join(flags)) | raise error.Abort(_(b'%s cannot be used together') % b', '.join(flags)) | ||||
| actions = [] | actions = [] | ||||
| for f in flags: | for f in flags: | ||||
| actions.append({b'type': f, b'value': True}) | actions.append({b'type': f, b'value': True}) | ||||
| drevs = querydrev(repo, spec) | drevs = querydrev(repo.ui, spec) | ||||
| for i, drev in enumerate(drevs): | for i, drev in enumerate(drevs): | ||||
| if i + 1 == len(drevs) and opts.get(b'comment'): | if i + 1 == len(drevs) and opts.get(b'comment'): | ||||
| actions.append({b'type': b'comment', b'value': opts[b'comment']}) | actions.append({b'type': b'comment', b'value': opts[b'comment']}) | ||||
| if actions: | if actions: | ||||
| params = { | params = { | ||||
| b'objectIdentifier': drev[b'phid'], | b'objectIdentifier': drev[b'phid'], | ||||
| b'transactions': actions, | b'transactions': actions, | ||||
| } | } | ||||