D6299: phabricator: don't assume the existence of properties of local:commits
Kwan (Ian Moody)
phabricator at mercurial-scm.org
Mon Apr 22 15:52:58 UTC 2019
Kwan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Not all the properties are guaranteed to be there, so if we don't check first
we could die with a KeyError.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D6299
AFFECTED FILES
hgext/phabricator.py
CHANGE DETAILS
diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -907,11 +907,14 @@
meta = props.get(b'hg:meta')
if not meta and props.get(b'local:commits'):
commit = sorted(props[b'local:commits'].values())[0]
- meta = {
- b'date': b'%d 0' % commit[b'time'],
- b'node': commit[b'rev'],
- b'user': b'%s <%s>' % (commit[b'author'], commit[b'authorEmail']),
- }
+ 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'rev' in commit:
+ meta[b'node'] = commit[b'rev']
if len(commit.get(b'parents', ())) >= 1:
meta[b'parent'] = commit[b'parents'][0]
return meta or {}
To: Kwan, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list