comparison tests/test-phabricator.t @ 41897:c340a8ac7ef3

phabricator: convert conduit response JSON unicode to bytes inside callconduit Previously the byte conversion was happening piecemeal in callers, and in the case of createdifferentialrevision not at all, leading to UnicodeEncodeErrors when trying to phabsend a commit with a description containing characters not representable in ascii. (issue6040) Remove all the scattered encoding.unitolocal calls and perform it once, inside callconduit, on the entire response dict recursively before returning it, in keeping with the strategy of converting at the earliest opportunity. Convert all keys used on returned object to bytes. Modify the phabsend tests to test this by adding a € to the commit message of alpha. Differential Revision: https://phab.mercurial-scm.org/D6044
author Ian Moody <moz-ian@perix.co.uk>
date Sat, 02 Mar 2019 18:48:23 +0000
parents 43fd1947301d
children a4f7dceb07bf
comparison
equal deleted inserted replaced
41896:94faa2e84094 41897:c340a8ac7ef3
46 $ hg phabupdate --accept D4564 \ 46 $ hg phabupdate --accept D4564 \
47 > -m 'I think I like where this is headed. Will read rest of series later.'\ 47 > -m 'I think I like where this is headed. Will read rest of series later.'\
48 > --test-vcr "$VCR/accept-4564.json" 48 > --test-vcr "$VCR/accept-4564.json"
49 49
50 Create a differential diff: 50 Create a differential diff:
51 $ HGENCODING=utf-8; export HGENCODING
51 $ echo alpha > alpha 52 $ echo alpha > alpha
52 $ hg ci --addremove -m 'create alpha for phabricator test' 53 $ hg ci --addremove -m 'create alpha for phabricator test €'
53 adding alpha 54 adding alpha
54 $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json" 55 $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json"
55 D4596 - created - 5206a4fa1e6c: create alpha for phabricator test 56 D6054 - created - d386117f30e6: create alpha for phabricator test \xe2\x82\xac (esc)
56 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/5206a4fa1e6c-dec9e777-phabsend.hg 57 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d386117f30e6-24ffe649-phabsend.hg
57 $ echo more >> alpha 58 $ echo more >> alpha
58 $ HGEDITOR=true hg ci --amend 59 $ HGEDITOR=true hg ci --amend
59 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d8f232f7d799-c573510a-amend.hg 60 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/cb03845d6dd9-870f61a6-amend.hg
60 $ echo beta > beta 61 $ echo beta > beta
61 $ hg ci --addremove -m 'create beta for phabricator test' 62 $ hg ci --addremove -m 'create beta for phabricator test'
62 adding beta 63 adding beta
63 $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json" 64 $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json"
64 D4596 - updated - f70265671c65: create alpha for phabricator test 65 D6054 - updated - 939d862f0318: create alpha for phabricator test \xe2\x82\xac (esc)
65 D4597 - created - 1a5640df7bbf: create beta for phabricator test 66 D6055 - created - f55f947ed0f8: create beta for phabricator test
66 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/1a5640df7bbf-6daf3e6e-phabsend.hg 67 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f55f947ed0f8-0d1e502e-phabsend.hg
68 $ unset HGENCODING
67 69
68 The amend won't explode after posting a public commit. The local tag is left 70 The amend won't explode after posting a public commit. The local tag is left
69 behind to identify it. 71 behind to identify it.
70 72
71 $ echo 'public change' > beta 73 $ echo 'public change' > beta
72 $ hg ci -m 'create public change for phabricator testing' 74 $ hg ci -m 'create public change for phabricator testing'
73 $ hg phase --public . 75 $ hg phase --public .
74 $ echo 'draft change' > alpha 76 $ echo 'draft change' > alpha
75 $ hg ci -m 'create draft change for phabricator testing' 77 $ hg ci -m 'create draft change for phabricator testing'
76 $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json" 78 $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json"
77 D5544 - created - 540a21d3fbeb: create public change for phabricator testing 79 D5544 - created - a56e5ebd77e6: create public change for phabricator testing
78 D5545 - created - 6bca752686cd: create draft change for phabricator testing 80 D5545 - created - 6a0ade3e3ec2: create draft change for phabricator testing
79 warning: not updating public commit 2:540a21d3fbeb 81 warning: not updating public commit 2:a56e5ebd77e6
80 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/6bca752686cd-41faefb4-phabsend.hg 82 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/6a0ade3e3ec2-aca7d23c-phabsend.hg
81 $ hg tags -v 83 $ hg tags -v
82 tip 3:620a50fd6ed9 84 tip 3:90532860b5e1
83 D5544 2:540a21d3fbeb local 85 D5544 2:a56e5ebd77e6 local
84 86
85 $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF 87 $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF
86 > { 88 > {
87 > "constraints": { 89 > "constraints": {
88 > "isBot": true 90 > "isBot": true
105 107
106 Template keywords 108 Template keywords
107 $ hg log -T'{rev} {phabreview|json}\n' 109 $ hg log -T'{rev} {phabreview|json}\n'
108 3 {"id": "D5545", "url": "https://phab.mercurial-scm.org/D5545"} 110 3 {"id": "D5545", "url": "https://phab.mercurial-scm.org/D5545"}
109 2 {"id": "D5544", "url": "https://phab.mercurial-scm.org/D5544"} 111 2 {"id": "D5544", "url": "https://phab.mercurial-scm.org/D5544"}
110 1 {"id": "D4597", "url": "https://phab.mercurial-scm.org/D4597"} 112 1 {"id": "D6055", "url": "https://phab.mercurial-scm.org/D6055"}
111 0 {"id": "D4596", "url": "https://phab.mercurial-scm.org/D4596"} 113 0 {"id": "D6054", "url": "https://phab.mercurial-scm.org/D6054"}
112 114
113 $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n' 115 $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n'
114 3 https://phab.mercurial-scm.org/D5545 D5545 116 3 https://phab.mercurial-scm.org/D5545 D5545
115 2 https://phab.mercurial-scm.org/D5544 D5544 117 2 https://phab.mercurial-scm.org/D5544 D5544
116 1 https://phab.mercurial-scm.org/D4597 D4597 118 1 https://phab.mercurial-scm.org/D6055 D6055
117 0 https://phab.mercurial-scm.org/D4596 D4596 119 0 https://phab.mercurial-scm.org/D6054 D6054
118 120
119 $ cd .. 121 $ cd ..