Mercurial > public > mercurial-scm > hg
comparison hgext/phabricator.py @ 41902:59bae59b7498
py3: fix a few "dict keys as str instead of bytes" issues in phabricator.py
Differential Revision: https://phab.mercurial-scm.org/D6108
author | Ian Moody <moz-ian@perix.co.uk> |
---|---|
date | Sat, 09 Mar 2019 01:30:44 +0000 |
parents | a98dabdb5a7b |
children | 8fd19a7b4ed6 |
comparison
equal
deleted
inserted
replaced
41901:a98dabdb5a7b | 41902:59bae59b7498 |
---|---|
760 "sourcePath": null | 760 "sourcePath": null |
761 } | 761 } |
762 """ | 762 """ |
763 def fetch(params): | 763 def fetch(params): |
764 """params -> single drev or None""" | 764 """params -> single drev or None""" |
765 key = (params.get(r'ids') or params.get(r'phids') or [None])[0] | 765 key = (params.get(b'ids') or params.get(b'phids') or [None])[0] |
766 if key in prefetched: | 766 if key in prefetched: |
767 return prefetched[key] | 767 return prefetched[key] |
768 drevs = callconduit(repo, b'differential.query', params) | 768 drevs = callconduit(repo, b'differential.query', params) |
769 # Fill prefetched with the result | 769 # Fill prefetched with the result |
770 for drev in drevs: | 770 for drev in drevs: |
777 | 777 |
778 def getstack(topdrevids): | 778 def getstack(topdrevids): |
779 """given a top, get a stack from the bottom, [id] -> [id]""" | 779 """given a top, get a stack from the bottom, [id] -> [id]""" |
780 visited = set() | 780 visited = set() |
781 result = [] | 781 result = [] |
782 queue = [{r'ids': [i]} for i in topdrevids] | 782 queue = [{b'ids': [i]} for i in topdrevids] |
783 while queue: | 783 while queue: |
784 params = queue.pop() | 784 params = queue.pop() |
785 drev = fetch(params) | 785 drev = fetch(params) |
786 if drev[b'id'] in visited: | 786 if drev[b'id'] in visited: |
787 continue | 787 continue |
921 header = b'# HG changeset patch\n' | 921 header = b'# HG changeset patch\n' |
922 | 922 |
923 # Try to preserve metadata from hg:meta property. Write hg patch | 923 # Try to preserve metadata from hg:meta property. Write hg patch |
924 # headers that can be read by the "import" command. See patchheadermap | 924 # headers that can be read by the "import" command. See patchheadermap |
925 # and extract in mercurial/patch.py for supported headers. | 925 # and extract in mercurial/patch.py for supported headers. |
926 meta = getdiffmeta(diffs[str(diffid)]) | 926 meta = getdiffmeta(diffs[b'%d' % diffid]) |
927 for k in _metanamemap.keys(): | 927 for k in _metanamemap.keys(): |
928 if k in meta: | 928 if k in meta: |
929 header += b'# %s %s\n' % (_metanamemap[k], meta[k]) | 929 header += b'# %s %s\n' % (_metanamemap[k], meta[k]) |
930 | 930 |
931 content = b'%s%s\n%s' % (header, desc, body) | 931 content = b'%s%s\n%s' % (header, desc, body) |