Debian Codegraph @

tests/test-rhg.t

raw
1 #require rhg
2
3 $ NO_FALLBACK="env RHG_ON_UNSUPPORTED=abort"
4
5 #if no-rust
6 It is possible to run a `rhg` backed by any `hg` including ones without support
7 for rust extensions. We still want to be able to use rust related feature in that case.
8 $ echo "[storage]" >> $HGRCPATH
9 $ echo "all-slow-path=allow" >> $HGRCPATH
10 #endif
11
12 Unimplemented command
13 $ $NO_FALLBACK rhg unimplemented-command
14 unsupported feature: error: unrecognized subcommand 'unimplemented-command'
15
16 Usage: rhg [OPTIONS] <COMMAND>
17
18 For more information, try '--help'.
19
20 [252]
21 $ rhg unimplemented-command --config rhg.on-unsupported=abort-silent
22 [252]
23
24 Finding root
25 $ $NO_FALLBACK rhg root
26 abort: no repository found in '$TESTTMP' (.hg not found)!
27 [255]
28
29 $ hg init repository
30 $ cd repository
31 $ $NO_FALLBACK rhg root
32 $TESTTMP/repository
33
34 Reading and setting configuration
35 $ echo "[ui]" >> $HGRCPATH
36 $ echo "username = user1" >> $HGRCPATH
37 $ echo "[extensions]" >> $HGRCPATH
38 $ echo "sparse =" >> $HGRCPATH
39 $ $NO_FALLBACK rhg config ui.username
40 user1
41 $ echo "[ui]" >> .hg/hgrc
42 $ echo "username = user2" >> .hg/hgrc
43 $ $NO_FALLBACK rhg config ui.username
44 user2
45 $ $NO_FALLBACK rhg --config ui.username=user3 config ui.username
46 user3
47
48 Alias to command
49 $ $NO_FALLBACK rhg foo --config alias.foo=root
50 $TESTTMP/repository
51 $ $NO_FALLBACK rhg --config alias.foo=root foo
52 $TESTTMP/repository
53
54 Alias that shadows an existing command
55 $ $NO_FALLBACK rhg status --config alias.status=root
56 $TESTTMP/repository
57
58 Alias to command with arguments
59 $ $NO_FALLBACK rhg foo --config alias.foo="config ui.username"
60 user2
61
62 Alias to command with arguments, shell quoted
63 $ $NO_FALLBACK rhg foo --config alias.foo="\"config\" ui.username"
64 user2
65 $ $NO_FALLBACK rhg foo --config alias.foo="\"config ui.username"
66 config error: error in definition for alias 'foo': invalid quotation or escape
67 [30]
68
69 Alias that adds arguments to command
70 $ $NO_FALLBACK rhg config --config alias.config="config ui.username"
71 user2
72
73 Shell alias
74 $ $NO_FALLBACK rhg foo --config alias.foo="!echo hello"
75 unsupported feature: shell alias
76 [252]
77
78 Alias interpolation
79 $ $NO_FALLBACK rhg foo --config alias.foo='status $1'
80 unsupported feature: alias interpolation
81 [252]
82
83 Alias to another alias (can only refer to earlier one)
84 $ $NO_FALLBACK rhg foo --config alias.bar=root --config alias.foo=bar
85 $TESTTMP/repository
86 $ $NO_FALLBACK rhg foo --config alias.foo=bar --config alias.bar=root 2>&1 | grep "unrecognized subcommand 'bar'"
87 unsupported feature: error: unrecognized subcommand 'bar'
88
89 Unwritable file descriptor
90 $ $NO_FALLBACK rhg root > /dev/full
91 abort: No space left on device (os error 28)
92 [255]
93
94 Deleted repository
95 $ rm -rf `pwd`
96 $ $NO_FALLBACK rhg root
97 abort: error getting current working directory: $ENOENT$
98 [255]
99
100 Listing tracked files
101 $ cd $TESTTMP
102 $ hg init repository
103 $ cd repository
104 $ for i in 1 2 3; do
105 > echo $i >> file$i
106 > hg add file$i
107 > done
108 > hg commit -m "commit $i" -q
109
110 Listing tracked files from root
111 $ $NO_FALLBACK rhg files
112 file1
113 file2
114 file3
115
116 Listing tracked files with NUL delimiters.
117 $ $NO_FALLBACK rhg files -0 | xargs -0n1
118 file1
119 file2
120 file3
121
122 Repeated flag is allowed
123 $ $NO_FALLBACK rhg files -0 -0 | xargs -0n1
124 file1
125 file2
126 file3
127
128 Repeating argument takes the last value
129 $ $NO_FALLBACK rhg files --rev '.^' --rev .
130 file1
131 file2
132 file3
133
134 Listing tracked files from subdirectory
135 $ mkdir -p path/to/directory
136 $ cd path/to/directory
137 $ $NO_FALLBACK rhg files
138 ../../../file1
139 ../../../file2
140 ../../../file3
141
142 $ $NO_FALLBACK rhg files --config ui.relative-paths=legacy
143 ../../../file1
144 ../../../file2
145 ../../../file3
146
147 $ $NO_FALLBACK rhg files --config ui.relative-paths=false
148 file1
149 file2
150 file3
151
152 $ $NO_FALLBACK rhg files --config ui.relative-paths=true
153 ../../../file1
154 ../../../file2
155 ../../../file3
156
157 Listing tracked files through broken pipe
158 $ $NO_FALLBACK rhg files | head -n 1
159 ../../../file1
160
161 Status with --rev and --change
162 $ cd $TESTTMP/repository
163 $ $NO_FALLBACK rhg status --change null
164 $ $NO_FALLBACK rhg status --change 0
165 A file1
166 A file2
167 A file3
168 $ $NO_FALLBACK rhg status --rev null --rev 0
169 A file1
170 A file2
171 A file3
172
173 Status with --change --copies
174 $ hg copy file2 file2copy
175 $ hg rename file3 file3rename
176 $ hg commit -m "commit 4" -q
177 $ $NO_FALLBACK rhg status --change . --copies
178 A file2copy
179 file2
180 A file3rename
181 file3
182 R file3
183
184 Debuging data in inline index
185 $ cd $TESTTMP
186 $ rm -rf repository
187 $ hg init repository
188 $ cd repository
189 $ for i in 1 2 3 4 5 6; do
190 > echo $i >> file-$i
191 > hg add file-$i
192 > hg commit -m "Commit $i" -q
193 > done
194 $ $NO_FALLBACK rhg debugdata -c 2
195 8d0267cb034247ebfa5ee58ce59e22e57a492297
196 test
197 0 0
198 file-3
199
200 Commit 3 (no-eol)
201 $ $NO_FALLBACK rhg debugdata -m 2
202 file-1\x00b8e02f6433738021a065f94175c7cd23db5f05be (esc)
203 file-2\x005d9299349fc01ddd25d0070d149b124d8f10411e (esc)
204 file-3\x002661d26c649684b482d10f91960cc3db683c38b4 (esc)
205
206 Debuging with full node id
207 $ $NO_FALLBACK rhg debugdata -c `hg log -r 0 -T '{node}'`
208 d1d1c679d3053e8926061b6f45ca52009f011e3f
209 test
210 0 0
211 file-1
212
213 Commit 1 (no-eol)
214
215 Specifying revisions by changeset ID
216 $ hg log -T '{node}\n'
217 c6ad58c44207b6ff8a4fbbca7045a5edaa7e908b
218 d654274993d0149eecc3cc03214f598320211900
219 f646af7e96481d3a5470b695cf30ad8e3ab6c575
220 cf8b83f14ead62b374b6e91a0e9303b85dfd9ed7
221 91c6f6e73e39318534dc415ea4e8a09c99cd74d6
222 6ae9681c6d30389694d8701faf24b583cf3ccafe
223 $ $NO_FALLBACK rhg files -r cf8b83
224 file-1
225 file-2
226 file-3
227 $ $NO_FALLBACK rhg cat -r cf8b83 file-2
228 2
229 $ $NO_FALLBACK rhg cat --rev cf8b83 file-2
230 2
231 $ $NO_FALLBACK rhg cat -r c file-2
232 abort: ambiguous revision identifier: c
233 [255]
234 $ $NO_FALLBACK rhg cat -r d file-2
235 2
236 $ $NO_FALLBACK rhg cat -r 0000 file-2
237 file-2: no such file in rev 000000000000
238 [1]
239
240 Cat files
241 $ cd $TESTTMP
242 $ rm -rf repository
243 $ hg init repository
244 $ cd repository
245 $ echo "original content" > original
246 $ hg add original
247 $ hg commit -m "add original" original
248 Without `--rev`
249 $ $NO_FALLBACK rhg cat original
250 original content
251 With `--rev`
252 $ $NO_FALLBACK rhg cat -r 0 original
253 original content
254 Cat copied file should not display copy metadata
255 $ hg copy original copy_of_original
256 $ hg commit -m "add copy of original"
257 $ $NO_FALLBACK rhg cat original
258 original content
259 $ $NO_FALLBACK rhg cat -r 1 copy_of_original
260 original content
261
262 Annotate files
263 $ $NO_FALLBACK rhg annotate original
264 0: original content
265 $ $NO_FALLBACK rhg annotate --rev . --user --file --date --number --changeset \
266 > --line-number --text --no-follow --ignore-all-space --ignore-space-change \
267 > --ignore-blank-lines --ignore-space-at-eol original
268 test 0 1c9e69808da7 Thu Jan 01 00:00:00 1970 +0000 original:1: original content
269 $ $NO_FALLBACK rhg blame -r . -ufdnclawbBZ --no-follow original
270 test 0 1c9e69808da7 Thu Jan 01 00:00:00 1970 +0000 original:1: original content
271 $ $NO_FALLBACK rhg annotate -r 'wdir()' original
272 0 : original content
273 $ $NO_FALLBACK rhg annotate -Tjson original
274 [
275 {
276 "lines": [{"line": "original content\n", "rev": 0}],
277 "path": "original"
278 }
279 ]
280
281 Purge files
282 $ mkdir -p untracked/inner_untracked
283 $ touch untracked/inner_untracked/file
284 $ mkdir another_dir
285
286 $ $NO_FALLBACK rhg purge -p --no-confirm
287 untracked/inner_untracked/file
288 untracked/inner_untracked
289 untracked
290 another_dir
291 $ $NO_FALLBACK rhg purge -p --files --no-confirm
292 untracked/inner_untracked/file
293 $ $NO_FALLBACK rhg purge -p --dirs --no-confirm
294 another_dir
295 $ $NO_FALLBACK rhg purge -v --no-confirm
296 removing file untracked/inner_untracked/file
297 removing directory untracked/inner_untracked
298 removing directory untracked
299 removing directory another_dir
300
301 $ ls
302 copy_of_original
303 original
304
305 Fallback to Python
306 $ $NO_FALLBACK rhg cat original --exclude="*.rs"
307 unsupported feature: error: unexpected argument '--exclude' found
308
309 tip: to pass '--exclude' as a value, use '-- --exclude'
310
311 Usage: rhg cat <FILE>...
312
313 For more information, try '--help'.
314
315 [252]
316 $ rhg cat original --exclude="*.rs"
317 original content
318
319 Check that `fallback-immediately` overrides `$NO_FALLBACK`
320 $ $NO_FALLBACK rhg cat original --exclude="*.rs" --config rhg.fallback-immediately=1
321 original content
322
323 $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original --exclude="*.rs")
324 abort: 'rhg.on-unsupported=fallback' without 'rhg.fallback-executable' set.
325 [255]
326
327 $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original)
328 original content
329
330 $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=false
331 [1]
332
333 $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=hg-non-existent
334 abort: invalid fallback 'hg-non-existent': cannot find binary path
335 [253]
336
337 $ rhg cat original --exclude="*.rs" --config rhg.fallback-executable=rhg
338 Blocking recursive fallback. The 'rhg.fallback-executable = rhg' config points to `rhg` itself.
339 unsupported feature: error: unexpected argument '--exclude' found
340
341 tip: to pass '--exclude' as a value, use '-- --exclude'
342
343 Usage: rhg cat <FILE>...
344
345 For more information, try '--help'.
346
347 [252]
348
349 Fallback with shell path segments
350 $ $NO_FALLBACK rhg cat .
351 unsupported feature: `..` or `.` path segment
352 [252]
353 $ $NO_FALLBACK rhg cat ..
354 unsupported feature: `..` or `.` path segment
355 [252]
356 $ $NO_FALLBACK rhg cat ../..
357 unsupported feature: `..` or `.` path segment
358 [252]
359
360 Fallback with filesets
361 $ $NO_FALLBACK rhg cat "set:c or b"
362 unsupported feature: rhg does not support file patterns
363 [252]
364
365 Fallback with generic hooks
366 $ $NO_FALLBACK rhg cat original --config hooks.pre-cat=something
367 unsupported feature: pre-cat hook defined
368 [252]
369
370 $ $NO_FALLBACK rhg cat original --config hooks.post-cat=something
371 unsupported feature: post-cat hook defined
372 [252]
373
374 $ $NO_FALLBACK rhg cat original --config hooks.fail-cat=something
375 unsupported feature: fail-cat hook defined
376 [252]
377
378 Fallback with [defaults]
379 $ $NO_FALLBACK rhg cat original --config "defaults.cat=-r null"
380 unsupported feature: `defaults` config set
381 [252]
382
383
384 Requirements
385 $ $NO_FALLBACK rhg debugrequirements
386 dotencode
387 fncache
388 generaldelta
389 persistent-nodemap (rust !)
390 revlog-compression-zstd (zstd !)
391 revlogv1
392 share-safe
393 sparserevlog
394 store
395
396 $ echo indoor-pool >> .hg/requires
397 $ $NO_FALLBACK rhg files
398 unsupported feature: repository requires feature unknown to this Mercurial: indoor-pool
399 [252]
400
401 $ $NO_FALLBACK rhg cat -r 1 copy_of_original
402 unsupported feature: repository requires feature unknown to this Mercurial: indoor-pool
403 [252]
404
405 $ $NO_FALLBACK rhg debugrequirements
406 unsupported feature: repository requires feature unknown to this Mercurial: indoor-pool
407 [252]
408
409 $ echo -e '\xFF' >> .hg/requires
410 $ $NO_FALLBACK rhg debugrequirements
411 abort: parse error in 'requires' file
412 [255]
413
414 Persistent nodemap
415 $ cd $TESTTMP
416 $ rm -rf repository
417 $ hg --config format.use-persistent-nodemap=no init repository
418 $ cd repository
419 $ $NO_FALLBACK rhg debugrequirements | grep nodemap
420 [1]
421 $ hg debugbuilddag .+5000 --overwritten-file --config "storage.revlog.nodemap.mode=warn"
422 $ hg id -r tip
423 c3ae8dec9fad tip
424 $ ls .hg/store/00changelog*
425 .hg/store/00changelog.d
426 .hg/store/00changelog.i
427 $ $NO_FALLBACK rhg files -r c3ae8dec9fad
428 of
429
430 $ cd $TESTTMP
431 $ rm -rf repository
432 $ hg --config format.use-persistent-nodemap=True init repository
433 $ cd repository
434 $ $NO_FALLBACK rhg debugrequirements | grep nodemap
435 persistent-nodemap
436 $ hg debugbuilddag .+5000 --overwritten-file --config "storage.revlog.nodemap.mode=warn"
437 $ hg id -r tip
438 c3ae8dec9fad tip
439 $ ls .hg/store/00changelog*
440 .hg/store/00changelog-*.nd (glob)
441 .hg/store/00changelog.d
442 .hg/store/00changelog.i
443 .hg/store/00changelog.n
444
445 Rhg status on a sparse repo with nodemap (this specific combination used to crash in 6.5.2)
446
447 $ hg debugsparse -X excluded-dir
448 $ $NO_FALLBACK rhg status
449
450 Specifying revisions by changeset ID
451 $ $NO_FALLBACK rhg files -r c3ae8dec9fad
452 of
453 $ $NO_FALLBACK rhg cat -r c3ae8dec9fad of
454 r5000
455
456 Crate a shared repository
457
458 $ echo "[extensions]" >> $HGRCPATH
459 $ echo "share = " >> $HGRCPATH
460
461 $ cd $TESTTMP
462 $ hg init repo1
463 $ echo a > repo1/a
464 $ hg -R repo1 commit -A -m'init'
465 adding a
466
467 $ hg share repo1 repo2
468 updating working directory
469 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
470
471 And check that basic rhg commands work with sharing
472
473 $ $NO_FALLBACK rhg files -R repo2
474 repo2/a
475 $ $NO_FALLBACK rhg -R repo2 cat -r 0 repo2/a
476 a
477
478 Same with relative sharing
479
480 $ hg share repo2 repo3 --relative
481 updating working directory
482 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
483
484 $ $NO_FALLBACK rhg files -R repo3
485 repo3/a
486 $ $NO_FALLBACK rhg -R repo3 cat -r 0 repo3/a
487 a
488
489 Same with share-safe
490
491 $ echo "[format]" >> $HGRCPATH
492 $ echo "use-share-safe = True" >> $HGRCPATH
493
494 $ cd $TESTTMP
495 $ hg init repo4
496 $ cd repo4
497 $ echo a > a
498 $ hg commit -A -m'init'
499 adding a
500
501 $ cd ..
502 $ hg share repo4 repo5
503 updating working directory
504 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
505
506 And check that basic rhg commands work with sharing
507
508 $ cd repo5
509 $ $NO_FALLBACK rhg files
510 a
511 $ $NO_FALLBACK rhg cat -r 0 a
512 a
513
514 The blackbox extension is supported
515
516 $ echo "[extensions]" >> $HGRCPATH
517 $ echo "blackbox =" >> $HGRCPATH
518 $ echo "[blackbox]" >> $HGRCPATH
519 $ echo "maxsize = 1" >> $HGRCPATH
520 $ $NO_FALLBACK rhg files > /dev/null
521 $ cat .hg/blackbox.log
522 ????-??-?? ??:??:??.??? * @d3873e73d99ef67873dac33fbcc66268d5d2b6f4 (*)> (rust) files exited 0 after * seconds (glob)
523 $ cat .hg/blackbox.log.1
524 ????-??-?? ??:??:??.??? * @d3873e73d99ef67873dac33fbcc66268d5d2b6f4 (*)> (rust) files (glob)
525
526 Subrepos are not supported
527
528 $ touch .hgsub
529 $ $NO_FALLBACK rhg files
530 unsupported feature: subrepos (.hgsub is present)
531 [252]
532 $ rhg files
533 a
534 $ rm .hgsub
535
536 The `:required` extension suboptions are correctly ignored
537
538 $ echo "[extensions]" >> $HGRCPATH
539 $ echo "blackbox:required = yes" >> $HGRCPATH
540 $ rhg files
541 a
542 $ echo "*:required = yes" >> $HGRCPATH
543 $ rhg files
544 a
545
546 Check that we expand both user and environment in ignore includes (HOME is TESTTMP)
547
548 $ echo "specificprefix" > ~/ignore.expected-extension
549 $ touch specificprefix
550 $ $NO_FALLBACK rhg st
551 ? specificprefix
552 $ $NO_FALLBACK RHG_EXT_TEST=expected-extension rhg st --config 'ui.ignore=~/ignore.${RHG_EXT_TEST}'
553
554 We can ignore all extensions at once
555
556 $ echo "[extensions]" >> $HGRCPATH
557 $ echo "thisextensionbetternotexist=" >> $HGRCPATH
558 $ echo "thisextensionbetternotexisteither=" >> $HGRCPATH
559 $ $NO_FALLBACK rhg files
560 unsupported feature: extensions: thisextensionbetternotexist, thisextensionbetternotexisteither (consider adding them to 'rhg.ignored-extensions' config)
561 [252]
562
563 $ echo "[rhg]" >> $HGRCPATH
564 $ echo "ignored-extensions=*" >> $HGRCPATH
565 $ $NO_FALLBACK rhg files
566 a
567
568 Latin-1 is not supported yet
569
570 $ $NO_FALLBACK HGENCODING=latin-1 rhg root
571 unsupported feature: HGENCODING value 'latin-1' is not supported
572 [252]
573
574
575 Cleanup the hgrc from constraint
576 ================================
577
578 (This confuse `hghave` when trying to match line later. This is obviously more
579 a bug in `run-tests/hghave` than this specific test, but its easy enough to
580 disarm it here.
581
582 $ echo "[extensions]" >> $HGRCPATH
583 $ echo "*:required = no" >> $HGRCPATH