if len(flags) > 1: raise error.Abort(_(b'%s cannot be used together') % b', '.join(flags)) actions = [] for f in flags: actions.append({b'type': f, b'value': b'true'}) drevs = querydrev(repo, spec) for i, drev in enumerate(drevs): if i + 1 == len(drevs) and opts.get(b'comment'): actions.append({b'type': b'comment', b'value': opts[b'comment']}) if actions: params = {b'objectIdentifier': drev[r'phid'], b'transactions': actions} callconduit(repo, b'differential.revision.edit', params) templatekeyword = registrar.templatekeyword() @templatekeyword(b'phabreview', requires={b'ctx'}) def template_review(context, mapping): """:phabreview: Object describing the review for this changeset. Has attributes `url` and `id`. """ ctx = context.resource(mapping, b'ctx') m = _differentialrevisiondescre.search(ctx.description()) if m: return { b'url': m.group(b'url'), b'id': b"D{}".format(m.group(b'id')), }
def _getpushinfo(repo, ctx, cache): if 'nodetopush' not in cache: nodetopush = {} for push in repo.pushlog.pushes(): for node in push.nodes: nodetopush[node] = push cache['nodetopush'] = nodetopush return cache['nodetopush'].get(ctx.hex(), (None, None, None, None)) keywords = {} templatekeyword = registrar.templatekeyword(keywords) @templatekeyword('pushid', requires={'repo', 'ctx', 'cache'}) def template_pushid(context, mapping): """:pushid: Integer. The unique identifier for the push that introduced this changeset. """ repo = context.resource(mapping, 'repo') ctx = context.resource(mapping, 'ctx') cache = context.resource(mapping, 'cache') pushid, who, when, nodes = _getpushinfo(repo, ctx, cache) return pushid