##// END OF EJS Templates
rust-utils: add util for canonical path...
Raphaël Gomès -
r44783:4caac36c default
parent child Browse files
Show More
@@ -1,645 +1,664 b''
1 1 # This file is automatically @generated by Cargo.
2 2 # It is not intended for manual editing.
3 3 [[package]]
4 4 name = "aho-corasick"
5 5 version = "0.7.8"
6 6 source = "registry+https://github.com/rust-lang/crates.io-index"
7 7 dependencies = [
8 8 "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
9 9 ]
10 10
11 11 [[package]]
12 12 name = "ansi_term"
13 13 version = "0.11.0"
14 14 source = "registry+https://github.com/rust-lang/crates.io-index"
15 15 dependencies = [
16 16 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
17 17 ]
18 18
19 19 [[package]]
20 20 name = "autocfg"
21 21 version = "0.1.7"
22 22 source = "registry+https://github.com/rust-lang/crates.io-index"
23 23
24 24 [[package]]
25 25 name = "autocfg"
26 26 version = "1.0.0"
27 27 source = "registry+https://github.com/rust-lang/crates.io-index"
28 28
29 29 [[package]]
30 30 name = "bitflags"
31 31 version = "1.2.1"
32 32 source = "registry+https://github.com/rust-lang/crates.io-index"
33 33
34 34 [[package]]
35 35 name = "byteorder"
36 36 version = "1.3.2"
37 37 source = "registry+https://github.com/rust-lang/crates.io-index"
38 38
39 39 [[package]]
40 40 name = "c2-chacha"
41 41 version = "0.2.3"
42 42 source = "registry+https://github.com/rust-lang/crates.io-index"
43 43 dependencies = [
44 44 "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
45 45 ]
46 46
47 47 [[package]]
48 48 name = "cfg-if"
49 49 version = "0.1.10"
50 50 source = "registry+https://github.com/rust-lang/crates.io-index"
51 51
52 52 [[package]]
53 53 name = "cloudabi"
54 54 version = "0.0.3"
55 55 source = "registry+https://github.com/rust-lang/crates.io-index"
56 56 dependencies = [
57 57 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
58 58 ]
59 59
60 60 [[package]]
61 61 name = "cpython"
62 62 version = "0.4.1"
63 63 source = "registry+https://github.com/rust-lang/crates.io-index"
64 64 dependencies = [
65 65 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
66 66 "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
67 67 "python27-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
68 68 "python3-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
69 69 ]
70 70
71 71 [[package]]
72 72 name = "crossbeam-deque"
73 73 version = "0.7.2"
74 74 source = "registry+https://github.com/rust-lang/crates.io-index"
75 75 dependencies = [
76 76 "crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
77 77 "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
78 78 ]
79 79
80 80 [[package]]
81 81 name = "crossbeam-epoch"
82 82 version = "0.8.0"
83 83 source = "registry+https://github.com/rust-lang/crates.io-index"
84 84 dependencies = [
85 85 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
86 86 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
87 87 "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
88 88 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
89 89 "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
90 90 "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
91 91 ]
92 92
93 93 [[package]]
94 94 name = "crossbeam-queue"
95 95 version = "0.2.1"
96 96 source = "registry+https://github.com/rust-lang/crates.io-index"
97 97 dependencies = [
98 98 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
99 99 "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
100 100 ]
101 101
102 102 [[package]]
103 103 name = "crossbeam-utils"
104 104 version = "0.7.0"
105 105 source = "registry+https://github.com/rust-lang/crates.io-index"
106 106 dependencies = [
107 107 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
108 108 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
109 109 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
110 110 ]
111 111
112 112 [[package]]
113 113 name = "ctor"
114 114 version = "0.1.12"
115 115 source = "registry+https://github.com/rust-lang/crates.io-index"
116 116 dependencies = [
117 117 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
118 118 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
119 119 ]
120 120
121 121 [[package]]
122 122 name = "difference"
123 123 version = "2.0.0"
124 124 source = "registry+https://github.com/rust-lang/crates.io-index"
125 125
126 126 [[package]]
127 127 name = "either"
128 128 version = "1.5.3"
129 129 source = "registry+https://github.com/rust-lang/crates.io-index"
130 130
131 131 [[package]]
132 132 name = "fuchsia-cprng"
133 133 version = "0.1.1"
134 134 source = "registry+https://github.com/rust-lang/crates.io-index"
135 135
136 136 [[package]]
137 137 name = "getrandom"
138 138 version = "0.1.14"
139 139 source = "registry+https://github.com/rust-lang/crates.io-index"
140 140 dependencies = [
141 141 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
142 142 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
143 143 "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
144 144 ]
145 145
146 146 [[package]]
147 147 name = "hermit-abi"
148 148 version = "0.1.6"
149 149 source = "registry+https://github.com/rust-lang/crates.io-index"
150 150 dependencies = [
151 151 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
152 152 ]
153 153
154 154 [[package]]
155 155 name = "hex"
156 156 version = "0.4.0"
157 157 source = "registry+https://github.com/rust-lang/crates.io-index"
158 158
159 159 [[package]]
160 160 name = "hg-core"
161 161 version = "0.1.0"
162 162 dependencies = [
163 163 "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
164 164 "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
165 165 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
166 166 "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
167 167 "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
168 168 "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
169 169 "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
170 170 "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
171 171 "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
172 "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
172 173 "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
173 174 "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
174 175 ]
175 176
176 177 [[package]]
177 178 name = "hg-cpython"
178 179 version = "0.1.0"
179 180 dependencies = [
180 181 "cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
181 182 "hg-core 0.1.0",
182 183 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
183 184 ]
184 185
185 186 [[package]]
186 187 name = "hgdirectffi"
187 188 version = "0.1.0"
188 189 dependencies = [
189 190 "hg-core 0.1.0",
190 191 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
191 192 ]
192 193
193 194 [[package]]
194 195 name = "lazy_static"
195 196 version = "1.4.0"
196 197 source = "registry+https://github.com/rust-lang/crates.io-index"
197 198
198 199 [[package]]
199 200 name = "libc"
200 201 version = "0.2.66"
201 202 source = "registry+https://github.com/rust-lang/crates.io-index"
202 203
203 204 [[package]]
204 205 name = "memchr"
205 206 version = "2.3.0"
206 207 source = "registry+https://github.com/rust-lang/crates.io-index"
207 208
208 209 [[package]]
209 210 name = "memoffset"
210 211 version = "0.5.3"
211 212 source = "registry+https://github.com/rust-lang/crates.io-index"
212 213 dependencies = [
213 214 "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
214 215 ]
215 216
216 217 [[package]]
217 218 name = "num-traits"
218 219 version = "0.2.11"
219 220 source = "registry+https://github.com/rust-lang/crates.io-index"
220 221 dependencies = [
221 222 "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
222 223 ]
223 224
224 225 [[package]]
225 226 name = "num_cpus"
226 227 version = "1.12.0"
227 228 source = "registry+https://github.com/rust-lang/crates.io-index"
228 229 dependencies = [
229 230 "hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
230 231 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
231 232 ]
232 233
233 234 [[package]]
234 235 name = "output_vt100"
235 236 version = "0.1.2"
236 237 source = "registry+https://github.com/rust-lang/crates.io-index"
237 238 dependencies = [
238 239 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
239 240 ]
240 241
241 242 [[package]]
242 243 name = "ppv-lite86"
243 244 version = "0.2.6"
244 245 source = "registry+https://github.com/rust-lang/crates.io-index"
245 246
246 247 [[package]]
247 248 name = "pretty_assertions"
248 249 version = "0.6.1"
249 250 source = "registry+https://github.com/rust-lang/crates.io-index"
250 251 dependencies = [
251 252 "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
252 253 "ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
253 254 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
254 255 "output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
255 256 ]
256 257
257 258 [[package]]
258 259 name = "proc-macro2"
259 260 version = "1.0.8"
260 261 source = "registry+https://github.com/rust-lang/crates.io-index"
261 262 dependencies = [
262 263 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
263 264 ]
264 265
265 266 [[package]]
266 267 name = "python27-sys"
267 268 version = "0.4.1"
268 269 source = "registry+https://github.com/rust-lang/crates.io-index"
269 270 dependencies = [
270 271 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
271 272 "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
272 273 ]
273 274
274 275 [[package]]
275 276 name = "python3-sys"
276 277 version = "0.4.1"
277 278 source = "registry+https://github.com/rust-lang/crates.io-index"
278 279 dependencies = [
279 280 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
280 281 "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
281 282 ]
282 283
283 284 [[package]]
284 285 name = "quote"
285 286 version = "1.0.2"
286 287 source = "registry+https://github.com/rust-lang/crates.io-index"
287 288 dependencies = [
288 289 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
289 290 ]
290 291
291 292 [[package]]
292 293 name = "rand"
293 294 version = "0.6.5"
294 295 source = "registry+https://github.com/rust-lang/crates.io-index"
295 296 dependencies = [
296 297 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
297 298 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
298 299 "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
299 300 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
300 301 "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
301 302 "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
302 303 "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
303 304 "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
304 305 "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
305 306 "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
306 307 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
307 308 ]
308 309
309 310 [[package]]
310 311 name = "rand"
311 312 version = "0.7.3"
312 313 source = "registry+https://github.com/rust-lang/crates.io-index"
313 314 dependencies = [
314 315 "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
315 316 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
316 317 "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
317 318 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
318 319 "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
319 320 ]
320 321
321 322 [[package]]
322 323 name = "rand_chacha"
323 324 version = "0.1.1"
324 325 source = "registry+https://github.com/rust-lang/crates.io-index"
325 326 dependencies = [
326 327 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
327 328 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
328 329 ]
329 330
330 331 [[package]]
331 332 name = "rand_chacha"
332 333 version = "0.2.1"
333 334 source = "registry+https://github.com/rust-lang/crates.io-index"
334 335 dependencies = [
335 336 "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
336 337 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
337 338 ]
338 339
339 340 [[package]]
340 341 name = "rand_core"
341 342 version = "0.3.1"
342 343 source = "registry+https://github.com/rust-lang/crates.io-index"
343 344 dependencies = [
344 345 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
345 346 ]
346 347
347 348 [[package]]
348 349 name = "rand_core"
349 350 version = "0.4.2"
350 351 source = "registry+https://github.com/rust-lang/crates.io-index"
351 352
352 353 [[package]]
353 354 name = "rand_core"
354 355 version = "0.5.1"
355 356 source = "registry+https://github.com/rust-lang/crates.io-index"
356 357 dependencies = [
357 358 "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
358 359 ]
359 360
360 361 [[package]]
361 362 name = "rand_hc"
362 363 version = "0.1.0"
363 364 source = "registry+https://github.com/rust-lang/crates.io-index"
364 365 dependencies = [
365 366 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
366 367 ]
367 368
368 369 [[package]]
369 370 name = "rand_hc"
370 371 version = "0.2.0"
371 372 source = "registry+https://github.com/rust-lang/crates.io-index"
372 373 dependencies = [
373 374 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
374 375 ]
375 376
376 377 [[package]]
377 378 name = "rand_isaac"
378 379 version = "0.1.1"
379 380 source = "registry+https://github.com/rust-lang/crates.io-index"
380 381 dependencies = [
381 382 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
382 383 ]
383 384
384 385 [[package]]
385 386 name = "rand_jitter"
386 387 version = "0.1.4"
387 388 source = "registry+https://github.com/rust-lang/crates.io-index"
388 389 dependencies = [
389 390 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
390 391 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
391 392 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
392 393 ]
393 394
394 395 [[package]]
395 396 name = "rand_os"
396 397 version = "0.1.3"
397 398 source = "registry+https://github.com/rust-lang/crates.io-index"
398 399 dependencies = [
399 400 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
400 401 "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
401 402 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
402 403 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
403 404 "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
404 405 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
405 406 ]
406 407
407 408 [[package]]
408 409 name = "rand_pcg"
409 410 version = "0.1.2"
410 411 source = "registry+https://github.com/rust-lang/crates.io-index"
411 412 dependencies = [
412 413 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
413 414 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
414 415 ]
415 416
416 417 [[package]]
417 418 name = "rand_xorshift"
418 419 version = "0.1.1"
419 420 source = "registry+https://github.com/rust-lang/crates.io-index"
420 421 dependencies = [
421 422 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
422 423 ]
423 424
424 425 [[package]]
425 426 name = "rayon"
426 427 version = "1.3.0"
427 428 source = "registry+https://github.com/rust-lang/crates.io-index"
428 429 dependencies = [
429 430 "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
430 431 "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
431 432 "rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
432 433 ]
433 434
434 435 [[package]]
435 436 name = "rayon-core"
436 437 version = "1.7.0"
437 438 source = "registry+https://github.com/rust-lang/crates.io-index"
438 439 dependencies = [
439 440 "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
440 441 "crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
441 442 "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
442 443 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
443 444 "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
444 445 ]
445 446
446 447 [[package]]
447 448 name = "rdrand"
448 449 version = "0.4.0"
449 450 source = "registry+https://github.com/rust-lang/crates.io-index"
450 451 dependencies = [
451 452 "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
452 453 ]
453 454
454 455 [[package]]
455 456 name = "redox_syscall"
456 457 version = "0.1.56"
457 458 source = "registry+https://github.com/rust-lang/crates.io-index"
458 459
459 460 [[package]]
460 461 name = "regex"
461 462 version = "1.3.4"
462 463 source = "registry+https://github.com/rust-lang/crates.io-index"
463 464 dependencies = [
464 465 "aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
465 466 "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
466 467 "regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
467 468 "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
468 469 ]
469 470
470 471 [[package]]
471 472 name = "regex-syntax"
472 473 version = "0.6.14"
473 474 source = "registry+https://github.com/rust-lang/crates.io-index"
474 475
475 476 [[package]]
476 477 name = "remove_dir_all"
477 478 version = "0.5.2"
478 479 source = "registry+https://github.com/rust-lang/crates.io-index"
479 480 dependencies = [
480 481 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
481 482 ]
482 483
483 484 [[package]]
484 485 name = "rustc_version"
485 486 version = "0.2.3"
486 487 source = "registry+https://github.com/rust-lang/crates.io-index"
487 488 dependencies = [
488 489 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
489 490 ]
490 491
491 492 [[package]]
493 name = "same-file"
494 version = "1.0.6"
495 source = "registry+https://github.com/rust-lang/crates.io-index"
496 dependencies = [
497 "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
498 ]
499
500 [[package]]
492 501 name = "scopeguard"
493 502 version = "1.0.0"
494 503 source = "registry+https://github.com/rust-lang/crates.io-index"
495 504
496 505 [[package]]
497 506 name = "semver"
498 507 version = "0.9.0"
499 508 source = "registry+https://github.com/rust-lang/crates.io-index"
500 509 dependencies = [
501 510 "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
502 511 ]
503 512
504 513 [[package]]
505 514 name = "semver-parser"
506 515 version = "0.7.0"
507 516 source = "registry+https://github.com/rust-lang/crates.io-index"
508 517
509 518 [[package]]
510 519 name = "syn"
511 520 version = "1.0.14"
512 521 source = "registry+https://github.com/rust-lang/crates.io-index"
513 522 dependencies = [
514 523 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
515 524 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
516 525 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
517 526 ]
518 527
519 528 [[package]]
520 529 name = "tempfile"
521 530 version = "3.1.0"
522 531 source = "registry+https://github.com/rust-lang/crates.io-index"
523 532 dependencies = [
524 533 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
525 534 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
526 535 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
527 536 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
528 537 "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
529 538 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
530 539 ]
531 540
532 541 [[package]]
533 542 name = "thread_local"
534 543 version = "1.0.1"
535 544 source = "registry+https://github.com/rust-lang/crates.io-index"
536 545 dependencies = [
537 546 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
538 547 ]
539 548
540 549 [[package]]
541 550 name = "twox-hash"
542 551 version = "1.5.0"
543 552 source = "registry+https://github.com/rust-lang/crates.io-index"
544 553 dependencies = [
545 554 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
546 555 ]
547 556
548 557 [[package]]
549 558 name = "unicode-xid"
550 559 version = "0.2.0"
551 560 source = "registry+https://github.com/rust-lang/crates.io-index"
552 561
553 562 [[package]]
554 563 name = "wasi"
555 564 version = "0.9.0+wasi-snapshot-preview1"
556 565 source = "registry+https://github.com/rust-lang/crates.io-index"
557 566
558 567 [[package]]
559 568 name = "winapi"
560 569 version = "0.3.8"
561 570 source = "registry+https://github.com/rust-lang/crates.io-index"
562 571 dependencies = [
563 572 "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
564 573 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
565 574 ]
566 575
567 576 [[package]]
568 577 name = "winapi-i686-pc-windows-gnu"
569 578 version = "0.4.0"
570 579 source = "registry+https://github.com/rust-lang/crates.io-index"
571 580
572 581 [[package]]
582 name = "winapi-util"
583 version = "0.1.3"
584 source = "registry+https://github.com/rust-lang/crates.io-index"
585 dependencies = [
586 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
587 ]
588
589 [[package]]
573 590 name = "winapi-x86_64-pc-windows-gnu"
574 591 version = "0.4.0"
575 592 source = "registry+https://github.com/rust-lang/crates.io-index"
576 593
577 594 [metadata]
578 595 "checksum aho-corasick 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "743ad5a418686aad3b87fd14c43badd828cf26e214a00f92a384291cf22e1811"
579 596 "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
580 597 "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
581 598 "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
582 599 "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
583 600 "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
584 601 "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
585 602 "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
586 603 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
587 604 "checksum cpython 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaf3847ab963e40c4f6dd8d6be279bdf74007ae2413786a0dcbb28c52139a95"
588 605 "checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca"
589 606 "checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac"
590 607 "checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
591 608 "checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4"
592 609 "checksum ctor 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8ce37ad4184ab2ce004c33bf6379185d3b1c95801cab51026bd271bf68eedc"
593 610 "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
594 611 "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
595 612 "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
596 613 "checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
597 614 "checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772"
598 615 "checksum hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e"
599 616 "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
600 617 "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
601 618 "checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
602 619 "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
603 620 "checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
604 621 "checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
605 622 "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
606 623 "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
607 624 "checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
608 625 "checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
609 626 "checksum python27-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "67cb041de8615111bf224dd75667af5f25c6e032118251426fed7f1b70ce4c8c"
610 627 "checksum python3-sys 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90af11779515a1e530af60782d273b59ac79d33b0e253c071a728563957c76d4"
611 628 "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
612 629 "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
613 630 "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
614 631 "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef"
615 632 "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853"
616 633 "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
617 634 "checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
618 635 "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
619 636 "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
620 637 "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
621 638 "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
622 639 "checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b"
623 640 "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071"
624 641 "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44"
625 642 "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c"
626 643 "checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098"
627 644 "checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
628 645 "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
629 646 "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
630 647 "checksum regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8"
631 648 "checksum regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06"
632 649 "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
633 650 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
651 "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
634 652 "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
635 653 "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
636 654 "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
637 655 "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
638 656 "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
639 657 "checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
640 658 "checksum twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56"
641 659 "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
642 660 "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
643 661 "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
644 662 "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
663 "checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
645 664 "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
@@ -1,24 +1,25 b''
1 1 [package]
2 2 name = "hg-core"
3 3 version = "0.1.0"
4 4 authors = ["Georges Racinet <gracinet@anybox.fr>"]
5 5 description = "Mercurial pure Rust core library, with no assumption on Python bindings (FFI)"
6 6 edition = "2018"
7 7
8 8 [lib]
9 9 name = "hg"
10 10
11 11 [dependencies]
12 12 byteorder = "1.3.1"
13 13 hex = "0.4.0"
14 14 lazy_static = "1.3.0"
15 15 memchr = "2.2.0"
16 16 rand = "0.6.5"
17 17 rand_pcg = "0.1.1"
18 18 rayon = "1.3.0"
19 19 regex = "1.1.0"
20 20 twox-hash = "1.5.0"
21 same-file = "1.0.6"
21 22
22 23 [dev-dependencies]
23 24 tempfile = "3.1.0"
24 25 pretty_assertions = "0.6.1" No newline at end of file
@@ -1,238 +1,384 b''
1 1 // files.rs
2 2 //
3 3 // Copyright 2019
4 4 // Raphaël Gomès <rgomes@octobus.net>,
5 5 // Yuya Nishihara <yuya@tcha.org>
6 6 //
7 7 // This software may be used and distributed according to the terms of the
8 8 // GNU General Public License version 2 or any later version.
9 9
10 10 //! Functions for fiddling with files.
11 11
12 use crate::utils::hg_path::{HgPath, HgPathBuf};
13
14 use crate::utils::replace_slice;
12 use crate::utils::{
13 hg_path::{path_to_hg_path_buf, HgPath, HgPathBuf, HgPathError},
14 path_auditor::PathAuditor,
15 replace_slice,
16 };
15 17 use lazy_static::lazy_static;
18 use same_file::is_same_file;
19 use std::borrow::ToOwned;
16 20 use std::fs::Metadata;
17 21 use std::iter::FusedIterator;
18 use std::path::Path;
22 use std::ops::Deref;
23 use std::path::{Path, PathBuf};
19 24
20 25 pub fn get_path_from_bytes(bytes: &[u8]) -> &Path {
21 26 let os_str;
22 27 #[cfg(unix)]
23 28 {
24 29 use std::os::unix::ffi::OsStrExt;
25 30 os_str = std::ffi::OsStr::from_bytes(bytes);
26 31 }
27 32 // TODO Handle other platforms
28 33 // TODO: convert from WTF8 to Windows MBCS (ANSI encoding).
29 34 // Perhaps, the return type would have to be Result<PathBuf>.
30 35
31 36 Path::new(os_str)
32 37 }
33 38
34 39 // TODO: need to convert from WTF8 to MBCS bytes on Windows.
35 40 // that's why Vec<u8> is returned.
36 41 #[cfg(unix)]
37 42 pub fn get_bytes_from_path(path: impl AsRef<Path>) -> Vec<u8> {
38 43 use std::os::unix::ffi::OsStrExt;
39 44 path.as_ref().as_os_str().as_bytes().to_vec()
40 45 }
41 46
42 47 /// An iterator over repository path yielding itself and its ancestors.
43 48 #[derive(Copy, Clone, Debug)]
44 49 pub struct Ancestors<'a> {
45 50 next: Option<&'a HgPath>,
46 51 }
47 52
48 53 impl<'a> Iterator for Ancestors<'a> {
49 54 type Item = &'a HgPath;
50 55
51 56 fn next(&mut self) -> Option<Self::Item> {
52 57 let next = self.next;
53 58 self.next = match self.next {
54 59 Some(s) if s.is_empty() => None,
55 60 Some(s) => {
56 61 let p = s.bytes().rposition(|c| *c == b'/').unwrap_or(0);
57 62 Some(HgPath::new(&s.as_bytes()[..p]))
58 63 }
59 64 None => None,
60 65 };
61 66 next
62 67 }
63 68 }
64 69
65 70 impl<'a> FusedIterator for Ancestors<'a> {}
66 71
67 72 /// An iterator over repository path yielding itself and its ancestors.
68 73 #[derive(Copy, Clone, Debug)]
69 74 pub(crate) struct AncestorsWithBase<'a> {
70 75 next: Option<(&'a HgPath, &'a HgPath)>,
71 76 }
72 77
73 78 impl<'a> Iterator for AncestorsWithBase<'a> {
74 79 type Item = (&'a HgPath, &'a HgPath);
75 80
76 81 fn next(&mut self) -> Option<Self::Item> {
77 82 let next = self.next;
78 83 self.next = match self.next {
79 84 Some((s, _)) if s.is_empty() => None,
80 85 Some((s, _)) => Some(s.split_filename()),
81 86 None => None,
82 87 };
83 88 next
84 89 }
85 90 }
86 91
87 92 impl<'a> FusedIterator for AncestorsWithBase<'a> {}
88 93
89 94 /// Returns an iterator yielding ancestor directories of the given repository
90 95 /// path.
91 96 ///
92 97 /// The path is separated by '/', and must not start with '/'.
93 98 ///
94 99 /// The path itself isn't included unless it is b"" (meaning the root
95 100 /// directory.)
96 101 pub fn find_dirs<'a>(path: &'a HgPath) -> Ancestors<'a> {
97 102 let mut dirs = Ancestors { next: Some(path) };
98 103 if !path.is_empty() {
99 104 dirs.next(); // skip itself
100 105 }
101 106 dirs
102 107 }
103 108
104 109 /// Returns an iterator yielding ancestor directories of the given repository
105 110 /// path.
106 111 ///
107 112 /// The path is separated by '/', and must not start with '/'.
108 113 ///
109 114 /// The path itself isn't included unless it is b"" (meaning the root
110 115 /// directory.)
111 116 pub(crate) fn find_dirs_with_base<'a>(
112 117 path: &'a HgPath,
113 118 ) -> AncestorsWithBase<'a> {
114 119 let mut dirs = AncestorsWithBase {
115 120 next: Some((path, HgPath::new(b""))),
116 121 };
117 122 if !path.is_empty() {
118 123 dirs.next(); // skip itself
119 124 }
120 125 dirs
121 126 }
122 127
123 128 /// TODO more than ASCII?
124 129 pub fn normalize_case(path: &HgPath) -> HgPathBuf {
125 130 #[cfg(windows)] // NTFS compares via upper()
126 131 return path.to_ascii_uppercase();
127 132 #[cfg(unix)]
128 133 path.to_ascii_lowercase()
129 134 }
130 135
131 136 lazy_static! {
132 137 static ref IGNORED_CHARS: Vec<Vec<u8>> = {
133 138 [
134 139 0x200c, 0x200d, 0x200e, 0x200f, 0x202a, 0x202b, 0x202c, 0x202d,
135 140 0x202e, 0x206a, 0x206b, 0x206c, 0x206d, 0x206e, 0x206f, 0xfeff,
136 141 ]
137 142 .iter()
138 143 .map(|code| {
139 144 std::char::from_u32(*code)
140 145 .unwrap()
141 146 .encode_utf8(&mut [0; 3])
142 147 .bytes()
143 148 .collect()
144 149 })
145 150 .collect()
146 151 };
147 152 }
148 153
149 154 fn hfs_ignore_clean(bytes: &[u8]) -> Vec<u8> {
150 155 let mut buf = bytes.to_owned();
151 156 let needs_escaping = bytes.iter().any(|b| *b == b'\xe2' || *b == b'\xef');
152 157 if needs_escaping {
153 158 for forbidden in IGNORED_CHARS.iter() {
154 159 replace_slice(&mut buf, forbidden, &[])
155 160 }
156 161 buf
157 162 } else {
158 163 buf
159 164 }
160 165 }
161 166
162 167 pub fn lower_clean(bytes: &[u8]) -> Vec<u8> {
163 168 hfs_ignore_clean(&bytes.to_ascii_lowercase())
164 169 }
165 170
166 171 #[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone)]
167 172 pub struct HgMetadata {
168 173 pub st_dev: u64,
169 174 pub st_mode: u32,
170 175 pub st_nlink: u64,
171 176 pub st_size: u64,
172 177 pub st_mtime: i64,
173 178 pub st_ctime: i64,
174 179 }
175 180
176 181 // TODO support other plaforms
177 182 #[cfg(unix)]
178 183 impl HgMetadata {
179 184 pub fn from_metadata(metadata: Metadata) -> Self {
180 185 use std::os::unix::fs::MetadataExt;
181 186 Self {
182 187 st_dev: metadata.dev(),
183 188 st_mode: metadata.mode(),
184 189 st_nlink: metadata.nlink(),
185 190 st_size: metadata.size(),
186 191 st_mtime: metadata.mtime(),
187 192 st_ctime: metadata.ctime(),
188 193 }
189 194 }
190 195 }
191 196
197 /// Returns the canonical path of `name`, given `cwd` and `root`
198 pub fn canonical_path(
199 root: impl AsRef<Path>,
200 cwd: impl AsRef<Path>,
201 name: impl AsRef<Path>,
202 ) -> Result<PathBuf, HgPathError> {
203 // TODO add missing normalization for other platforms
204 let root = root.as_ref();
205 let cwd = cwd.as_ref();
206 let name = name.as_ref();
207
208 let name = if !name.is_absolute() {
209 root.join(&cwd).join(&name)
210 } else {
211 name.to_owned()
212 };
213 let mut auditor = PathAuditor::new(&root);
214 if name != root && name.starts_with(&root) {
215 let name = name.strip_prefix(&root).unwrap();
216 auditor.audit_path(path_to_hg_path_buf(name)?)?;
217 return Ok(name.to_owned());
218 } else if name == root {
219 return Ok("".into());
220 } else {
221 // Determine whether `name' is in the hierarchy at or beneath `root',
222 // by iterating name=name.parent() until it returns `None` (can't
223 // check name == '/', because that doesn't work on windows).
224 let mut name = name.deref();
225 let original_name = name.to_owned();
226 loop {
227 let same = is_same_file(&name, &root).unwrap_or(false);
228 if same {
229 if name == original_name {
230 // `name` was actually the same as root (maybe a symlink)
231 return Ok("".into());
232 }
233 // `name` is a symlink to root, so `original_name` is under
234 // root
235 let rel_path = original_name.strip_prefix(&name).unwrap();
236 auditor.audit_path(path_to_hg_path_buf(&rel_path)?)?;
237 return Ok(rel_path.to_owned());
238 }
239 name = match name.parent() {
240 None => break,
241 Some(p) => p,
242 };
243 }
244 // TODO hint to the user about using --cwd
245 // Bubble up the responsibility to Python for now
246 Err(HgPathError::NotUnderRoot {
247 path: original_name.to_owned(),
248 root: root.to_owned(),
249 })
250 }
251 }
252
192 253 #[cfg(test)]
193 254 mod tests {
194 255 use super::*;
256 use pretty_assertions::assert_eq;
195 257
196 258 #[test]
197 259 fn find_dirs_some() {
198 260 let mut dirs = super::find_dirs(HgPath::new(b"foo/bar/baz"));
199 261 assert_eq!(dirs.next(), Some(HgPath::new(b"foo/bar")));
200 262 assert_eq!(dirs.next(), Some(HgPath::new(b"foo")));
201 263 assert_eq!(dirs.next(), Some(HgPath::new(b"")));
202 264 assert_eq!(dirs.next(), None);
203 265 assert_eq!(dirs.next(), None);
204 266 }
205 267
206 268 #[test]
207 269 fn find_dirs_empty() {
208 270 // looks weird, but mercurial.pathutil.finddirs(b"") yields b""
209 271 let mut dirs = super::find_dirs(HgPath::new(b""));
210 272 assert_eq!(dirs.next(), Some(HgPath::new(b"")));
211 273 assert_eq!(dirs.next(), None);
212 274 assert_eq!(dirs.next(), None);
213 275 }
214 276
215 277 #[test]
216 278 fn test_find_dirs_with_base_some() {
217 279 let mut dirs = super::find_dirs_with_base(HgPath::new(b"foo/bar/baz"));
218 280 assert_eq!(
219 281 dirs.next(),
220 282 Some((HgPath::new(b"foo/bar"), HgPath::new(b"baz")))
221 283 );
222 284 assert_eq!(
223 285 dirs.next(),
224 286 Some((HgPath::new(b"foo"), HgPath::new(b"bar")))
225 287 );
226 288 assert_eq!(dirs.next(), Some((HgPath::new(b""), HgPath::new(b"foo"))));
227 289 assert_eq!(dirs.next(), None);
228 290 assert_eq!(dirs.next(), None);
229 291 }
230 292
231 293 #[test]
232 294 fn test_find_dirs_with_base_empty() {
233 295 let mut dirs = super::find_dirs_with_base(HgPath::new(b""));
234 296 assert_eq!(dirs.next(), Some((HgPath::new(b""), HgPath::new(b""))));
235 297 assert_eq!(dirs.next(), None);
236 298 assert_eq!(dirs.next(), None);
237 299 }
300
301 #[test]
302 fn test_canonical_path() {
303 let root = Path::new("/repo");
304 let cwd = Path::new("/dir");
305 let name = Path::new("filename");
306 assert_eq!(
307 canonical_path(root, cwd, name),
308 Err(HgPathError::NotUnderRoot {
309 path: PathBuf::from("/dir/filename"),
310 root: root.to_path_buf()
311 })
312 );
313
314 let root = Path::new("/repo");
315 let cwd = Path::new("/");
316 let name = Path::new("filename");
317 assert_eq!(
318 canonical_path(root, cwd, name),
319 Err(HgPathError::NotUnderRoot {
320 path: PathBuf::from("/filename"),
321 root: root.to_path_buf()
322 })
323 );
324
325 let root = Path::new("/repo");
326 let cwd = Path::new("/");
327 let name = Path::new("repo/filename");
328 assert_eq!(
329 canonical_path(root, cwd, name),
330 Ok(PathBuf::from("filename"))
331 );
332
333 let root = Path::new("/repo");
334 let cwd = Path::new("/repo");
335 let name = Path::new("filename");
336 assert_eq!(
337 canonical_path(root, cwd, name),
338 Ok(PathBuf::from("filename"))
339 );
340
341 let root = Path::new("/repo");
342 let cwd = Path::new("/repo/subdir");
343 let name = Path::new("filename");
344 assert_eq!(
345 canonical_path(root, cwd, name),
346 Ok(PathBuf::from("subdir/filename"))
347 );
348 }
349
350 #[test]
351 fn test_canonical_path_not_rooted() {
352 use std::fs::create_dir;
353 use tempfile::tempdir;
354
355 let base_dir = tempdir().unwrap();
356 let base_dir_path = base_dir.path();
357 let beneath_repo = base_dir_path.join("a");
358 let root = base_dir_path.join("a/b");
359 let out_of_repo = base_dir_path.join("c");
360 let under_repo_symlink = out_of_repo.join("d");
361
362 create_dir(&beneath_repo).unwrap();
363 create_dir(&root).unwrap();
364
365 // TODO make portable
366 std::os::unix::fs::symlink(&root, &out_of_repo).unwrap();
367
368 assert_eq!(
369 canonical_path(&root, Path::new(""), out_of_repo),
370 Ok(PathBuf::from(""))
371 );
372 assert_eq!(
373 canonical_path(&root, Path::new(""), &beneath_repo),
374 Err(HgPathError::NotUnderRoot {
375 path: beneath_repo.to_owned(),
376 root: root.to_owned()
377 })
378 );
379 assert_eq!(
380 canonical_path(&root, Path::new(""), &under_repo_symlink),
381 Ok(PathBuf::from("d"))
382 );
383 }
238 384 }
General Comments 0
You need to be logged in to leave comments. Login now