##// END OF EJS Templates
tests: move the phabricator auth token to the global config file...
Matt Harbison -
r45210:ed81fa85 default
parent child Browse files
Show More
@@ -1,419 +1,419 b''
1 #require vcr
1 #require vcr
2 $ cat >> $HGRCPATH <<EOF
2 $ cat >> $HGRCPATH <<EOF
3 > [extensions]
3 > [extensions]
4 > phabricator =
4 > phabricator =
5 >
5 >
6 > [auth]
7 > hgphab.schemes = https
8 > hgphab.prefix = phab.mercurial-scm.org
9 > # When working on the extension and making phabricator interaction
10 > # changes, edit this to be a real phabricator token. When done, edit
11 > # it back. The VCR transcripts will be auto-sanitised to replace your real
12 > # token with this value.
13 > hgphab.phabtoken = cli-hahayouwish
14 >
6 > [phabricator]
15 > [phabricator]
7 > debug = True
16 > debug = True
8 > EOF
17 > EOF
9 $ hg init repo
18 $ hg init repo
10 $ cd repo
19 $ cd repo
11 $ cat >> .hg/hgrc <<EOF
20 $ cat >> .hg/hgrc <<EOF
12 > [phabricator]
21 > [phabricator]
13 > url = https://phab.mercurial-scm.org/
22 > url = https://phab.mercurial-scm.org/
14 > callsign = HG
23 > callsign = HG
15 >
16 > [auth]
17 > hgphab.schemes = https
18 > hgphab.prefix = phab.mercurial-scm.org
19 > # When working on the extension and making phabricator interaction
20 > # changes, edit this to be a real phabricator token. When done, edit
21 > # it back. The VCR transcripts will be auto-sanitised to replace your real
22 > # token with this value.
23 > hgphab.phabtoken = cli-hahayouwish
24 > EOF
24 > EOF
25 $ VCR="$TESTDIR/phabricator"
25 $ VCR="$TESTDIR/phabricator"
26
26
27 Error is handled reasonably. We override the phabtoken here so that
27 Error is handled reasonably. We override the phabtoken here so that
28 when you're developing changes to phabricator.py you can edit the
28 when you're developing changes to phabricator.py you can edit the
29 above config and have a real token in the test but not have to edit
29 above config and have a real token in the test but not have to edit
30 this test.
30 this test.
31 $ hg phabread --config auth.hgphab.phabtoken=cli-notavalidtoken \
31 $ hg phabread --config auth.hgphab.phabtoken=cli-notavalidtoken \
32 > --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head
32 > --test-vcr "$VCR/phabread-conduit-error.json" D4480 | head
33 abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long.
33 abort: Conduit Error (ERR-INVALID-AUTH): API token "cli-notavalidtoken" has the wrong length. API tokens should be 32 characters long.
34
34
35 Missing arguments don't crash, and may print the command help
35 Missing arguments don't crash, and may print the command help
36
36
37 $ hg debugcallconduit
37 $ hg debugcallconduit
38 hg debugcallconduit: invalid arguments
38 hg debugcallconduit: invalid arguments
39 hg debugcallconduit METHOD
39 hg debugcallconduit METHOD
40
40
41 call Conduit API
41 call Conduit API
42
42
43 options:
43 options:
44
44
45 (use 'hg debugcallconduit -h' to show more help)
45 (use 'hg debugcallconduit -h' to show more help)
46 [255]
46 [255]
47 $ hg phabread
47 $ hg phabread
48 abort: empty DREVSPEC set
48 abort: empty DREVSPEC set
49 [255]
49 [255]
50
50
51 Basic phabread:
51 Basic phabread:
52 $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head
52 $ hg phabread --test-vcr "$VCR/phabread-4480.json" D4480 | head
53 # HG changeset patch
53 # HG changeset patch
54 # Date 1536771503 0
54 # Date 1536771503 0
55 # Parent a5de21c9e3703f8e8eb064bd7d893ff2f703c66a
55 # Parent a5de21c9e3703f8e8eb064bd7d893ff2f703c66a
56 exchangev2: start to implement pull with wire protocol v2
56 exchangev2: start to implement pull with wire protocol v2
57
57
58 Wire protocol version 2 will take a substantially different
58 Wire protocol version 2 will take a substantially different
59 approach to exchange than version 1 (at least as far as pulling
59 approach to exchange than version 1 (at least as far as pulling
60 is concerned).
60 is concerned).
61
61
62 This commit establishes a new exchangev2 module for holding
62 This commit establishes a new exchangev2 module for holding
63
63
64 Phabread with multiple DREVSPEC
64 Phabread with multiple DREVSPEC
65
65
66 TODO: attempt to order related revisions like --stack?
66 TODO: attempt to order related revisions like --stack?
67 $ hg phabread --test-vcr "$VCR/phabread-multi-drev.json" D8205 8206 D8207 \
67 $ hg phabread --test-vcr "$VCR/phabread-multi-drev.json" D8205 8206 D8207 \
68 > | grep '^Differential Revision'
68 > | grep '^Differential Revision'
69 Differential Revision: https://phab.mercurial-scm.org/D8205
69 Differential Revision: https://phab.mercurial-scm.org/D8205
70 Differential Revision: https://phab.mercurial-scm.org/D8206
70 Differential Revision: https://phab.mercurial-scm.org/D8206
71 Differential Revision: https://phab.mercurial-scm.org/D8207
71 Differential Revision: https://phab.mercurial-scm.org/D8207
72
72
73 Empty DREVSPECs don't crash
73 Empty DREVSPECs don't crash
74
74
75 $ hg phabread --test-vcr "$VCR/phabread-empty-drev.json" D7917-D7917
75 $ hg phabread --test-vcr "$VCR/phabread-empty-drev.json" D7917-D7917
76 abort: empty DREVSPEC set
76 abort: empty DREVSPEC set
77 [255]
77 [255]
78
78
79
79
80 phabupdate with an accept:
80 phabupdate with an accept:
81 $ hg phabupdate --accept D4564 \
81 $ hg phabupdate --accept D4564 \
82 > -m 'I think I like where this is headed. Will read rest of series later.'\
82 > -m 'I think I like where this is headed. Will read rest of series later.'\
83 > --test-vcr "$VCR/accept-4564.json"
83 > --test-vcr "$VCR/accept-4564.json"
84 abort: Conduit Error (ERR-CONDUIT-CORE): Validation errors:
84 abort: Conduit Error (ERR-CONDUIT-CORE): Validation errors:
85 - You can not accept this revision because it has already been closed. Only open revisions can be accepted.
85 - You can not accept this revision because it has already been closed. Only open revisions can be accepted.
86 [255]
86 [255]
87 $ hg phabupdate --accept D7913 -m 'LGTM' --test-vcr "$VCR/accept-7913.json"
87 $ hg phabupdate --accept D7913 -m 'LGTM' --test-vcr "$VCR/accept-7913.json"
88
88
89 Create a differential diff:
89 Create a differential diff:
90 $ HGENCODING=utf-8; export HGENCODING
90 $ HGENCODING=utf-8; export HGENCODING
91 $ echo alpha > alpha
91 $ echo alpha > alpha
92 $ hg ci --addremove -m 'create alpha for phabricator test €'
92 $ hg ci --addremove -m 'create alpha for phabricator test €'
93 adding alpha
93 adding alpha
94 $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json"
94 $ hg phabsend -r . --test-vcr "$VCR/phabsend-create-alpha.json"
95 D7915 - created - d386117f30e6: create alpha for phabricator test \xe2\x82\xac (esc)
95 D7915 - created - d386117f30e6: create alpha for phabricator test \xe2\x82\xac (esc)
96 new commits: ['347bf67801e5']
96 new commits: ['347bf67801e5']
97 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d386117f30e6-24ffe649-phabsend.hg
97 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d386117f30e6-24ffe649-phabsend.hg
98 $ echo more >> alpha
98 $ echo more >> alpha
99 $ HGEDITOR=true hg ci --amend
99 $ HGEDITOR=true hg ci --amend
100 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/347bf67801e5-3bf313e4-amend.hg
100 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/347bf67801e5-3bf313e4-amend.hg
101 $ echo beta > beta
101 $ echo beta > beta
102 $ hg ci --addremove -m 'create beta for phabricator test'
102 $ hg ci --addremove -m 'create beta for phabricator test'
103 adding beta
103 adding beta
104 $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json"
104 $ hg phabsend -r ".^::" --test-vcr "$VCR/phabsend-update-alpha-create-beta.json"
105 c44b38f24a45 mapped to old nodes []
105 c44b38f24a45 mapped to old nodes []
106 D7915 - updated - c44b38f24a45: create alpha for phabricator test \xe2\x82\xac (esc)
106 D7915 - updated - c44b38f24a45: create alpha for phabricator test \xe2\x82\xac (esc)
107 D7916 - created - 9e6901f21d5b: create beta for phabricator test
107 D7916 - created - 9e6901f21d5b: create beta for phabricator test
108 new commits: ['a692622e6937']
108 new commits: ['a692622e6937']
109 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9e6901f21d5b-1fcd4f0e-phabsend.hg
109 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9e6901f21d5b-1fcd4f0e-phabsend.hg
110 $ unset HGENCODING
110 $ unset HGENCODING
111
111
112 The amend won't explode after posting a public commit. The local tag is left
112 The amend won't explode after posting a public commit. The local tag is left
113 behind to identify it.
113 behind to identify it.
114
114
115 $ echo 'public change' > beta
115 $ echo 'public change' > beta
116 $ hg ci -m 'create public change for phabricator testing'
116 $ hg ci -m 'create public change for phabricator testing'
117 $ hg phase --public .
117 $ hg phase --public .
118 $ echo 'draft change' > alpha
118 $ echo 'draft change' > alpha
119 $ hg ci -m 'create draft change for phabricator testing'
119 $ hg ci -m 'create draft change for phabricator testing'
120 $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json"
120 $ hg phabsend --amend -r '.^::' --test-vcr "$VCR/phabsend-create-public.json"
121 D7917 - created - 7b4185ab5d16: create public change for phabricator testing
121 D7917 - created - 7b4185ab5d16: create public change for phabricator testing
122 D7918 - created - 251c1c333fc6: create draft change for phabricator testing
122 D7918 - created - 251c1c333fc6: create draft change for phabricator testing
123 warning: not updating public commit 2:7b4185ab5d16
123 warning: not updating public commit 2:7b4185ab5d16
124 new commits: ['3244dc4a3334']
124 new commits: ['3244dc4a3334']
125 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/251c1c333fc6-41cb7c3b-phabsend.hg
125 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/251c1c333fc6-41cb7c3b-phabsend.hg
126 $ hg tags -v
126 $ hg tags -v
127 tip 3:3244dc4a3334
127 tip 3:3244dc4a3334
128 D7917 2:7b4185ab5d16 local
128 D7917 2:7b4185ab5d16 local
129
129
130 $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF
130 $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF
131 > {
131 > {
132 > "constraints": {
132 > "constraints": {
133 > "isBot": true
133 > "isBot": true
134 > }
134 > }
135 > }
135 > }
136 > EOF
136 > EOF
137 {
137 {
138 "cursor": {
138 "cursor": {
139 "after": null,
139 "after": null,
140 "before": null,
140 "before": null,
141 "limit": 100,
141 "limit": 100,
142 "order": null
142 "order": null
143 },
143 },
144 "data": [],
144 "data": [],
145 "maps": {},
145 "maps": {},
146 "query": {
146 "query": {
147 "queryKey": null
147 "queryKey": null
148 }
148 }
149 }
149 }
150
150
151 Template keywords
151 Template keywords
152 $ hg log -T'{rev} {phabreview|json}\n'
152 $ hg log -T'{rev} {phabreview|json}\n'
153 3 {"id": "D7918", "url": "https://phab.mercurial-scm.org/D7918"}
153 3 {"id": "D7918", "url": "https://phab.mercurial-scm.org/D7918"}
154 2 {"id": "D7917", "url": "https://phab.mercurial-scm.org/D7917"}
154 2 {"id": "D7917", "url": "https://phab.mercurial-scm.org/D7917"}
155 1 {"id": "D7916", "url": "https://phab.mercurial-scm.org/D7916"}
155 1 {"id": "D7916", "url": "https://phab.mercurial-scm.org/D7916"}
156 0 {"id": "D7915", "url": "https://phab.mercurial-scm.org/D7915"}
156 0 {"id": "D7915", "url": "https://phab.mercurial-scm.org/D7915"}
157
157
158 $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n'
158 $ hg log -T'{rev} {if(phabreview, "{phabreview.url} {phabreview.id}")}\n'
159 3 https://phab.mercurial-scm.org/D7918 D7918
159 3 https://phab.mercurial-scm.org/D7918 D7918
160 2 https://phab.mercurial-scm.org/D7917 D7917
160 2 https://phab.mercurial-scm.org/D7917 D7917
161 1 https://phab.mercurial-scm.org/D7916 D7916
161 1 https://phab.mercurial-scm.org/D7916 D7916
162 0 https://phab.mercurial-scm.org/D7915 D7915
162 0 https://phab.mercurial-scm.org/D7915 D7915
163
163
164 Commenting when phabsending:
164 Commenting when phabsending:
165 $ echo comment > comment
165 $ echo comment > comment
166 $ hg ci --addremove -m "create comment for phabricator test"
166 $ hg ci --addremove -m "create comment for phabricator test"
167 adding comment
167 adding comment
168 $ hg phabsend -r . -m "For default branch" --test-vcr "$VCR/phabsend-comment-created.json"
168 $ hg phabsend -r . -m "For default branch" --test-vcr "$VCR/phabsend-comment-created.json"
169 D7919 - created - d5dddca9023d: create comment for phabricator test
169 D7919 - created - d5dddca9023d: create comment for phabricator test
170 new commits: ['f7db812bbe1d']
170 new commits: ['f7db812bbe1d']
171 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d5dddca9023d-adf673ba-phabsend.hg
171 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/d5dddca9023d-adf673ba-phabsend.hg
172 $ echo comment2 >> comment
172 $ echo comment2 >> comment
173 $ hg ci --amend
173 $ hg ci --amend
174 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f7db812bbe1d-8fcded77-amend.hg
174 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f7db812bbe1d-8fcded77-amend.hg
175 $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json"
175 $ hg phabsend -r . -m "Address review comments" --test-vcr "$VCR/phabsend-comment-updated.json"
176 1849d7828727 mapped to old nodes []
176 1849d7828727 mapped to old nodes []
177 D7919 - updated - 1849d7828727: create comment for phabricator test
177 D7919 - updated - 1849d7828727: create comment for phabricator test
178
178
179 Phabsending a skipped commit:
179 Phabsending a skipped commit:
180 $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json"
180 $ hg phabsend --no-amend -r . --test-vcr "$VCR/phabsend-skipped.json"
181 1849d7828727 mapped to old nodes ['1849d7828727']
181 1849d7828727 mapped to old nodes ['1849d7828727']
182 D7919 - skipped - 1849d7828727: create comment for phabricator test
182 D7919 - skipped - 1849d7828727: create comment for phabricator test
183
183
184 Phabesending a new binary, a modified binary, and a removed binary
184 Phabesending a new binary, a modified binary, and a removed binary
185
185
186 >>> open('bin', 'wb').write(b'\0a') and None
186 >>> open('bin', 'wb').write(b'\0a') and None
187 $ hg ci -Am 'add binary'
187 $ hg ci -Am 'add binary'
188 adding bin
188 adding bin
189 >>> open('bin', 'wb').write(b'\0b') and None
189 >>> open('bin', 'wb').write(b'\0b') and None
190 $ hg ci -m 'modify binary'
190 $ hg ci -m 'modify binary'
191 $ hg rm bin
191 $ hg rm bin
192 $ hg ci -m 'remove binary'
192 $ hg ci -m 'remove binary'
193 $ hg phabsend -r .~2:: --test-vcr "$VCR/phabsend-binary.json"
193 $ hg phabsend -r .~2:: --test-vcr "$VCR/phabsend-binary.json"
194 uploading bin@aa24a81f55de
194 uploading bin@aa24a81f55de
195 D8007 - created - aa24a81f55de: add binary
195 D8007 - created - aa24a81f55de: add binary
196 uploading bin@d8d62a881b54
196 uploading bin@d8d62a881b54
197 D8008 - created - d8d62a881b54: modify binary
197 D8008 - created - d8d62a881b54: modify binary
198 D8009 - created - af55645b2e29: remove binary
198 D8009 - created - af55645b2e29: remove binary
199 new commits: ['b8139fbb4a57']
199 new commits: ['b8139fbb4a57']
200 new commits: ['c88ce4c2d2ad']
200 new commits: ['c88ce4c2d2ad']
201 new commits: ['75dbbc901145']
201 new commits: ['75dbbc901145']
202 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/aa24a81f55de-a3a0cf24-phabsend.hg
202 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/aa24a81f55de-a3a0cf24-phabsend.hg
203
203
204 Phabsend a renamed binary and a copied binary, with and without content changes
204 Phabsend a renamed binary and a copied binary, with and without content changes
205 to src and dest
205 to src and dest
206
206
207 >>> open('bin2', 'wb').write(b'\0c') and None
207 >>> open('bin2', 'wb').write(b'\0c') and None
208 $ hg ci -Am 'add another binary'
208 $ hg ci -Am 'add another binary'
209 adding bin2
209 adding bin2
210
210
211 TODO: "bin2" can't be viewed in this commit (left or right side), and the URL
211 TODO: "bin2" can't be viewed in this commit (left or right side), and the URL
212 looks much different than when viewing "bin2_moved". No idea if this is a phab
212 looks much different than when viewing "bin2_moved". No idea if this is a phab
213 bug, or phabsend bug. The patch (as printed by phabread) look reasonable
213 bug, or phabsend bug. The patch (as printed by phabread) look reasonable
214 though.
214 though.
215
215
216 $ hg mv bin2 bin2_moved
216 $ hg mv bin2 bin2_moved
217 $ hg ci -m "moved binary"
217 $ hg ci -m "moved binary"
218
218
219 Note: "bin2_moved" is also not viewable in phabricator with this review
219 Note: "bin2_moved" is also not viewable in phabricator with this review
220
220
221 $ hg cp bin2_moved bin2_copied
221 $ hg cp bin2_moved bin2_copied
222 $ hg ci -m "copied binary"
222 $ hg ci -m "copied binary"
223
223
224 Note: "bin2_moved_again" is marked binary in phabricator, and both sides of it
224 Note: "bin2_moved_again" is marked binary in phabricator, and both sides of it
225 are viewable in their proper state. "bin2_copied" is not viewable, and not
225 are viewable in their proper state. "bin2_copied" is not viewable, and not
226 listed as binary in phabricator.
226 listed as binary in phabricator.
227
227
228 >>> open('bin2_copied', 'wb').write(b'\0move+mod') and None
228 >>> open('bin2_copied', 'wb').write(b'\0move+mod') and None
229 $ hg mv bin2_copied bin2_moved_again
229 $ hg mv bin2_copied bin2_moved_again
230 $ hg ci -m "move+mod copied binary"
230 $ hg ci -m "move+mod copied binary"
231
231
232 Note: "bin2_moved" and "bin2_moved_copy" are both marked binary, and both
232 Note: "bin2_moved" and "bin2_moved_copy" are both marked binary, and both
233 viewable on each side.
233 viewable on each side.
234
234
235 >>> open('bin2_moved', 'wb').write(b'\0precopy mod') and None
235 >>> open('bin2_moved', 'wb').write(b'\0precopy mod') and None
236 $ hg cp bin2_moved bin2_moved_copied
236 $ hg cp bin2_moved bin2_moved_copied
237 >>> open('bin2_moved', 'wb').write(b'\0copy src+mod') and None
237 >>> open('bin2_moved', 'wb').write(b'\0copy src+mod') and None
238 $ hg ci -m "copy+mod moved binary"
238 $ hg ci -m "copy+mod moved binary"
239
239
240 $ hg phabsend -r .~4:: --test-vcr "$VCR/phabsend-binary-renames.json"
240 $ hg phabsend -r .~4:: --test-vcr "$VCR/phabsend-binary-renames.json"
241 uploading bin2@f42f9195e00c
241 uploading bin2@f42f9195e00c
242 D8128 - created - f42f9195e00c: add another binary
242 D8128 - created - f42f9195e00c: add another binary
243 D8129 - created - 834ab31d80ae: moved binary
243 D8129 - created - 834ab31d80ae: moved binary
244 D8130 - created - 494b750e5194: copied binary
244 D8130 - created - 494b750e5194: copied binary
245 uploading bin2_moved_again@25f766b50cc2
245 uploading bin2_moved_again@25f766b50cc2
246 D8131 - created - 25f766b50cc2: move+mod copied binary
246 D8131 - created - 25f766b50cc2: move+mod copied binary
247 uploading bin2_moved_copied@1b87b363a5e4
247 uploading bin2_moved_copied@1b87b363a5e4
248 uploading bin2_moved@1b87b363a5e4
248 uploading bin2_moved@1b87b363a5e4
249 D8132 - created - 1b87b363a5e4: copy+mod moved binary
249 D8132 - created - 1b87b363a5e4: copy+mod moved binary
250 new commits: ['90437c20312a']
250 new commits: ['90437c20312a']
251 new commits: ['f391f4da4c61']
251 new commits: ['f391f4da4c61']
252 new commits: ['da86a9f3268c']
252 new commits: ['da86a9f3268c']
253 new commits: ['003ffc16ba66']
253 new commits: ['003ffc16ba66']
254 new commits: ['13bd750c36fa']
254 new commits: ['13bd750c36fa']
255 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f42f9195e00c-e82a0769-phabsend.hg
255 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/f42f9195e00c-e82a0769-phabsend.hg
256
256
257 Phabreading a DREV with a local:commits time as a string:
257 Phabreading a DREV with a local:commits time as a string:
258 $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285
258 $ hg phabread --test-vcr "$VCR/phabread-str-time.json" D1285
259 # HG changeset patch
259 # HG changeset patch
260 # User Pulkit Goyal <7895pulkit@gmail.com>
260 # User Pulkit Goyal <7895pulkit@gmail.com>
261 # Date 1509404054 -19800
261 # Date 1509404054 -19800
262 # Node ID 44fc1c1f1774a76423b9c732af6938435099bcc5
262 # Node ID 44fc1c1f1774a76423b9c732af6938435099bcc5
263 # Parent 8feef8ef8389a3b544e0a74624f1efc3a8d85d35
263 # Parent 8feef8ef8389a3b544e0a74624f1efc3a8d85d35
264 repoview: add a new attribute _visibilityexceptions and related API
264 repoview: add a new attribute _visibilityexceptions and related API
265
265
266 Currently we don't have a defined way in core to make some hidden revisions
266 Currently we don't have a defined way in core to make some hidden revisions
267 visible in filtered repo. Extensions to achieve the purpose of unhiding some
267 visible in filtered repo. Extensions to achieve the purpose of unhiding some
268 hidden commits, wrap repoview.pinnedrevs() function.
268 hidden commits, wrap repoview.pinnedrevs() function.
269
269
270 To make the above task simple and have well defined API, this patch adds a new
270 To make the above task simple and have well defined API, this patch adds a new
271 attribute '_visibilityexceptions' to repoview class which will contains
271 attribute '_visibilityexceptions' to repoview class which will contains
272 the hidden revs which should be exception.
272 the hidden revs which should be exception.
273 This will allow to set different exceptions for different repoview objects
273 This will allow to set different exceptions for different repoview objects
274 backed by the same unfiltered repo.
274 backed by the same unfiltered repo.
275
275
276 This patch also adds API to add revs to the attribute set and get them.
276 This patch also adds API to add revs to the attribute set and get them.
277
277
278 Thanks to Jun for suggesting the use of repoview class instead of localrepo.
278 Thanks to Jun for suggesting the use of repoview class instead of localrepo.
279
279
280 Differential Revision: https://phab.mercurial-scm.org/D1285
280 Differential Revision: https://phab.mercurial-scm.org/D1285
281 diff --git a/mercurial/repoview.py b/mercurial/repoview.py
281 diff --git a/mercurial/repoview.py b/mercurial/repoview.py
282 --- a/mercurial/repoview.py
282 --- a/mercurial/repoview.py
283 +++ b/mercurial/repoview.py
283 +++ b/mercurial/repoview.py
284 @@ * @@ (glob)
284 @@ * @@ (glob)
285 subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`.
285 subclasses of `localrepo`. Eg: `bundlerepo` or `statichttprepo`.
286 """
286 """
287
287
288 + # hidden revs which should be visible
288 + # hidden revs which should be visible
289 + _visibilityexceptions = set()
289 + _visibilityexceptions = set()
290 +
290 +
291 def __init__(self, repo, filtername):
291 def __init__(self, repo, filtername):
292 object.__setattr__(self, r'_unfilteredrepo', repo)
292 object.__setattr__(self, r'_unfilteredrepo', repo)
293 object.__setattr__(self, r'filtername', filtername)
293 object.__setattr__(self, r'filtername', filtername)
294 @@ -231,6 +234,14 @@
294 @@ -231,6 +234,14 @@
295 return self
295 return self
296 return self.unfiltered().filtered(name)
296 return self.unfiltered().filtered(name)
297
297
298 + def addvisibilityexceptions(self, revs):
298 + def addvisibilityexceptions(self, revs):
299 + """adds hidden revs which should be visible to set of exceptions"""
299 + """adds hidden revs which should be visible to set of exceptions"""
300 + self._visibilityexceptions.update(revs)
300 + self._visibilityexceptions.update(revs)
301 +
301 +
302 + def getvisibilityexceptions(self):
302 + def getvisibilityexceptions(self):
303 + """returns the set of hidden revs which should be visible"""
303 + """returns the set of hidden revs which should be visible"""
304 + return self._visibilityexceptions
304 + return self._visibilityexceptions
305 +
305 +
306 # everything access are forwarded to the proxied repo
306 # everything access are forwarded to the proxied repo
307 def __getattr__(self, attr):
307 def __getattr__(self, attr):
308 return getattr(self._unfilteredrepo, attr)
308 return getattr(self._unfilteredrepo, attr)
309 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
309 diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
310 --- a/mercurial/localrepo.py
310 --- a/mercurial/localrepo.py
311 +++ b/mercurial/localrepo.py
311 +++ b/mercurial/localrepo.py
312 @@ -570,6 +570,14 @@
312 @@ -570,6 +570,14 @@
313 def close(self):
313 def close(self):
314 self._writecaches()
314 self._writecaches()
315
315
316 + def addvisibilityexceptions(self, exceptions):
316 + def addvisibilityexceptions(self, exceptions):
317 + # should be called on a filtered repository
317 + # should be called on a filtered repository
318 + pass
318 + pass
319 +
319 +
320 + def getvisibilityexceptions(self):
320 + def getvisibilityexceptions(self):
321 + # should be called on a filtered repository
321 + # should be called on a filtered repository
322 + return set()
322 + return set()
323 +
323 +
324 def _loadextensions(self):
324 def _loadextensions(self):
325 extensions.loadall(self.ui)
325 extensions.loadall(self.ui)
326
326
327
327
328 A bad .arcconfig doesn't error out
328 A bad .arcconfig doesn't error out
329 $ echo 'garbage' > .arcconfig
329 $ echo 'garbage' > .arcconfig
330 $ hg config phabricator --debug
330 $ hg config phabricator --debug
331 invalid JSON in $TESTTMP/repo/.arcconfig
331 invalid JSON in $TESTTMP/repo/.arcconfig
332 read config from: */.hgrc (glob)
332 read config from: */.hgrc (glob)
333 */.hgrc:*: phabricator.debug=True (glob)
333 */.hgrc:*: phabricator.debug=True (glob)
334 $TESTTMP/repo/.hg/hgrc:*: phabricator.url=https://phab.mercurial-scm.org/ (glob)
334 $TESTTMP/repo/.hg/hgrc:*: phabricator.url=https://phab.mercurial-scm.org/ (glob)
335 $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=HG (glob)
335 $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=HG (glob)
336
336
337 The .arcconfig content overrides global config
337 The .arcconfig content overrides global config
338 $ cat >> $HGRCPATH << EOF
338 $ cat >> $HGRCPATH << EOF
339 > [phabricator]
339 > [phabricator]
340 > url = global
340 > url = global
341 > callsign = global
341 > callsign = global
342 > EOF
342 > EOF
343 $ cp $TESTDIR/../.arcconfig .
343 $ cp $TESTDIR/../.arcconfig .
344 $ mv .hg/hgrc .hg/hgrc.bak
344 $ mv .hg/hgrc .hg/hgrc.bak
345 $ hg config phabricator --debug
345 $ hg config phabricator --debug
346 read config from: */.hgrc (glob)
346 read config from: */.hgrc (glob)
347 */.hgrc:*: phabricator.debug=True (glob)
347 */.hgrc:*: phabricator.debug=True (glob)
348 $TESTTMP/repo/.arcconfig: phabricator.callsign=HG
348 $TESTTMP/repo/.arcconfig: phabricator.callsign=HG
349 $TESTTMP/repo/.arcconfig: phabricator.url=https://phab.mercurial-scm.org/
349 $TESTTMP/repo/.arcconfig: phabricator.url=https://phab.mercurial-scm.org/
350
350
351 But it doesn't override local config
351 But it doesn't override local config
352 $ cat >> .hg/hgrc << EOF
352 $ cat >> .hg/hgrc << EOF
353 > [phabricator]
353 > [phabricator]
354 > url = local
354 > url = local
355 > callsign = local
355 > callsign = local
356 > EOF
356 > EOF
357 $ hg config phabricator --debug
357 $ hg config phabricator --debug
358 read config from: */.hgrc (glob)
358 read config from: */.hgrc (glob)
359 */.hgrc:*: phabricator.debug=True (glob)
359 */.hgrc:*: phabricator.debug=True (glob)
360 $TESTTMP/repo/.hg/hgrc:*: phabricator.url=local (glob)
360 $TESTTMP/repo/.hg/hgrc:*: phabricator.url=local (glob)
361 $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=local (glob)
361 $TESTTMP/repo/.hg/hgrc:*: phabricator.callsign=local (glob)
362 $ mv .hg/hgrc.bak .hg/hgrc
362 $ mv .hg/hgrc.bak .hg/hgrc
363
363
364 Phabimport works with a stack
364 Phabimport works with a stack
365
365
366 $ cd ..
366 $ cd ..
367 $ hg clone repo repo2 -qr 1
367 $ hg clone repo repo2 -qr 1
368 $ cp repo/.hg/hgrc repo2/.hg/
368 $ cp repo/.hg/hgrc repo2/.hg/
369 $ cd repo2
369 $ cd repo2
370 $ hg phabimport --stack 'D7918' --test-vcr "$VCR/phabimport-stack.json"
370 $ hg phabimport --stack 'D7918' --test-vcr "$VCR/phabimport-stack.json"
371 applying patch from D7917
371 applying patch from D7917
372 applying patch from D7918
372 applying patch from D7918
373 $ hg log -r .: -G -Tcompact
373 $ hg log -r .: -G -Tcompact
374 o 3[tip] aaef04066140 1970-01-01 00:00 +0000 test
374 o 3[tip] aaef04066140 1970-01-01 00:00 +0000 test
375 | create draft change for phabricator testing
375 | create draft change for phabricator testing
376 |
376 |
377 o 2 8de3712202d1 1970-01-01 00:00 +0000 test
377 o 2 8de3712202d1 1970-01-01 00:00 +0000 test
378 | create public change for phabricator testing
378 | create public change for phabricator testing
379 |
379 |
380 @ 1 a692622e6937 1970-01-01 00:00 +0000 test
380 @ 1 a692622e6937 1970-01-01 00:00 +0000 test
381 | create beta for phabricator test
381 | create beta for phabricator test
382 ~
382 ~
383 Phabimport can create secret commits
383 Phabimport can create secret commits
384
384
385 $ hg rollback --config ui.rollback=True
385 $ hg rollback --config ui.rollback=True
386 repository tip rolled back to revision 1 (undo phabimport)
386 repository tip rolled back to revision 1 (undo phabimport)
387 $ hg phabimport --stack 'D7918' --test-vcr "$VCR/phabimport-stack.json" \
387 $ hg phabimport --stack 'D7918' --test-vcr "$VCR/phabimport-stack.json" \
388 > --config phabimport.secret=True
388 > --config phabimport.secret=True
389 applying patch from D7917
389 applying patch from D7917
390 applying patch from D7918
390 applying patch from D7918
391 $ hg log -r 'reverse(.:)' -T phases
391 $ hg log -r 'reverse(.:)' -T phases
392 changeset: 3:aaef04066140
392 changeset: 3:aaef04066140
393 tag: tip
393 tag: tip
394 phase: secret
394 phase: secret
395 user: test
395 user: test
396 date: Thu Jan 01 00:00:00 1970 +0000
396 date: Thu Jan 01 00:00:00 1970 +0000
397 summary: create draft change for phabricator testing
397 summary: create draft change for phabricator testing
398
398
399 changeset: 2:8de3712202d1
399 changeset: 2:8de3712202d1
400 phase: secret
400 phase: secret
401 user: test
401 user: test
402 date: Thu Jan 01 00:00:00 1970 +0000
402 date: Thu Jan 01 00:00:00 1970 +0000
403 summary: create public change for phabricator testing
403 summary: create public change for phabricator testing
404
404
405 changeset: 1:a692622e6937
405 changeset: 1:a692622e6937
406 phase: public
406 phase: public
407 user: test
407 user: test
408 date: Thu Jan 01 00:00:00 1970 +0000
408 date: Thu Jan 01 00:00:00 1970 +0000
409 summary: create beta for phabricator test
409 summary: create beta for phabricator test
410
410
411 Phabimport accepts multiple DREVSPECs
411 Phabimport accepts multiple DREVSPECs
412
412
413 $ hg rollback --config ui.rollback=True
413 $ hg rollback --config ui.rollback=True
414 repository tip rolled back to revision 1 (undo phabimport)
414 repository tip rolled back to revision 1 (undo phabimport)
415 $ hg phabimport --no-stack D7917 D7918 --test-vcr "$VCR/phabimport-multi-drev.json"
415 $ hg phabimport --no-stack D7917 D7918 --test-vcr "$VCR/phabimport-multi-drev.json"
416 applying patch from D7917
416 applying patch from D7917
417 applying patch from D7918
417 applying patch from D7918
418
418
419 $ cd ..
419 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now