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