Mercurial > hg
changeset 33268:85391b95961d
phabricator: avoid calling differential.getcommitmessage
Previously, we call differential.getcommitmessage API to get commit
messages. Now we read that from "Differential Revision" object fetched
via "differential.query" API.
This removes one API call per patch.
author | Jun Wu <quark@fb.com> |
---|---|
date | Tue, 04 Jul 2017 16:36:48 -0700 |
parents | dba9f88659a3 |
children | ead6749354e1 |
files | contrib/phabricator.py |
diffstat | 1 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/phabricator.py Tue Jul 04 16:36:48 2017 -0700 +++ b/contrib/phabricator.py Tue Jul 04 16:36:48 2017 -0700 @@ -307,8 +307,6 @@ ctx.description().split('\n')[0])) lastrevid = newrevid -_summaryre = re.compile('^Summary:\s*', re.M) - # Map from "hg:meta" keys to header understood by "hg import". The order is # consistent with "hg export" output. _metanamemap = util.sortdict([(r'user', 'User'), (r'date', 'Date'), @@ -377,6 +375,20 @@ result.reverse() return result +def getdescfromdrev(drev): + """get description (commit message) from "Differential Revision" + + This is similar to differential.getcommitmessage API. But we only care + about limited fields: title, summary, test plan, and URL. + """ + title = drev[r'title'] + summary = drev[r'summary'].rstrip() + testplan = drev[r'testPlan'].rstrip() + if testplan: + testplan = 'Test Plan:\n%s' % testplan + uri = 'Differential Revision: %s' % drev[r'uri'] + return '\n\n'.join(filter(None, [title, summary, testplan, uri])) + def readpatch(repo, params, write, stack=False): """generate plain-text patch readable by 'hg import' @@ -396,13 +408,9 @@ diffid = max(int(v) for v in drev[r'diffs']) body = callconduit(repo, 'differential.getrawdiff', {'diffID': diffid}) - desc = callconduit(repo, 'differential.getcommitmessage', - {'revision_id': drev[r'id']}) + desc = getdescfromdrev(drev) header = '# HG changeset patch\n' - # Remove potential empty "Summary:" - desc = _summaryre.sub('', desc) - # Try to preserve metadata from hg:meta property. Write hg patch # headers that can be read by the "import" command. See patchheadermap # and extract in mercurial/patch.py for supported headers.