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