| 1 |
The simple store doesn't escape paths robustly and can't store paths |
| 2 |
with periods, etc. So much of this test fails with it. |
| 3 |
|
| 4 |
$ hg init repo |
| 5 |
$ cd repo |
| 6 |
|
| 7 |
audit of .hg |
| 8 |
|
| 9 |
$ hg add .hg/00changelog.i |
| 10 |
abort: path contains illegal component: .hg/00changelog.i |
| 11 |
[10] |
| 12 |
|
| 13 |
#if symlink |
| 14 |
|
| 15 |
Symlinks |
| 16 |
|
| 17 |
$ mkdir a |
| 18 |
$ echo a > a/a |
| 19 |
$ hg ci -Ama |
| 20 |
adding a/a |
| 21 |
$ ln -s a b |
| 22 |
$ echo b > a/b |
| 23 |
$ hg add b/b |
| 24 |
abort: path 'b/b' traverses symbolic link 'b' |
| 25 |
[255] |
| 26 |
$ hg add b |
| 27 |
|
| 28 |
should still fail - maybe |
| 29 |
|
| 30 |
$ hg add b/b |
| 31 |
abort: path 'b/b' traverses symbolic link 'b' |
| 32 |
[255] |
| 33 |
|
| 34 |
$ hg commit -m 'add symlink b' |
| 35 |
|
| 36 |
|
| 37 |
Test symlink traversing when accessing history: |
| 38 |
----------------------------------------------- |
| 39 |
|
| 40 |
(build a changeset where the path exists as a directory) |
| 41 |
|
| 42 |
$ hg up 0 |
| 43 |
0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 44 |
$ mkdir b |
| 45 |
$ echo c > b/a |
| 46 |
$ hg add b/a |
| 47 |
$ hg ci -m 'add directory b' |
| 48 |
created new head |
| 49 |
|
| 50 |
Test that hg cat does not do anything wrong the working copy has 'b' as directory |
| 51 |
|
| 52 |
$ hg cat b/a |
| 53 |
c |
| 54 |
$ hg cat -r "desc(directory)" b/a |
| 55 |
c |
| 56 |
$ hg cat -r "desc(symlink)" b/a |
| 57 |
b/a: no such file in rev bc151a1f53bd |
| 58 |
[1] |
| 59 |
|
| 60 |
Test that hg cat does not do anything wrong the working copy has 'b' as a symlink (issue4749) |
| 61 |
|
| 62 |
$ hg up 'desc(symlink)' |
| 63 |
1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
| 64 |
$ hg cat b/a |
| 65 |
b/a: no such file in rev bc151a1f53bd |
| 66 |
[1] |
| 67 |
$ hg cat -r "desc(directory)" b/a |
| 68 |
c |
| 69 |
$ hg cat -r "desc(symlink)" b/a |
| 70 |
b/a: no such file in rev bc151a1f53bd |
| 71 |
[1] |
| 72 |
|
| 73 |
#endif |
| 74 |
|
| 75 |
|
| 76 |
unbundle tampered bundle |
| 77 |
|
| 78 |
$ hg init target |
| 79 |
$ cd target |
| 80 |
$ hg unbundle "$TESTDIR/bundles/tampered.hg" |
| 81 |
adding changesets |
| 82 |
adding manifests |
| 83 |
adding file changes |
| 84 |
added 5 changesets with 6 changes to 6 files (+4 heads) |
| 85 |
new changesets b7da9bf6b037:fc1393d727bc (5 drafts) |
| 86 |
(run 'hg heads' to see heads, 'hg merge' to merge) |
| 87 |
|
| 88 |
attack .hg/test |
| 89 |
|
| 90 |
$ hg manifest -r0 |
| 91 |
.hg/test |
| 92 |
$ hg update -Cr0 |
| 93 |
abort: path contains illegal component: .hg/test (no-rust !) |
| 94 |
abort: path '.hg/test' is inside the '.hg' folder (rust !) |
| 95 |
[10] |
| 96 |
|
| 97 |
attack foo/.hg/test |
| 98 |
|
| 99 |
$ hg manifest -r1 |
| 100 |
foo/.hg/test |
| 101 |
$ hg update -Cr1 |
| 102 |
abort: path 'foo/.hg/test' is inside nested repo 'foo' |
| 103 |
[10] |
| 104 |
|
| 105 |
attack back/test where back symlinks to .. |
| 106 |
|
| 107 |
$ hg manifest -r2 |
| 108 |
back |
| 109 |
back/test |
| 110 |
|
| 111 |
#if symlink |
| 112 |
$ hg update -Cr2 |
| 113 |
abort: path 'back/test' traverses symbolic link 'back' |
| 114 |
[255] |
| 115 |
#else |
| 116 |
('back' will be a file and cause some other system specific error) |
| 117 |
$ hg update -Cr2 |
| 118 |
abort: $TESTTMP/repo/target/back/test: $ENOTDIR$ |
| 119 |
[255] |
| 120 |
#endif |
| 121 |
|
| 122 |
attack ../test |
| 123 |
|
| 124 |
$ hg manifest -r3 |
| 125 |
../test |
| 126 |
$ mkdir ../test |
| 127 |
$ echo data > ../test/file |
| 128 |
$ hg update -Cr3 |
| 129 |
abort: path contains illegal component: ../test |
| 130 |
[10] |
| 131 |
$ cat ../test/file |
| 132 |
data |
| 133 |
|
| 134 |
attack /tmp/test |
| 135 |
|
| 136 |
$ hg manifest -r4 |
| 137 |
/tmp/test |
| 138 |
$ hg update -Cr4 |
| 139 |
abort: path contains illegal component: /tmp/test |
| 140 |
[10] |
| 141 |
|
| 142 |
$ cd .. |
| 143 |
|
| 144 |
Test symlink traversal on merge: |
| 145 |
-------------------------------- |
| 146 |
|
| 147 |
#if symlink |
| 148 |
|
| 149 |
set up symlink hell |
| 150 |
|
| 151 |
$ mkdir merge-symlink-out |
| 152 |
$ hg init merge-symlink |
| 153 |
$ cd merge-symlink |
| 154 |
$ touch base |
| 155 |
$ hg commit -qAm base |
| 156 |
$ ln -s ../merge-symlink-out a |
| 157 |
$ hg commit -qAm 'symlink a -> ../merge-symlink-out' |
| 158 |
$ hg up -q 0 |
| 159 |
$ mkdir a |
| 160 |
$ touch a/poisoned |
| 161 |
$ hg commit -qAm 'file a/poisoned' |
| 162 |
$ hg log -G -T '{rev}: {desc}\n' |
| 163 |
@ 2: file a/poisoned |
| 164 |
| |
| 165 |
| o 1: symlink a -> ../merge-symlink-out |
| 166 |
|/ |
| 167 |
o 0: base |
| 168 |
|
| 169 |
|
| 170 |
try trivial merge |
| 171 |
|
| 172 |
$ hg up -qC 1 |
| 173 |
$ hg merge 2 |
| 174 |
abort: path 'a/poisoned' traverses symbolic link 'a' |
| 175 |
[255] |
| 176 |
|
| 177 |
try rebase onto other revision: cache of audited paths should be discarded, |
| 178 |
and the rebase should fail (issue5628) |
| 179 |
|
| 180 |
$ hg up -qC 2 |
| 181 |
$ hg rebase -s 2 -d 1 --config extensions.rebase= |
| 182 |
rebasing 2:e73c21d6b244 tip "file a/poisoned" |
| 183 |
abort: path 'a/poisoned' traverses symbolic link 'a' |
| 184 |
[255] |
| 185 |
$ ls ../merge-symlink-out |
| 186 |
|
| 187 |
$ cd .. |
| 188 |
|
| 189 |
Test symlink traversal on update: |
| 190 |
--------------------------------- |
| 191 |
|
| 192 |
$ mkdir update-symlink-out |
| 193 |
$ hg init update-symlink |
| 194 |
$ cd update-symlink |
| 195 |
$ ln -s ../update-symlink-out a |
| 196 |
$ hg commit -qAm 'symlink a -> ../update-symlink-out' |
| 197 |
$ hg rm a |
| 198 |
$ mkdir a && touch a/b |
| 199 |
$ hg ci -qAm 'file a/b' a/b |
| 200 |
$ hg up -qC 0 |
| 201 |
$ hg rm a |
| 202 |
$ mkdir a && touch a/c |
| 203 |
$ hg ci -qAm 'rm a, file a/c' |
| 204 |
$ hg log -G -T '{rev}: {desc}\n' |
| 205 |
@ 2: rm a, file a/c |
| 206 |
| |
| 207 |
| o 1: file a/b |
| 208 |
|/ |
| 209 |
o 0: symlink a -> ../update-symlink-out |
| 210 |
|
| 211 |
|
| 212 |
try linear update where symlink already exists: |
| 213 |
|
| 214 |
$ hg up -qC 0 |
| 215 |
#if rust |
| 216 |
$ hg up 1 |
| 217 |
abort: path 'a/b' traverses symbolic link 'a' |
| 218 |
[10] |
| 219 |
#else |
| 220 |
$ hg up 1 |
| 221 |
abort: path 'a/b' traverses symbolic link 'a' |
| 222 |
[255] |
| 223 |
#endif |
| 224 |
|
| 225 |
try linear update including symlinked directory and its content: paths are |
| 226 |
audited first by calculateupdates(), where no symlink is created so both |
| 227 |
'a' and 'a/b' are taken as good paths. still applyupdates() should fail. |
| 228 |
|
| 229 |
$ hg up -qC null |
| 230 |
#if rust |
| 231 |
$ hg up 1 |
| 232 |
abort: path 'a/?' traverses symbolic link 'a' (glob) |
| 233 |
[10] |
| 234 |
#else |
| 235 |
$ hg up 1 |
| 236 |
abort: path 'a/b' traverses symbolic link 'a' |
| 237 |
[255] |
| 238 |
#endif |
| 239 |
$ ls ../update-symlink-out |
| 240 |
|
| 241 |
try branch update replacing directory with symlink, and its content: the |
| 242 |
path 'a' is audited as a directory first, which should be audited again as |
| 243 |
a symlink. |
| 244 |
|
| 245 |
$ rm -rf a |
| 246 |
$ hg up -qC 2 |
| 247 |
|
| 248 |
#if rust |
| 249 |
$ hg up 1 |
| 250 |
abort: path 'a/?' traverses symbolic link 'a' (glob) |
| 251 |
[10] |
| 252 |
#else |
| 253 |
$ hg up 1 |
| 254 |
abort: path 'a/?' traverses symbolic link 'a' (glob) |
| 255 |
[255] |
| 256 |
#endif |
| 257 |
$ ls ../update-symlink-out |
| 258 |
|
| 259 |
$ cd .. |
| 260 |
|
| 261 |
#endif |
| 262 |
|
| 263 |
$ hg init utf8-hfs-ignore-clean |
| 264 |
$ cd utf8-hfs-ignore-clean |
| 265 |
|
| 266 |
The UTF-8 encoding of unicode character '(' contains a special byte |
| 267 |
(0xef) that changes behavior of `hfs_ignore_clean`, so we end up |
| 268 |
exercising a code path that's otherwise not exercised. |
| 269 |
|
| 270 |
$ f='(' |
| 271 |
$ echo "$f" |
| 272 |
\xef\xbc\x88 (esc) |
| 273 |
$ touch "$f" |
| 274 |
$ hg add "$f" |
| 275 |
$ hg commit -m "add" |
| 276 |
$ echo change > "$f" |
| 277 |
$ hg commit -m "change" |
| 278 |
$ hg update ".^" |
| 279 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |