Mercurial > hg
comparison hgext/phabricator.py @ 42257: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 |
comparison
equal
deleted
inserted
replaced
42256:9421d7e12888 | 42257:a4f7dceb07bf |
---|---|
903 Note: metadata extracted from "local:commits" will lose time zone | 903 Note: metadata extracted from "local:commits" will lose time zone |
904 information. | 904 information. |
905 """ | 905 """ |
906 props = diff.get(b'properties') or {} | 906 props = diff.get(b'properties') or {} |
907 meta = props.get(b'hg:meta') | 907 meta = props.get(b'hg:meta') |
908 if not meta and props.get(b'local:commits'): | 908 if not meta: |
909 commit = sorted(props[b'local:commits'].values())[0] | 909 if props.get(b'local:commits'): |
910 meta = {} | 910 commit = sorted(props[b'local:commits'].values())[0] |
911 if b'author' in commit and b'authorEmail' in commit: | 911 meta = {} |
912 meta[b'user'] = b'%s <%s>' % (commit[b'author'], | 912 if b'author' in commit and b'authorEmail' in commit: |
913 commit[b'authorEmail']) | 913 meta[b'user'] = b'%s <%s>' % (commit[b'author'], |
914 if b'time' in commit: | 914 commit[b'authorEmail']) |
915 meta[b'date'] = b'%d 0' % commit[b'time'] | 915 if b'time' in commit: |
916 if b'branch' in commit: | 916 meta[b'date'] = b'%d 0' % commit[b'time'] |
917 meta[b'branch'] = commit[b'branch'] | 917 if b'branch' in commit: |
918 node = commit.get(b'commit', commit.get(b'rev')) | 918 meta[b'branch'] = commit[b'branch'] |
919 if node: | 919 node = commit.get(b'commit', commit.get(b'rev')) |
920 meta[b'node'] = node | 920 if node: |
921 if len(commit.get(b'parents', ())) >= 1: | 921 meta[b'node'] = node |
922 meta[b'parent'] = commit[b'parents'][0] | 922 if len(commit.get(b'parents', ())) >= 1: |
923 return meta or {} | 923 meta[b'parent'] = commit[b'parents'][0] |
924 else: | |
925 meta = {} | |
926 if b'date' not in meta and b'dateCreated' in diff: | |
927 meta[b'date'] = b'%s 0' % diff[b'dateCreated'] | |
928 if b'branch' not in meta and diff.get(b'branch'): | |
929 meta[b'branch'] = diff[b'branch'] | |
930 if b'parent' not in meta and diff.get(b'sourceControlBaseRevision'): | |
931 meta[b'parent'] = diff[b'sourceControlBaseRevision'] | |
932 return meta | |
924 | 933 |
925 def readpatch(repo, drevs, write): | 934 def readpatch(repo, drevs, write): |
926 """generate plain-text patch readable by 'hg import' | 935 """generate plain-text patch readable by 'hg import' |
927 | 936 |
928 write is usually ui.write. drevs is what "querydrev" returns, results of | 937 write is usually ui.write. drevs is what "querydrev" returns, results of |