comparison tests/test-copies-in-changeset.t @ 42141:0e41f40b01cc

copies: add config option for writing copy metadata to file and/or changset This introduces a config option that lets you choose to write copy metadata to the changeset extras instead of to filelog. There's also an option to write it to both places. I imagine that may possibly be useful when transitioning an existing repo. The copy metadata is stored as two fields in extras: one for copies since p1 and one for copies since p2. I may need to add more information later in order to make copy tracing faster. Specifically, I'm thinking out recording which files were added or removed so that copies._chaincopies() doesn't have to look at the manifest for that. But that would just be an optimization and that can be added once we know if it's necessary. I have also considered saving space by using replacing the destination file path by an index into the "files" list, but that can also be changed later (but before the feature is ready to release). Differential Revision: https://phab.mercurial-scm.org/D6183
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 27 Dec 2017 19:49:36 -0800
parents
children 5382d8f8530b
comparison
equal deleted inserted replaced
42140:a4483e380c3e 42141:0e41f40b01cc
1
2 $ cat >> $HGRCPATH << EOF
3 > [experimental]
4 > copies.write-to=changeset-only
5 > [alias]
6 > changesetcopies = log -r . -T 'files: {files}
7 > {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
8 > EOF
9
10 Check that copies are recorded correctly
11
12 $ hg init repo
13 $ cd repo
14 $ echo a > a
15 $ hg add a
16 $ hg ci -m initial
17 $ hg cp a b
18 $ hg cp a c
19 $ hg cp a d
20 $ hg ci -m 'copy a to b, c, and d'
21 $ hg changesetcopies
22 files: b c d
23 p1copies: b\x00a (esc)
24 c\x00a (esc)
25 d\x00a (esc)
26
27 Check that renames are recorded correctly
28
29 $ hg mv b b2
30 $ hg ci -m 'rename b to b2'
31 $ hg changesetcopies
32 files: b b2
33 p1copies: b2\x00b (esc)
34
35 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.
37
38 $ hg cp b2 c --force
39 $ hg st --copies
40 M c
41 b2
42 $ hg debugindex c
43 rev linkrev nodeid p1 p2
44 0 1 b789fdd96dc2 000000000000 000000000000
45 $ hg ci -m 'move b onto d'
46 $ hg changesetcopies
47 files: c
48 p1copies: c\x00b2 (esc)
49 $ hg debugindex c
50 rev linkrev nodeid p1 p2
51 0 1 b789fdd96dc2 000000000000 000000000000
52
53 Create a merge commit with copying done during merge.
54
55 $ hg co 0
56 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
57 $ hg cp a e
58 $ hg cp a f
59 $ hg ci -m 'copy a to e and f'
60 created new head
61 $ hg merge 3
62 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
63 (branch merge, don't forget to commit)
64 File 'a' exists on both sides, so 'g' could be recorded as being from p1 or p2, but we currently
65 always record it as being from p1
66 $ hg cp a g
67 File 'd' exists only in p2, so 'h' should be from p2
68 $ hg cp d h
69 File 'f' exists only in p1, so 'i' should be from p1
70 $ hg cp f i
71 $ hg ci -m 'merge'
72 $ hg changesetcopies
73 files: g h i
74 p1copies: g\x00a (esc)
75 i\x00f (esc)
76 p2copies: h\x00d (esc)
77
78 Test writing to both changeset and filelog
79
80 $ hg cp a j
81 $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
82 $ hg changesetcopies
83 files: j
84 p1copies: j\x00a (esc)
85 $ hg debugdata j 0
86 \x01 (esc)
87 copy: a
88 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
89 \x01 (esc)
90 a
91
92 Test writing only to filelog
93
94 $ hg cp a k
95 $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
96 $ hg changesetcopies
97 files: k
98 $ hg debugdata k 0
99 \x01 (esc)
100 copy: a
101 copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
102 \x01 (esc)
103 a
104
105 $ cd ..