| 1 |
#testcases safe normal |
| 2 |
#testcases fncache fileindex |
| 3 |
|
| 4 |
#if safe |
| 5 |
$ echo "[format]" >> $HGRCPATH |
| 6 |
$ echo "use-share-safe = True" >> $HGRCPATH |
| 7 |
#endif |
| 8 |
|
| 9 |
#if fileindex |
| 10 |
$ cat >> $HGRCPATH << EOF |
| 11 |
> [format] |
| 12 |
> use-fileindex-v1=yes |
| 13 |
> EOF |
| 14 |
#else |
| 15 |
$ cat >> $HGRCPATH << EOF |
| 16 |
> [format] |
| 17 |
> use-fileindex-v1=no |
| 18 |
> EOF |
| 19 |
#endif |
| 20 |
|
| 21 |
#if fileindex no-rust |
| 22 |
$ cat >> $HGRCPATH << EOF |
| 23 |
> [storage] |
| 24 |
> fileindex.slow-path=allow |
| 25 |
> EOF |
| 26 |
#endif |
| 27 |
|
| 28 |
$ echo "[extensions]" >> $HGRCPATH |
| 29 |
$ echo "share = " >> $HGRCPATH |
| 30 |
|
| 31 |
prepare repo1 |
| 32 |
|
| 33 |
$ hg init repo1 |
| 34 |
$ cd repo1 |
| 35 |
$ echo a > a |
| 36 |
$ hg commit -A -m'init' |
| 37 |
adding a |
| 38 |
|
| 39 |
share it |
| 40 |
|
| 41 |
$ cd .. |
| 42 |
$ hg share repo1 repo2 |
| 43 |
updating working directory |
| 44 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 45 |
|
| 46 |
share shouldn't have a store dir |
| 47 |
|
| 48 |
$ cd repo2 |
| 49 |
$ test -d .hg/store |
| 50 |
[1] |
| 51 |
$ hg root -Tjson | sed 's|\\\\|\\|g' |
| 52 |
[ |
| 53 |
{ |
| 54 |
"hgpath": "$TESTTMP/repo2/.hg", |
| 55 |
"reporoot": "$TESTTMP/repo2", |
| 56 |
"storepath": "$TESTTMP/repo1/.hg/store" |
| 57 |
} |
| 58 |
] |
| 59 |
|
| 60 |
Test the --share-source option for `hg root` |
| 61 |
|
| 62 |
(In a share) |
| 63 |
|
| 64 |
$ hg root |
| 65 |
$TESTTMP/repo2 |
| 66 |
$ hg root -T json | sed 's|\\\\|\\|g' |
| 67 |
[ |
| 68 |
{ |
| 69 |
"hgpath": "$TESTTMP/repo2/.hg", |
| 70 |
"reporoot": "$TESTTMP/repo2", |
| 71 |
"storepath": "$TESTTMP/repo1/.hg/store" |
| 72 |
} |
| 73 |
] |
| 74 |
|
| 75 |
$ RHG_ON_UNSUPPORTED=abort hg root --share-source |
| 76 |
$TESTTMP/repo1 |
| 77 |
$ hg root --share-source -T json | sed 's|\\\\|\\|g' |
| 78 |
[ |
| 79 |
{ |
| 80 |
"hgpath": "$TESTTMP/repo1/.hg/", |
| 81 |
"reporoot": "$TESTTMP/repo1", |
| 82 |
"storepath": "$TESTTMP/repo1/.hg/store" |
| 83 |
} |
| 84 |
] |
| 85 |
|
| 86 |
(not in a share) |
| 87 |
|
| 88 |
$ hg -R ../repo1 root |
| 89 |
$TESTTMP/repo1 |
| 90 |
$ hg -R ../repo1 root -T json | sed 's|\\\\|\\|g' |
| 91 |
[ |
| 92 |
{ |
| 93 |
"hgpath": "$TESTTMP/repo1/.hg", |
| 94 |
"reporoot": "$TESTTMP/repo1", |
| 95 |
"storepath": "$TESTTMP/repo1/.hg/store" |
| 96 |
} |
| 97 |
] |
| 98 |
|
| 99 |
$ hg -R ../repo1 root --share-source |
| 100 |
$TESTTMP/repo1 |
| 101 |
$ hg -R ../repo1 root --share-source -T json | sed 's|\\\\|\\|g' |
| 102 |
[ |
| 103 |
{ |
| 104 |
"hgpath": "$TESTTMP/repo1/.hg/", |
| 105 |
"reporoot": "$TESTTMP/repo1", |
| 106 |
"storepath": "$TESTTMP/repo1/.hg/store" |
| 107 |
} |
| 108 |
] |
| 109 |
|
| 110 |
share shouldn't have a full cache dir, original repo should |
| 111 |
|
| 112 |
$ hg branches |
| 113 |
default 0:d3873e73d99e |
| 114 |
$ hg tags |
| 115 |
tip 0:d3873e73d99e |
| 116 |
$ test -d .hg/cache |
| 117 |
[1] |
| 118 |
$ ls -1 .hg/wcache || true |
| 119 |
checkisexec (execbit !) |
| 120 |
checklink (symlink no-rust !) |
| 121 |
checklink-target (symlink no-rust !) |
| 122 |
manifestfulltextcache (no-rust !) |
| 123 |
$ ls -1 ../repo1/.hg/cache |
| 124 |
branch2-served |
| 125 |
rbc-names-v2 |
| 126 |
rbc-revs-v2 |
| 127 |
tags2-visible |
| 128 |
|
| 129 |
Cloning a shared repo should pick up the full cache dir on the other hand. |
| 130 |
|
| 131 |
$ hg clone . ../repo2-clone |
| 132 |
updating to branch default |
| 133 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 134 |
$ ls -1 ../repo2-clone/.hg/cache |
| 135 |
branch2-base |
| 136 |
branch2-served |
| 137 |
rbc-names-v2 |
| 138 |
rbc-revs-v2 |
| 139 |
tags2 |
| 140 |
tags2-served |
| 141 |
tags2-visible |
| 142 |
|
| 143 |
Some sed versions appends newline, some don't, and some just fails |
| 144 |
|
| 145 |
$ cat .hg/sharedpath; echo |
| 146 |
$TESTTMP/repo1/.hg |
| 147 |
|
| 148 |
trailing newline on .hg/sharedpath is ok |
| 149 |
$ hg tip -q |
| 150 |
0:d3873e73d99e |
| 151 |
$ echo '' >> .hg/sharedpath |
| 152 |
$ cat .hg/sharedpath |
| 153 |
$TESTTMP/repo1/.hg |
| 154 |
$ hg tip -q |
| 155 |
0:d3873e73d99e |
| 156 |
|
| 157 |
commit in shared clone |
| 158 |
|
| 159 |
$ echo a >> a |
| 160 |
$ hg commit -m'change in shared clone' |
| 161 |
|
| 162 |
check original |
| 163 |
|
| 164 |
$ cd ../repo1 |
| 165 |
$ hg log |
| 166 |
changeset: 1:8af4dc49db9e |
| 167 |
tag: tip |
| 168 |
user: test |
| 169 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 170 |
summary: change in shared clone |
| 171 |
|
| 172 |
changeset: 0:d3873e73d99e |
| 173 |
user: test |
| 174 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 175 |
summary: init |
| 176 |
|
| 177 |
$ hg update |
| 178 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 179 |
$ cat a # should be two lines of "a" |
| 180 |
a |
| 181 |
a |
| 182 |
|
| 183 |
commit in original |
| 184 |
|
| 185 |
$ echo b > b |
| 186 |
$ hg commit -A -m'another file' |
| 187 |
adding b |
| 188 |
|
| 189 |
check in shared clone |
| 190 |
|
| 191 |
$ cd ../repo2 |
| 192 |
$ hg log |
| 193 |
changeset: 2:c2e0ac586386 |
| 194 |
tag: tip |
| 195 |
user: test |
| 196 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 197 |
summary: another file |
| 198 |
|
| 199 |
changeset: 1:8af4dc49db9e |
| 200 |
user: test |
| 201 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 202 |
summary: change in shared clone |
| 203 |
|
| 204 |
changeset: 0:d3873e73d99e |
| 205 |
user: test |
| 206 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 207 |
summary: init |
| 208 |
|
| 209 |
$ hg update |
| 210 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 211 |
$ cat b # should exist with one "b" |
| 212 |
b |
| 213 |
|
| 214 |
hg serve shared clone |
| 215 |
|
| 216 |
$ hg serve -n test -p $HGPORT -d --pid-file=hg.pid |
| 217 |
$ cat hg.pid >> $DAEMON_PIDS |
| 218 |
$ get-with-headers.py localhost:$HGPORT 'raw-file/' |
| 219 |
200 Script output follows |
| 220 |
|
| 221 |
|
| 222 |
-rw-r--r-- 4 a |
| 223 |
-rw-r--r-- 2 b |
| 224 |
|
| 225 |
|
| 226 |
Cloning a shared repo via bundle2 results in a non-shared clone |
| 227 |
|
| 228 |
$ cd .. |
| 229 |
$ hg clone -q --stream ssh://user@dummy/`pwd`/repo2 cloned-via-bundle2 |
| 230 |
$ hg -R cloned-via-bundle2 debugrequires | grep "shared" |
| 231 |
[1] |
| 232 |
$ hg id --cwd cloned-via-bundle2 -r tip |
| 233 |
c2e0ac586386 tip |
| 234 |
$ cd repo2 |
| 235 |
|
| 236 |
test unshare command |
| 237 |
|
| 238 |
$ hg unshare |
| 239 |
$ test -d .hg/store |
| 240 |
$ test -f .hg/sharedpath |
| 241 |
[1] |
| 242 |
$ hg debugrequires | grep shared |
| 243 |
[1] |
| 244 |
$ hg unshare |
| 245 |
abort: this is not a shared repo |
| 246 |
[255] |
| 247 |
|
| 248 |
check that a change does not propagate |
| 249 |
|
| 250 |
$ echo b >> b |
| 251 |
$ hg commit -m'change in unshared' |
| 252 |
$ cd ../repo1 |
| 253 |
$ hg id -r tip |
| 254 |
c2e0ac586386 tip |
| 255 |
|
| 256 |
$ cd .. |
| 257 |
|
| 258 |
|
| 259 |
non largefiles repos won't enable largefiles |
| 260 |
|
| 261 |
$ hg share --config extensions.largefiles= repo2 sharedrepo |
| 262 |
The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) |
| 263 |
The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) |
| 264 |
updating working directory |
| 265 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 266 |
$ [ -f sharedrepo/.hg/hgrc ] |
| 267 |
[1] |
| 268 |
|
| 269 |
test shared clones using relative paths work |
| 270 |
|
| 271 |
$ mkdir thisdir |
| 272 |
$ hg init thisdir/orig |
| 273 |
$ hg share -U thisdir/orig thisdir/abs |
| 274 |
$ hg share -U --relative thisdir/abs thisdir/rel |
| 275 |
$ cat thisdir/rel/.hg/sharedpath |
| 276 |
../../orig/.hg (no-eol) |
| 277 |
$ hg debugrequires -R thisdir/abs/ | grep shared |
| 278 |
shared |
| 279 |
$ hg debugrequires -R thisdir/rel/ | grep shared |
| 280 |
relshared |
| 281 |
shared |
| 282 |
|
| 283 |
test that relative shared paths aren't relative to $PWD |
| 284 |
|
| 285 |
$ cd thisdir |
| 286 |
$ hg -R rel root |
| 287 |
$TESTTMP/thisdir/rel |
| 288 |
$ cd .. |
| 289 |
|
| 290 |
now test that relative paths really are relative, survive across |
| 291 |
renames and changes of PWD |
| 292 |
|
| 293 |
$ hg -R thisdir/abs root |
| 294 |
$TESTTMP/thisdir/abs |
| 295 |
$ hg -R thisdir/rel root |
| 296 |
$TESTTMP/thisdir/rel |
| 297 |
$ mv thisdir thatdir |
| 298 |
$ hg -R thatdir/abs root |
| 299 |
abort: .hg/sharedpath points to nonexistent directory $TESTTMP/thisdir/orig/.hg |
| 300 |
[255] |
| 301 |
$ hg -R thatdir/rel root |
| 302 |
$TESTTMP/thatdir/rel |
| 303 |
|
| 304 |
test unshare relshared repo |
| 305 |
|
| 306 |
$ cd thatdir/rel |
| 307 |
$ hg unshare |
| 308 |
$ test -d .hg/store |
| 309 |
$ test -f .hg/sharedpath |
| 310 |
[1] |
| 311 |
$ hg debugrequires | grep shared |
| 312 |
[1] |
| 313 |
$ hg unshare |
| 314 |
abort: this is not a shared repo |
| 315 |
[255] |
| 316 |
$ cd ../.. |
| 317 |
|
| 318 |
$ rm -r thatdir |
| 319 |
|
| 320 |
Demonstrate buggy behavior around requirements validation |
| 321 |
See comment in localrepo.py:makelocalrepository() for more. |
| 322 |
|
| 323 |
$ hg init sharenewrequires |
| 324 |
$ hg share sharenewrequires shareoldrequires |
| 325 |
updating working directory |
| 326 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 327 |
|
| 328 |
$ cat >> sharenewrequires/.hg/requires << EOF |
| 329 |
> missing-requirement |
| 330 |
> EOF |
| 331 |
|
| 332 |
We cannot open the repo with the unknown requirement |
| 333 |
|
| 334 |
$ hg -R sharenewrequires status |
| 335 |
abort: repository requires features unknown to this Mercurial: missing-requirement |
| 336 |
(see https://mercurial-scm.org/wiki/MissingRequirement for more information) |
| 337 |
[255] |
| 338 |
|
| 339 |
BUG: we don't get the same error when opening the shared repo pointing to it |
| 340 |
|
| 341 |
$ hg -R shareoldrequires status |
| 342 |
|
| 343 |
Explicitly kill daemons to let the test exit on Windows |
| 344 |
|
| 345 |
$ killdaemons.py |
| 346 |
|
| 347 |
Test sharing a repository which was created with store requirement disable |
| 348 |
|
| 349 |
$ hg init nostore --config format.usestore=false |
| 350 |
ignoring enabled 'format.use-share-safe' config because it is incompatible with disabled 'format.usestore' config (safe !) |
| 351 |
$ hg share nostore sharednostore |
| 352 |
abort: cannot create shared repository as source was created with 'format.usestore' config disabled |
| 353 |
[255] |
| 354 |
|
| 355 |
Check that (safe) share can control wc-specific format variant at creation time |
| 356 |
------------------------------------------------------------------------------- |
| 357 |
|
| 358 |
#if no-rust |
| 359 |
|
| 360 |
$ cat << EOF >> $HGRCPATH |
| 361 |
> [storage] |
| 362 |
> dirstate-v2.slow-path = allow |
| 363 |
> EOF |
| 364 |
|
| 365 |
#endif |
| 366 |
|
| 367 |
$ hg init repo-safe-d1 --config format.use-share-safe=yes --config format.exp-rc-dirstate-v2=no |
| 368 |
$ hg debugformat -R repo-safe-d1 dirstate-v2 |
| 369 |
format-variant repo |
| 370 |
dirstate-v2: no |
| 371 |
|
| 372 |
$ hg share repo-safe-d1 share-safe-d2 --config format.use-share-safe=yes --config format.exp-rc-dirstate-v2=yes |
| 373 |
updating working directory |
| 374 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 375 |
$ hg debugformat -R share-safe-d2 dirstate-v2 |
| 376 |
format-variant repo |
| 377 |
dirstate-v2: yes |
| 378 |
|
| 379 |
Test sharing and unsharing an empty repo |
| 380 |
---------------------------------------- |
| 381 |
|
| 382 |
$ hg init repo-empty |
| 383 |
$ hg share repo-empty repo-empty-share |
| 384 |
updating working directory |
| 385 |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 386 |
$ hg -R repo-empty-share unshare |
| 387 |
$ hg -R repo-empty-share verify |
| 388 |
checking changesets |
| 389 |
checking manifests |
| 390 |
crosschecking files in changesets and manifests |
| 391 |
checking files |
| 392 |
checking dirstate |
| 393 |
checked 0 changesets with 0 changes to 0 files |