##// END OF EJS Templates
merge default into stable for 5.1 release
merge default into stable for 5.1 release

File last commit:

r42620:027f1567 default
r42860:e386b5f4 merge 5.1rc0 stable
Show More
test-copies-in-changeset.t
187 lines | 4.3 KiB | text/troff | Tads3Lexer
/ tests / test-copies-in-changeset.t
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317
$ cat >> $HGRCPATH << EOF
> [experimental]
> copies.write-to=changeset-only
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 > copies.read-from=changeset-only
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317 > [alias]
> changesetcopies = log -r . -T 'files: {files}
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598 > {extras % "{ifcontains("files", key, "{key}: {value}\n")}"}
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317 > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}'
Martin von Zweigbergk
tests: demonstrate loss of changeset copy metadata on rebase...
r42475 > [extensions]
> rebase =
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317 > EOF
Check that copies are recorded correctly
$ hg init repo
$ cd repo
$ 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'
$ hg changesetcopies
files: b c d
Martin von Zweigbergk
copies: separate added/removed files by newline instead of null...
r42620 filesadded: 0
1
2
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 p1copies: 0\x00a (esc)
1\x00a (esc)
2\x00a (esc)
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 $ hg showcopies
a -> b
a -> c
a -> d
$ hg showcopies --config experimental.copies.read-from=compatibility
a -> b
a -> c
a -> d
$ hg showcopies --config experimental.copies.read-from=filelog-only
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317
Check that renames are recorded correctly
$ hg mv b b2
$ hg ci -m 'rename b to b2'
$ hg changesetcopies
files: b b2
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598 filesadded: 1
filesremoved: 0
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 p1copies: 1\x00b (esc)
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 $ hg showcopies
b -> b2
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317
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
$ hg debugindex c
rev linkrev nodeid p1 p2
0 1 b789fdd96dc2 000000000000 000000000000
$ hg ci -m 'move b onto d'
$ hg changesetcopies
files: c
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 p1copies: 0\x00b2 (esc)
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 $ hg showcopies
b2 -> c
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317 $ hg debugindex c
rev linkrev nodeid p1 p2
0 1 b789fdd96dc2 000000000000 000000000000
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'
$ hg changesetcopies
files: g h i
Martin von Zweigbergk
copies: separate added/removed files by newline instead of null...
r42620 filesadded: 0
1
2
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 p1copies: 0\x00a (esc)
2\x00f (esc)
p2copies: 1\x00d (esc)
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 $ hg showcopies
a -> g
d -> h
f -> i
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317
Test writing to both changeset and filelog
$ hg cp a j
$ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
$ hg changesetcopies
files: j
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598 filesadded: 0
filesremoved:
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 p1copies: 0\x00a (esc)
Martin von Zweigbergk
copies: write empty entries in changeset when also writing to filelog...
r42486 p2copies:
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317 $ hg debugdata j 0
\x01 (esc)
copy: a
copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
\x01 (esc)
a
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 $ 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
Martin von Zweigbergk
copies: write empty entries in changeset when also writing to filelog...
r42486 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
$ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility
$ hg changesetcopies
files: j
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598 filesadded:
filesremoved:
Martin von Zweigbergk
copies: write empty entries in changeset when also writing to filelog...
r42486 p1copies:
p2copies:
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317
Test writing only to filelog
$ hg cp a k
$ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
$ hg changesetcopies
files: k
Martin von Zweigbergk
changelog: optionally store added and removed files in changeset extras...
r42598
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317 $ hg debugdata k 0
\x01 (esc)
copy: a
copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
\x01 (esc)
a
Martin von Zweigbergk
changelog: parse copy metadata if available in extras...
r42318 $ hg showcopies
$ hg showcopies --config experimental.copies.read-from=compatibility
a -> k
$ hg showcopies --config experimental.copies.read-from=filelog-only
a -> k
Martin von Zweigbergk
copies: add config option for writing copy metadata to file and/or changset...
r42317
$ cd ..
Martin von Zweigbergk
tests: demonstrate loss of changeset copy metadata on rebase...
r42475
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'
$ hg rebase -d 1 --config rebase.experimental.inmemory=yes
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 rebasing 2:fc7287ac5b9b "rename a to b" (tip)
Martin von Zweigbergk
tests: demonstrate loss of changeset copy metadata on rebase...
r42475 merging a and b to b
Martin von Zweigbergk
copies: also encode p[12]copies destination as index into "files" list...
r42619 saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/fc7287ac5b9b-8f2a95ec-rebase.hg
Martin von Zweigbergk
tests: demonstrate loss of changeset copy metadata on rebase...
r42475 $ hg st --change . --copies
A b
Martin von Zweigbergk
context: reuse changectx._copies() in all but workingctx...
r42477 a
Martin von Zweigbergk
tests: demonstrate loss of changeset copy metadata on rebase...
r42475 R a
$ cd ..