2010-08-14 05:27:24 +04:00
|
|
|
$ hg init
|
|
|
|
$ echo 0 > a
|
|
|
|
$ echo 0 > b
|
2010-09-03 01:22:51 +04:00
|
|
|
$ hg ci -A -m m
|
2010-08-14 05:27:24 +04:00
|
|
|
adding a
|
|
|
|
adding b
|
|
|
|
$ hg rm a
|
|
|
|
$ hg cat a
|
|
|
|
0
|
|
|
|
$ hg cat --decode a # more tests in test-encode
|
|
|
|
0
|
|
|
|
$ echo 1 > b
|
2010-09-03 01:22:51 +04:00
|
|
|
$ hg ci -m m
|
2010-08-14 05:27:24 +04:00
|
|
|
$ echo 2 > b
|
|
|
|
$ hg cat -r 0 a
|
|
|
|
0
|
|
|
|
$ hg cat -r 0 b
|
|
|
|
0
|
|
|
|
$ hg cat -r 1 a
|
2010-09-03 01:22:51 +04:00
|
|
|
a: no such file in rev 7040230c159c
|
2010-09-17 02:51:32 +04:00
|
|
|
[1]
|
2010-08-14 05:27:24 +04:00
|
|
|
$ hg cat -r 1 b
|
|
|
|
1
|
2012-08-16 00:50:23 +04:00
|
|
|
|
2015-03-18 21:42:09 +03:00
|
|
|
Test multiple files
|
2012-08-16 00:50:23 +04:00
|
|
|
|
|
|
|
$ echo 3 > c
|
|
|
|
$ hg ci -Am addmore c
|
2015-03-18 21:42:09 +03:00
|
|
|
$ hg cat b c
|
|
|
|
1
|
|
|
|
3
|
|
|
|
$ hg cat .
|
|
|
|
1
|
|
|
|
3
|
|
|
|
$ hg cat . c
|
|
|
|
1
|
|
|
|
3
|
|
|
|
|
|
|
|
Test fileset
|
|
|
|
|
2012-08-16 00:50:23 +04:00
|
|
|
$ hg cat 'set:not(b) or a'
|
|
|
|
3
|
|
|
|
$ hg cat 'set:c or b'
|
|
|
|
1
|
|
|
|
3
|
|
|
|
|
2014-04-16 07:29:19 +04:00
|
|
|
$ mkdir tmp
|
|
|
|
$ hg cat --output tmp/HH_%H c
|
|
|
|
$ hg cat --output tmp/RR_%R c
|
|
|
|
$ hg cat --output tmp/h_%h c
|
|
|
|
$ hg cat --output tmp/r_%r c
|
|
|
|
$ hg cat --output tmp/%s_s c
|
|
|
|
$ hg cat --output tmp/%d%%_d c
|
|
|
|
$ hg cat --output tmp/%p_p c
|
|
|
|
$ hg log -r . --template "{rev}: {node|short}\n"
|
|
|
|
2: 45116003780e
|
|
|
|
$ find tmp -type f | sort
|
|
|
|
tmp/.%_d
|
|
|
|
tmp/HH_45116003780e3678b333fb2c99fa7d559c8457e9
|
|
|
|
tmp/RR_2
|
|
|
|
tmp/c_p
|
|
|
|
tmp/c_s
|
|
|
|
tmp/h_45116003780e
|
|
|
|
tmp/r_2
|
|
|
|
|
2017-05-25 15:53:44 +03:00
|
|
|
Test template output
|
|
|
|
|
|
|
|
$ hg --cwd tmp cat ../b ../c -T '== {path} ({abspath}) ==\n{data}'
|
2017-12-11 06:50:57 +03:00
|
|
|
== ../b (b) ==
|
2017-05-25 15:53:44 +03:00
|
|
|
1
|
2017-12-11 06:50:57 +03:00
|
|
|
== ../c (c) ==
|
2017-05-25 15:53:44 +03:00
|
|
|
3
|
|
|
|
|
|
|
|
$ hg cat b c -Tjson --output -
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"abspath": "b",
|
|
|
|
"data": "1\n",
|
|
|
|
"path": "b"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"abspath": "c",
|
|
|
|
"data": "3\n",
|
|
|
|
"path": "c"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
$ hg cat b c -Tjson --output 'tmp/%p.json'
|
|
|
|
$ cat tmp/b.json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"abspath": "b",
|
|
|
|
"data": "1\n",
|
|
|
|
"path": "b"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
$ cat tmp/c.json
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"abspath": "c",
|
|
|
|
"data": "3\n",
|
|
|
|
"path": "c"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2015-04-05 07:16:46 +03:00
|
|
|
Test working directory
|
|
|
|
|
|
|
|
$ echo b-wdir > b
|
|
|
|
$ hg cat -r 'wdir()' b
|
|
|
|
b-wdir
|
2017-01-18 07:12:54 +03:00
|
|
|
|
|
|
|
Environment variables are not visible by default
|
|
|
|
|
|
|
|
$ PATTERN='t4' hg log -r '.' -T "{ifcontains('PATTERN', envvars, 'yes', 'no')}\n"
|
|
|
|
no
|
|
|
|
|
|
|
|
Environment variable visibility can be explicit
|
|
|
|
|
|
|
|
$ PATTERN='t4' hg log -r '.' -T "{envvars % '{key} -> {value}\n'}" \
|
|
|
|
> --config "experimental.exportableenviron=PATTERN"
|
|
|
|
PATTERN -> t4
|
2017-11-08 00:46:15 +03:00
|
|
|
|
|
|
|
Test behavior of output when directory structure does not already exist
|
|
|
|
|
|
|
|
$ mkdir foo
|
|
|
|
$ echo a > foo/a
|
|
|
|
$ hg add foo/a
|
|
|
|
$ hg commit -qm "add foo/a"
|
|
|
|
$ hg cat --output "output/%p" foo/a
|
2017-11-08 00:48:33 +03:00
|
|
|
$ cat output/foo/a
|
|
|
|
a
|