1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
|
#testcases extra sidedata
#if extra
$ cat >> $HGRCPATH << EOF
> [experimental]
> copies.write-to=changeset-only
> copies.read-from=changeset-only
> [alias]
> changesetcopies = log -r . -T 'files: {files}
> {extras % "{ifcontains("files", key, "{key}: {value}\n")}"}
> {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
> EOF
#endif
#if sidedata
$ cat >> $HGRCPATH << EOF
> [format]
> exp-use-copies-side-data-changeset = yes
> EOF
#endif
$ cat >> $HGRCPATH << EOF
> [alias]
> showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}'
> [extensions]
> rebase =
> split =
> EOF
Check that copies are recorded correctly
$ hg init repo
$ cd repo
#if sidedata
$ hg debugformat -v | egrep 'format-variant|revlog-v2|copies-sdc|changelog-v2'
format-variant repo config default
copies-sdc: yes yes no
revlog-v2: no no no
changelog-v2: yes yes no
#else
$ hg debugformat -v | egrep 'format-variant|revlog-v2|copies-sdc|changelog-v2'
format-variant repo config default
copies-sdc: no no no
revlog-v2: no no no
changelog-v2: no no no
#endif
$ echo a > a
$ hg add a
$ hg ci -m initial
$ hg cp a b
$ hg cp a c
$ hg cp a d
$ hg ci -m 'copy a to b, c, and d'
#if extra
$ hg changesetcopies
files: b c d
filesadded: 0
1
2
p1copies: 0\x00a (esc)
1\x00a (esc)
2\x00a (esc)
#else
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 44
'\x00\x00\x00\x04\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00\x06\x00\x00\x00\x03\x00\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x00abcd'
#endif
$ hg showcopies
a -> b
a -> c
a -> d
#if extra
$ hg showcopies --config experimental.copies.read-from=compatibility
a -> b
a -> c
a -> d
$ hg showcopies --config experimental.copies.read-from=filelog-only
#endif
Check that renames are recorded correctly
$ hg mv b b2
$ hg ci -m 'rename b to b2'
#if extra
$ hg changesetcopies
files: b b2
filesadded: 1
filesremoved: 0
p1copies: 1\x00b (esc)
#else
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 25
'\x00\x00\x00\x02\x0c\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x03\x00\x00\x00\x00bb2'
#endif
$ hg showcopies
b -> b2
Rename onto existing file. This should get recorded in the changeset files list and in the extras,
even though there is no filelog entry.
$ hg cp b2 c --force
$ hg st --copies
M c
b2
#if extra
$ hg debugindex c
rev linkrev nodeid p1-nodeid p2-nodeid
0 1 b789fdd96dc2 000000000000 000000000000
#else
$ hg debugindex c
rev linkrev nodeid p1-nodeid p2-nodeid
0 1 37d9b5d994ea 000000000000 000000000000
#endif
$ hg ci -m 'move b onto d'
#if extra
$ hg changesetcopies
files: c
p1copies: 0\x00b2 (esc)
#else
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 25
'\x00\x00\x00\x02\x00\x00\x00\x00\x02\x00\x00\x00\x00\x16\x00\x00\x00\x03\x00\x00\x00\x00b2c'
#endif
$ hg showcopies
b2 -> c
#if extra
$ hg debugindex c
rev linkrev nodeid p1-nodeid p2-nodeid
0 1 b789fdd96dc2 000000000000 000000000000
#else
$ hg debugindex c
rev linkrev nodeid p1-nodeid p2-nodeid
0 1 37d9b5d994ea 000000000000 000000000000
1 3 029625640347 000000000000 000000000000
#endif
Create a merge commit with copying done during merge.
$ hg co 0
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
$ hg cp a e
$ hg cp a f
$ hg ci -m 'copy a to e and f'
created new head
$ hg merge 3
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
File 'a' exists on both sides, so 'g' could be recorded as being from p1 or p2, but we currently
always record it as being from p1
$ hg cp a g
File 'd' exists only in p2, so 'h' should be from p2
$ hg cp d h
File 'f' exists only in p1, so 'i' should be from p1
$ hg cp f i
$ hg ci -m 'merge'
#if extra
$ hg changesetcopies
files: g h i
filesadded: 0
1
2
p1copies: 0\x00a (esc)
2\x00f (esc)
p2copies: 1\x00d (esc)
#else
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 64
'\x00\x00\x00\x06\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x06\x00\x00\x00\x04\x00\x00\x00\x00\x07\x00\x00\x00\x05\x00\x00\x00\x01\x06\x00\x00\x00\x06\x00\x00\x00\x02adfghi'
#endif
$ hg showcopies
a -> g
d -> h
f -> i
Test writing to both changeset and filelog
$ hg cp a j
#if extra
$ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
$ hg changesetcopies
files: j
filesadded: 0
filesremoved:
p1copies: 0\x00a (esc)
p2copies:
#else
$ hg ci -m 'copy a to j'
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 24
'\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00aj'
#endif
$ hg debugdata j 0
\x01 (esc)
copy: a
copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
\x01 (esc)
a
$ hg showcopies
a -> j
$ hg showcopies --config experimental.copies.read-from=compatibility
a -> j
$ hg showcopies --config experimental.copies.read-from=filelog-only
a -> j
Existing copy information in the changeset gets removed on amend and writing
copy information on to the filelog
#if extra
$ hg ci --amend -m 'copy a to j, v2' \
> --config experimental.copies.write-to=filelog-only
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
$ hg changesetcopies
files: j
#else
$ hg ci --amend -m 'copy a to j, v2'
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 24
'\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00aj'
#endif
$ hg showcopies --config experimental.copies.read-from=filelog-only
a -> j
The entries should be written to extras even if they're empty (so the client
won't have to fall back to reading from filelogs)
$ echo x >> j
#if extra
$ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility
$ hg changesetcopies
files: j
filesadded:
filesremoved:
p1copies:
p2copies:
#else
$ hg ci -m 'modify j'
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 14
'\x00\x00\x00\x01\x14\x00\x00\x00\x01\x00\x00\x00\x00j'
#endif
Test writing only to filelog
$ hg cp a k
#if extra
$ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
$ hg changesetcopies
files: k
#else
$ hg ci -m 'copy a to k'
$ hg debugsidedata -c -v -- -1
1 sidedata entries
entry-0014 size 24
'\x00\x00\x00\x02\x00\x00\x00\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00ak'
#endif
$ hg debugdata k 0
\x01 (esc)
copy: a
copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
\x01 (esc)
a
#if extra
$ hg showcopies
$ hg showcopies --config experimental.copies.read-from=compatibility
a -> k
$ hg showcopies --config experimental.copies.read-from=filelog-only
a -> k
#else
$ hg showcopies
a -> k
#endif
Existing copy information is preserved by amend
$ hg cp a l
$ hg ci -m 'copy a to l'
$ hg showcopies
a -> l
$ hg ci --amend -m 'new description'
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
$ hg showcopies
a -> l
No crash on partial amend
$ hg st --change .
A l
$ echo modified >> a
$ hg rm l
$ hg commit --amend a
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
$ cd ..
Test rebasing a commit with copy information
$ hg init rebase-rename
$ cd rebase-rename
$ echo a > a
$ hg ci -Aqm 'add a'
$ echo a2 > a
$ hg ci -m 'modify a'
$ hg co -q 0
$ hg mv a b
$ hg ci -qm 'rename a to b'
Not only do we want this to run in-memory, it shouldn't fall back to
on-disk merge (no conflicts), so we force it to be in-memory
with no fallback.
$ hg rebase -d 1 --config rebase.experimental.inmemory=yes --config devel.rebase.force-in-memory-merge=yes
rebasing 2:* tip "rename a to b" (glob)
merging a and b to b
saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/*-*-rebase.hg (glob)
$ hg st --change . --copies
A b
a
R a
$ cd ..
Test splitting a commit
$ hg init split
$ cd split
$ echo a > a
$ echo b > b
$ hg ci -Aqm 'add a and b'
$ echo a2 > a
$ hg mv b c
$ hg ci -m 'modify a, move b to c'
$ hg --config ui.interactive=yes split <<EOF
> y
> y
> n
> y
> EOF
diff --git a/a b/a
1 hunks, 1 lines changed
examine changes to 'a'?
(enter ? for help) [Ynesfdaq?] y
@@ -1,1 +1,1 @@
-a
+a2
record this change to 'a'?
(enter ? for help) [Ynesfdaq?] y
diff --git a/b b/c
rename from b
rename to c
examine changes to 'b' and 'c'?
(enter ? for help) [Ynesfdaq?] n
created new head
diff --git a/b b/c
rename from b
rename to c
examine changes to 'b' and 'c'?
(enter ? for help) [Ynesfdaq?] y
saved backup bundle to $TESTTMP/split/.hg/strip-backup/*-*-split.hg (glob)
$ cd ..
Test committing half a rename
$ hg init partial
$ cd partial
$ echo a > a
$ hg ci -Aqm 'add a'
$ hg mv a b
$ hg ci -m 'remove a' a
#if sidedata
Test upgrading/downgrading to sidedata storage
==============================================
downgrading
$ hg debugformat -v | egrep 'format-variant|revlog-v2|copies-sdc|changelog-v2'
format-variant repo config default
copies-sdc: yes yes no
revlog-v2: no no no
changelog-v2: yes yes no
$ hg debugsidedata -c -- 0
1 sidedata entries
entry-0014 size 14
$ hg debugsidedata -c -- 1
1 sidedata entries
entry-0014 size 14
$ hg debugsidedata -m -- 0
$ cat << EOF > .hg/hgrc
> [format]
> exp-use-copies-side-data-changeset = no
> EOF
$ hg debugupgraderepo --run --quiet --no-backup
upgrade will perform the following actions:
requirements
preserved: * (glob)
removed: exp-changelog-v2, exp-copies-sidedata-changeset
processed revlogs:
- changelog
$ hg debugformat -v | egrep 'format-variant|revlog-v2|copies-sdc|changelog-v2'
format-variant repo config default
copies-sdc: no no no
revlog-v2: no no no
changelog-v2: no no no
$ hg debugsidedata -c -- 0
$ hg debugsidedata -c -- 1
$ hg debugsidedata -m -- 0
upgrading
$ cat << EOF > .hg/hgrc
> [format]
> exp-use-copies-side-data-changeset = yes
> EOF
$ hg debugupgraderepo --run --quiet --no-backup
upgrade will perform the following actions:
requirements
preserved: * (glob)
added: exp-changelog-v2, exp-copies-sidedata-changeset
processed revlogs:
- changelog
$ hg debugformat -v | egrep 'format-variant|revlog-v2|copies-sdc|changelog-v2'
format-variant repo config default
copies-sdc: yes yes no
revlog-v2: no no no
changelog-v2: yes yes no
$ hg debugsidedata -c -- 0
1 sidedata entries
entry-0014 size 14
$ hg debugsidedata -c -- 1
1 sidedata entries
entry-0014 size 14
$ hg debugsidedata -m -- 0
#endif
$ cd ..
|