Mercurial > public > mercurial-scm > hg-stable
diff hgext/phabricator.py @ 42285:a4f7dceb07bf
phabricator: fallback to reading metadata from diff for phabread
Differential Revision: https://phab.mercurial-scm.org/D6301
author | Ian Moody <moz-ian@perix.co.uk> |
---|---|
date | Mon, 22 Apr 2019 18:55:26 +0100 |
parents | 9421d7e12888 |
children | 231334c1ee96 |
line wrap: on
line diff
--- a/hgext/phabricator.py Sat Apr 20 16:11:23 2019 +0100 +++ b/hgext/phabricator.py Mon Apr 22 18:55:26 2019 +0100 @@ -905,22 +905,31 @@ """ props = diff.get(b'properties') or {} meta = props.get(b'hg:meta') - if not meta and props.get(b'local:commits'): - commit = sorted(props[b'local:commits'].values())[0] - meta = {} - if b'author' in commit and b'authorEmail' in commit: - meta[b'user'] = b'%s <%s>' % (commit[b'author'], - commit[b'authorEmail']) - if b'time' in commit: - meta[b'date'] = b'%d 0' % commit[b'time'] - if b'branch' in commit: - meta[b'branch'] = commit[b'branch'] - node = commit.get(b'commit', commit.get(b'rev')) - if node: - meta[b'node'] = node - if len(commit.get(b'parents', ())) >= 1: - meta[b'parent'] = commit[b'parents'][0] - return meta or {} + if not meta: + if props.get(b'local:commits'): + commit = sorted(props[b'local:commits'].values())[0] + meta = {} + if b'author' in commit and b'authorEmail' in commit: + meta[b'user'] = b'%s <%s>' % (commit[b'author'], + commit[b'authorEmail']) + if b'time' in commit: + meta[b'date'] = b'%d 0' % commit[b'time'] + if b'branch' in commit: + meta[b'branch'] = commit[b'branch'] + node = commit.get(b'commit', commit.get(b'rev')) + if node: + meta[b'node'] = node + if len(commit.get(b'parents', ())) >= 1: + meta[b'parent'] = commit[b'parents'][0] + else: + meta = {} + if b'date' not in meta and b'dateCreated' in diff: + meta[b'date'] = b'%s 0' % diff[b'dateCreated'] + if b'branch' not in meta and diff.get(b'branch'): + meta[b'branch'] = diff[b'branch'] + if b'parent' not in meta and diff.get(b'sourceControlBaseRevision'): + meta[b'parent'] = diff[b'sourceControlBaseRevision'] + return meta def readpatch(repo, drevs, write): """generate plain-text patch readable by 'hg import'