changeset 42199:6dd454e5b123

phabricator: don't assume the existence of properties of local:commits Not all the properties are guaranteed to be there, so if we don't check first we could die with a KeyError. Differential Revision: https://phab.mercurial-scm.org/D6299
author Ian Moody <moz-ian@perix.co.uk>
date Sat, 20 Apr 2019 17:22:35 +0100
parents d49ab47be8a6
children c4d96f4761d3
files hgext/phabricator.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Sat Apr 20 16:01:47 2019 +0100
+++ b/hgext/phabricator.py	Sat Apr 20 17:22:35 2019 +0100
@@ -905,11 +905,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 {}