Mercurial > hg
annotate tests/test-cat.t @ 51460:cebd96dee99a
branchcache: move the filename to a class attribute
This prepare the introduction of more variant of cache.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 25 Feb 2024 20:40:37 +0100 |
parents | 55c6ebd11cb9 |
children |
rev | line source |
---|---|
49621
55c6ebd11cb9
tests: run many tests in $TESTTMP/repo instead of $TESTTMP
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
39369
diff
changeset
|
1 $ hg init repo |
55c6ebd11cb9
tests: run many tests in $TESTTMP/repo instead of $TESTTMP
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
39369
diff
changeset
|
2 $ cd repo |
11874 | 3 $ echo 0 > a |
4 $ echo 0 > b | |
12156
4c94b6d0fb1c
tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
5 $ hg ci -A -m m |
11874 | 6 adding a |
7 adding b | |
8 $ hg rm a | |
9 $ hg cat a | |
10 0 | |
11 $ hg cat --decode a # more tests in test-encode | |
12 0 | |
13 $ echo 1 > b | |
12156
4c94b6d0fb1c
tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
14 $ hg ci -m m |
11874 | 15 $ echo 2 > b |
16 $ hg cat -r 0 a | |
17 0 | |
18 $ hg cat -r 0 b | |
19 0 | |
20 $ hg cat -r 1 a | |
12156
4c94b6d0fb1c
tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents:
12070
diff
changeset
|
21 a: no such file in rev 7040230c159c |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
22 [1] |
11874 | 23 $ hg cat -r 1 b |
24 1 | |
17371
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
25 |
24381
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
26 Test multiple files |
17371
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
27 |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
28 $ echo 3 > c |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
29 $ hg ci -Am addmore c |
24381
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
30 $ hg cat b c |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
31 1 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
32 3 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
33 $ hg cat . |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
34 1 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
35 3 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
36 $ hg cat . c |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
37 1 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
38 3 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
39 |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
40 Test fileset |
82b82168d045
context.walk: walk all files when file and '.' given
Martin von Zweigbergk <martinvonz@google.com>
parents:
21078
diff
changeset
|
41 |
17371
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
42 $ hg cat 'set:not(b) or a' |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
43 3 |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
44 $ hg cat 'set:c or b' |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
45 1 |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
46 3 |
1310489eb5d6
fileset: fix generator vs list bug in fast path
Patrick Mezard <patrick@mezard.eu>
parents:
12316
diff
changeset
|
47 |
21078
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
48 $ mkdir tmp |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
49 $ hg cat --output tmp/HH_%H c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
50 $ hg cat --output tmp/RR_%R c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
51 $ hg cat --output tmp/h_%h c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
52 $ hg cat --output tmp/r_%r c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
53 $ hg cat --output tmp/%s_s c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
54 $ hg cat --output tmp/%d%%_d c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
55 $ hg cat --output tmp/%p_p c |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
56 $ hg log -r . --template "{rev}: {node|short}\n" |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
57 2: 45116003780e |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
58 $ find tmp -type f | sort |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
59 tmp/.%_d |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
60 tmp/HH_45116003780e3678b333fb2c99fa7d559c8457e9 |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
61 tmp/RR_2 |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
62 tmp/c_p |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
63 tmp/c_s |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
64 tmp/h_45116003780e |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
65 tmp/r_2 |
50107a4b32e7
cat: explicitly document the supported formatter rules
Matt Harbison <matt_harbison@yahoo.com>
parents:
17371
diff
changeset
|
66 |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
67 Test template output |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
68 |
39369
34ba47117164
formatter: rename {abspath}/{file} to {path}, and drop relative {path} (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38539
diff
changeset
|
69 $ hg --cwd tmp cat ../b ../c -T '== {path|relpath} ({path}) r{rev} ==\n{data}' |
38539
b1bbff1dd99a
cat: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents:
35393
diff
changeset
|
70 == ../b (b) r2 == |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
71 1 |
38539
b1bbff1dd99a
cat: add support for log-like template keywords and functions
Yuya Nishihara <yuya@tcha.org>
parents:
35393
diff
changeset
|
72 == ../c (c) r2 == |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
73 3 |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
74 |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
75 $ hg cat b c -Tjson --output - |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
76 [ |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
77 { |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
78 "data": "1\n", |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
79 "path": "b" |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
80 }, |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
81 { |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
82 "data": "3\n", |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
83 "path": "c" |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
84 } |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
85 ] |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
86 |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
87 $ hg cat b c -Tjson --output 'tmp/%p.json' |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
88 $ cat tmp/b.json |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
89 [ |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
90 { |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
91 "data": "1\n", |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
92 "path": "b" |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
93 } |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
94 ] |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
95 $ cat tmp/c.json |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
96 [ |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
97 { |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
98 "data": "3\n", |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
99 "path": "c" |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
100 } |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
101 ] |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
30833
diff
changeset
|
102 |
24720
c560d8c68791
cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
24381
diff
changeset
|
103 Test working directory |
c560d8c68791
cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
24381
diff
changeset
|
104 |
c560d8c68791
cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
24381
diff
changeset
|
105 $ echo b-wdir > b |
c560d8c68791
cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
24381
diff
changeset
|
106 $ hg cat -r 'wdir()' b |
c560d8c68791
cat: disable optimization of single file case for workingctx
Yuya Nishihara <yuya@tcha.org>
parents:
24381
diff
changeset
|
107 b-wdir |
30833
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
108 |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
109 Environment variables are not visible by default |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
110 |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
111 $ PATTERN='t4' hg log -r '.' -T "{ifcontains('PATTERN', envvars, 'yes', 'no')}\n" |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
112 no |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
113 |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
114 Environment variable visibility can be explicit |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
115 |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
116 $ PATTERN='t4' hg log -r '.' -T "{envvars % '{key} -> {value}\n'}" \ |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
117 > --config "experimental.exportableenviron=PATTERN" |
bd5e9647f646
templater: add '{envvars}' to access environment variables
Matt Harbison <matt_harbison@yahoo.com>
parents:
24720
diff
changeset
|
118 PATTERN -> t4 |
35006
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
119 |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
120 Test behavior of output when directory structure does not already exist |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
121 |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
122 $ mkdir foo |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
123 $ echo a > foo/a |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
124 $ hg add foo/a |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
125 $ hg commit -qm "add foo/a" |
8154119ed236
cat: test output path behvaior when target path does not exist
Ryan McElroy <rmcelroy@fb.com>
parents:
32584
diff
changeset
|
126 $ hg cat --output "output/%p" foo/a |
35007
407ec7f3ff02
cmdutil: create dirs for templated cat file output
Ryan McElroy <rmcelroy@fb.com>
parents:
35006
diff
changeset
|
127 $ cat output/foo/a |
407ec7f3ff02
cmdutil: create dirs for templated cat file output
Ryan McElroy <rmcelroy@fb.com>
parents:
35006
diff
changeset
|
128 a |