comparison tests/test-copies-in-changeset.t @ 42142:5382d8f8530b

changelog: parse copy metadata if available in extras This lets read back the copy metadata we just started writing. There are still many places left to teach about getting the copy information from the changeset, but we have enough ({file_copies}, specifically) that we can add it now and have some test coverage of it. Differential Revision: https://phab.mercurial-scm.org/D6186
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 27 Dec 2017 22:05:20 -0800
parents 0e41f40b01cc
children 83b225fbd788
comparison
equal deleted inserted replaced
42141:0e41f40b01cc 42142:5382d8f8530b
1 1
2 $ cat >> $HGRCPATH << EOF 2 $ cat >> $HGRCPATH << EOF
3 > [experimental] 3 > [experimental]
4 > copies.write-to=changeset-only 4 > copies.write-to=changeset-only
5 > copies.read-from=changeset-only
5 > [alias] 6 > [alias]
6 > changesetcopies = log -r . -T 'files: {files} 7 > changesetcopies = log -r . -T 'files: {files}
7 > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}' 8 > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
9 > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}'
8 > EOF 10 > EOF
9 11
10 Check that copies are recorded correctly 12 Check that copies are recorded correctly
11 13
12 $ hg init repo 14 $ hg init repo
21 $ hg changesetcopies 23 $ hg changesetcopies
22 files: b c d 24 files: b c d
23 p1copies: b\x00a (esc) 25 p1copies: b\x00a (esc)
24 c\x00a (esc) 26 c\x00a (esc)
25 d\x00a (esc) 27 d\x00a (esc)
28 $ hg showcopies
29 a -> b
30 a -> c
31 a -> d
32 $ hg showcopies --config experimental.copies.read-from=compatibility
33 a -> b
34 a -> c
35 a -> d
36 $ hg showcopies --config experimental.copies.read-from=filelog-only
26 37
27 Check that renames are recorded correctly 38 Check that renames are recorded correctly
28 39
29 $ hg mv b b2 40 $ hg mv b b2
30 $ hg ci -m 'rename b to b2' 41 $ hg ci -m 'rename b to b2'
31 $ hg changesetcopies 42 $ hg changesetcopies
32 files: b b2 43 files: b b2
33 p1copies: b2\x00b (esc) 44 p1copies: b2\x00b (esc)
45 $ hg showcopies
46 b -> b2
34 47
35 Rename onto existing file. This should get recorded in the changeset files list and in the extras, 48 Rename onto existing file. This should get recorded in the changeset files list and in the extras,
36 even though there is no filelog entry. 49 even though there is no filelog entry.
37 50
38 $ hg cp b2 c --force 51 $ hg cp b2 c --force
44 0 1 b789fdd96dc2 000000000000 000000000000 57 0 1 b789fdd96dc2 000000000000 000000000000
45 $ hg ci -m 'move b onto d' 58 $ hg ci -m 'move b onto d'
46 $ hg changesetcopies 59 $ hg changesetcopies
47 files: c 60 files: c
48 p1copies: c\x00b2 (esc) 61 p1copies: c\x00b2 (esc)
62 $ hg showcopies
63 b2 -> c
49 $ hg debugindex c 64 $ hg debugindex c
50 rev linkrev nodeid p1 p2 65 rev linkrev nodeid p1 p2
51 0 1 b789fdd96dc2 000000000000 000000000000 66 0 1 b789fdd96dc2 000000000000 000000000000
52 67
53 Create a merge commit with copying done during merge. 68 Create a merge commit with copying done during merge.
72 $ hg changesetcopies 87 $ hg changesetcopies
73 files: g h i 88 files: g h i
74 p1copies: g\x00a (esc) 89 p1copies: g\x00a (esc)
75 i\x00f (esc) 90 i\x00f (esc)
76 p2copies: h\x00d (esc) 91 p2copies: h\x00d (esc)
92 $ hg showcopies
93 a -> g
94 d -> h
95 f -> i
77 96
78 Test writing to both changeset and filelog 97 Test writing to both changeset and filelog
79 98
80 $ hg cp a j 99 $ hg cp a j
81 $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility 100 $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
86 \x01 (esc) 105 \x01 (esc)
87 copy: a 106 copy: a
88 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 107 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
89 \x01 (esc) 108 \x01 (esc)
90 a 109 a
110 $ hg showcopies
111 a -> j
112 $ hg showcopies --config experimental.copies.read-from=compatibility
113 a -> j
114 $ hg showcopies --config experimental.copies.read-from=filelog-only
115 a -> j
91 116
92 Test writing only to filelog 117 Test writing only to filelog
93 118
94 $ hg cp a k 119 $ hg cp a k
95 $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only 120 $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
99 \x01 (esc) 124 \x01 (esc)
100 copy: a 125 copy: a
101 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 126 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
102 \x01 (esc) 127 \x01 (esc)
103 a 128 a
129 $ hg showcopies
130 $ hg showcopies --config experimental.copies.read-from=compatibility
131 a -> k
132 $ hg showcopies --config experimental.copies.read-from=filelog-only
133 a -> k
104 134
105 $ cd .. 135 $ cd ..