Show More
@@ -1,141 +1,284 | |||||
1 | #!/bin/sh |
|
|||
2 |
|
||||
3 | HGMERGE=true; export HGMERGE |
|
|||
4 |
|
||||
5 | echo '[extensions]' >> $HGRCPATH |
|
|||
6 | echo 'graphlog =' >> $HGRCPATH |
|
|||
7 | echo 'convert =' >> $HGRCPATH |
|
|||
8 |
|
||||
9 | glog() |
|
|||
10 | { |
|
|||
11 | hg glog --template '{rev} "{desc}" files: {files}\n' "$@" |
|
|||
12 | } |
|
|||
13 |
|
||||
14 | hg init source |
|
|||
15 | cd source |
|
|||
16 |
|
||||
17 | echo foo > foo |
|
|||
18 | echo baz > baz |
|
|||
19 | mkdir -p dir/subdir |
|
|||
20 | echo dir/file >> dir/file |
|
|||
21 | echo dir/file2 >> dir/file2 |
|
|||
22 | echo dir/subdir/file3 >> dir/subdir/file3 |
|
|||
23 | echo dir/subdir/file4 >> dir/subdir/file4 |
|
|||
24 | hg ci -d '0 0' -qAm '0: add foo baz dir/' |
|
|||
25 |
|
||||
26 | echo bar > bar |
|
|||
27 | echo quux > quux |
|
|||
28 | hg copy foo copied |
|
|||
29 | hg ci -d '1 0' -qAm '1: add bar quux; copy foo to copied' |
|
|||
30 |
|
||||
31 | echo >> foo |
|
|||
32 | hg ci -d '2 0' -m '2: change foo' |
|
|||
33 |
|
1 | |||
34 | hg up -qC 1 |
|
2 | $ HGMERGE=true; export HGMERGE | |
35 | echo >> bar |
|
3 | $ echo '[extensions]' >> $HGRCPATH | |
36 | echo >> quux |
|
4 | $ echo 'graphlog =' >> $HGRCPATH | |
37 | hg ci -d '3 0' -m '3: change bar quux' |
|
5 | $ echo 'convert =' >> $HGRCPATH | |
38 |
|
6 | $ glog() | ||
39 | hg up -qC 2 |
|
7 | > { | |
40 | hg merge -qr 3 |
|
8 | > hg glog --template '{rev} "{desc}" files: {files}\n' "$@" | |
41 | echo >> bar |
|
9 | > } | |
42 | echo >> baz |
|
10 | $ hg init source | |
43 | hg ci -d '4 0' -m '4: first merge; change bar baz' |
|
11 | $ cd source | |
44 |
|
12 | $ echo foo > foo | ||
45 |
|
|
13 | $ echo baz > baz | |
46 | echo 1 >> baz |
|
14 | $ mkdir -p dir/subdir | |
47 | echo >> quux |
|
15 | $ echo dir/file >> dir/file | |
48 | hg ci -d '5 0' -m '5: change bar baz quux' |
|
16 | $ echo dir/file2 >> dir/file2 | |
|
17 | $ echo dir/subdir/file3 >> dir/subdir/file3 | |||
|
18 | $ echo dir/subdir/file4 >> dir/subdir/file4 | |||
|
19 | $ hg ci -d '0 0' -qAm '0: add foo baz dir/' | |||
|
20 | $ echo bar > bar | |||
|
21 | $ echo quux > quux | |||
|
22 | $ hg copy foo copied | |||
|
23 | $ hg ci -d '1 0' -qAm '1: add bar quux; copy foo to copied' | |||
|
24 | $ echo >> foo | |||
|
25 | $ hg ci -d '2 0' -m '2: change foo' | |||
|
26 | $ hg up -qC 1 | |||
|
27 | $ echo >> bar | |||
|
28 | $ echo >> quux | |||
|
29 | $ hg ci -d '3 0' -m '3: change bar quux' | |||
|
30 | created new head | |||
|
31 | $ hg up -qC 2 | |||
|
32 | $ hg merge -qr 3 | |||
|
33 | $ echo >> bar | |||
|
34 | $ echo >> baz | |||
|
35 | $ hg ci -d '4 0' -m '4: first merge; change bar baz' | |||
|
36 | $ echo >> bar | |||
|
37 | $ echo 1 >> baz | |||
|
38 | $ echo >> quux | |||
|
39 | $ hg ci -d '5 0' -m '5: change bar baz quux' | |||
|
40 | $ hg up -qC 4 | |||
|
41 | $ echo >> foo | |||
|
42 | $ echo 2 >> baz | |||
|
43 | $ hg ci -d '6 0' -m '6: change foo baz' | |||
|
44 | created new head | |||
|
45 | $ hg up -qC 5 | |||
|
46 | $ hg merge -qr 6 | |||
|
47 | $ echo >> bar | |||
|
48 | $ hg ci -d '7 0' -m '7: second merge; change bar' | |||
|
49 | $ echo >> foo | |||
|
50 | $ hg ci -m '8: change foo' | |||
|
51 | $ glog | |||
|
52 | @ 8 "8: change foo" files: foo | |||
|
53 | | | |||
|
54 | o 7 "7: second merge; change bar" files: bar baz | |||
|
55 | |\ | |||
|
56 | | o 6 "6: change foo baz" files: baz foo | |||
|
57 | | | | |||
|
58 | o | 5 "5: change bar baz quux" files: bar baz quux | |||
|
59 | |/ | |||
|
60 | o 4 "4: first merge; change bar baz" files: bar baz | |||
|
61 | |\ | |||
|
62 | | o 3 "3: change bar quux" files: bar quux | |||
|
63 | | | | |||
|
64 | o | 2 "2: change foo" files: foo | |||
|
65 | |/ | |||
|
66 | o 1 "1: add bar quux; copy foo to copied" files: bar copied quux | |||
|
67 | | | |||
|
68 | o 0 "0: add foo baz dir/" files: baz dir/file dir/file2 dir/subdir/file3 dir/subdir/file4 foo | |||
|
69 | ||||
49 |
|
70 | |||
50 | hg up -qC 4 |
|
71 | final file versions in this repo: | |
51 | echo >> foo |
|
|||
52 | echo 2 >> baz |
|
|||
53 | hg ci -d '6 0' -m '6: change foo baz' |
|
|||
54 |
|
||||
55 | hg up -qC 5 |
|
|||
56 | hg merge -qr 6 |
|
|||
57 | echo >> bar |
|
|||
58 | hg ci -d '7 0' -m '7: second merge; change bar' |
|
|||
59 |
|
||||
60 | echo >> foo |
|
|||
61 | hg ci -m '8: change foo' |
|
|||
62 |
|
||||
63 | glog |
|
|||
64 |
|
||||
65 | echo '% final file versions in this repo:' |
|
|||
66 | hg manifest --debug |
|
|||
67 | hg debugrename copied |
|
|||
68 | echo |
|
|||
69 |
|
||||
70 | cd .. |
|
|||
71 |
|
72 | |||
72 | splitrepo() |
|
73 | $ hg manifest --debug | |
73 | { |
|
74 | 9463f52fe115e377cf2878d4fc548117211063f2 644 bar | |
74 | msg="$1" |
|
75 | 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644 baz | |
75 | files="$2" |
|
76 | 7711d36246cc83e61fb29cd6d4ef394c63f1ceaf 644 copied | |
76 | opts=$3 |
|
77 | 3e20847584beff41d7cd16136b7331ab3d754be0 644 dir/file | |
77 | echo "% $files: $msg" |
|
78 | 75e6d3f8328f5f6ace6bf10b98df793416a09dca 644 dir/file2 | |
78 | prefix=`echo "$files" | sed -e 's/ /-/g'` |
|
79 | 5fe139720576e18e34bcc9f79174db8897c8afe9 644 dir/subdir/file3 | |
79 | fmap="$prefix.fmap" |
|
80 | 57a1c1511590f3de52874adfa04effe8a77d64af 644 dir/subdir/file4 | |
80 | repo="$prefix.repo" |
|
81 | 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo | |
81 | for i in $files; do |
|
82 | bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux | |
82 | echo "include $i" >> "$fmap" |
|
83 | $ hg debugrename copied | |
83 | done |
|
84 | copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd | |
84 | hg -q convert $opts --filemap "$fmap" --datesort source "$repo" |
|
85 | $ echo | |
85 | hg up -q -R "$repo" |
|
86 | ||
86 | glog -R "$repo" |
|
87 | $ cd .. | |
87 | hg -R "$repo" manifest --debug |
|
88 | $ splitrepo() | |
88 | } |
|
89 | > { | |
89 |
|
90 | > msg="$1" | ||
90 | splitrepo 'skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd' foo |
|
91 | > files="$2" | |
91 |
|
92 | > opts=$3 | ||
92 | splitrepo 'merges are not merges anymore' bar |
|
93 | > echo "% $files: $msg" | |
93 |
|
94 | > prefix=`echo "$files" | sed -e 's/ /-/g'` | ||
94 | splitrepo '1st merge is not a merge anymore; 2nd still is' baz |
|
95 | > fmap="$prefix.fmap" | |
95 |
|
96 | > repo="$prefix.repo" | ||
96 | splitrepo 'we add additional merges when they are interesting' 'foo quux' |
|
97 | > for i in $files; do | |
97 |
|
98 | > echo "include $i" >> "$fmap" | ||
98 | splitrepo 'partial conversion' 'bar quux' '-r 3' |
|
99 | > done | |
99 | splitrepo 'complete the partial conversion' 'bar quux' |
|
100 | > hg -q convert $opts --filemap "$fmap" --datesort source "$repo" | |
100 |
|
101 | > hg up -q -R "$repo" | ||
101 | rm -r foo.repo |
|
102 | > glog -R "$repo" | |
102 | splitrepo 'partial conversion' 'foo' '-r 3' |
|
103 | > hg -R "$repo" manifest --debug | |
103 | splitrepo 'complete the partial conversion' 'foo' |
|
104 | > } | |
|
105 | $ splitrepo 'skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd' foo | |||
|
106 | % foo: skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd | |||
|
107 | @ 3 "8: change foo" files: foo | |||
|
108 | | | |||
|
109 | o 2 "6: change foo baz" files: foo | |||
|
110 | | | |||
|
111 | o 1 "2: change foo" files: foo | |||
|
112 | | | |||
|
113 | o 0 "0: add foo baz dir/" files: foo | |||
|
114 | ||||
|
115 | 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo | |||
|
116 | $ splitrepo 'merges are not merges anymore' bar | |||
|
117 | % bar: merges are not merges anymore | |||
|
118 | @ 4 "7: second merge; change bar" files: bar | |||
|
119 | | | |||
|
120 | o 3 "5: change bar baz quux" files: bar | |||
|
121 | | | |||
|
122 | o 2 "4: first merge; change bar baz" files: bar | |||
|
123 | | | |||
|
124 | o 1 "3: change bar quux" files: bar | |||
|
125 | | | |||
|
126 | o 0 "1: add bar quux; copy foo to copied" files: bar | |||
|
127 | ||||
|
128 | 9463f52fe115e377cf2878d4fc548117211063f2 644 bar | |||
|
129 | $ splitrepo '1st merge is not a merge anymore; 2nd still is' baz | |||
|
130 | % baz: 1st merge is not a merge anymore; 2nd still is | |||
|
131 | @ 4 "7: second merge; change bar" files: baz | |||
|
132 | |\ | |||
|
133 | | o 3 "6: change foo baz" files: baz | |||
|
134 | | | | |||
|
135 | o | 2 "5: change bar baz quux" files: baz | |||
|
136 | |/ | |||
|
137 | o 1 "4: first merge; change bar baz" files: baz | |||
|
138 | | | |||
|
139 | o 0 "0: add foo baz dir/" files: baz | |||
|
140 | ||||
|
141 | 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644 baz | |||
|
142 | $ splitrepo 'we add additional merges when they are interesting' 'foo quux' | |||
|
143 | % foo quux: we add additional merges when they are interesting | |||
|
144 | @ 8 "8: change foo" files: foo | |||
|
145 | | | |||
|
146 | o 7 "7: second merge; change bar" files: | |||
|
147 | |\ | |||
|
148 | | o 6 "6: change foo baz" files: foo | |||
|
149 | | | | |||
|
150 | o | 5 "5: change bar baz quux" files: quux | |||
|
151 | |/ | |||
|
152 | o 4 "4: first merge; change bar baz" files: | |||
|
153 | |\ | |||
|
154 | | o 3 "3: change bar quux" files: quux | |||
|
155 | | | | |||
|
156 | o | 2 "2: change foo" files: foo | |||
|
157 | |/ | |||
|
158 | o 1 "1: add bar quux; copy foo to copied" files: quux | |||
|
159 | | | |||
|
160 | o 0 "0: add foo baz dir/" files: foo | |||
|
161 | ||||
|
162 | 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo | |||
|
163 | bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux | |||
|
164 | $ splitrepo 'partial conversion' 'bar quux' '-r 3' | |||
|
165 | % bar quux: partial conversion | |||
|
166 | @ 1 "3: change bar quux" files: bar quux | |||
|
167 | | | |||
|
168 | o 0 "1: add bar quux; copy foo to copied" files: bar quux | |||
|
169 | ||||
|
170 | b79105bedc55102f394e90a789c9c380117c1b4a 644 bar | |||
|
171 | db0421cc6b685a458c8d86c7d5c004f94429ea23 644 quux | |||
|
172 | $ splitrepo 'complete the partial conversion' 'bar quux' | |||
|
173 | % bar quux: complete the partial conversion | |||
|
174 | @ 4 "7: second merge; change bar" files: bar | |||
|
175 | | | |||
|
176 | o 3 "5: change bar baz quux" files: bar quux | |||
|
177 | | | |||
|
178 | o 2 "4: first merge; change bar baz" files: bar | |||
|
179 | | | |||
|
180 | o 1 "3: change bar quux" files: bar quux | |||
|
181 | | | |||
|
182 | o 0 "1: add bar quux; copy foo to copied" files: bar quux | |||
|
183 | ||||
|
184 | 9463f52fe115e377cf2878d4fc548117211063f2 644 bar | |||
|
185 | bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux | |||
|
186 | $ rm -r foo.repo | |||
|
187 | $ splitrepo 'partial conversion' 'foo' '-r 3' | |||
|
188 | % foo: partial conversion | |||
|
189 | @ 0 "0: add foo baz dir/" files: foo | |||
|
190 | ||||
|
191 | 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo | |||
|
192 | $ splitrepo 'complete the partial conversion' 'foo' | |||
|
193 | % foo: complete the partial conversion | |||
|
194 | @ 3 "8: change foo" files: foo | |||
|
195 | | | |||
|
196 | o 2 "6: change foo baz" files: foo | |||
|
197 | | | |||
|
198 | o 1 "2: change foo" files: foo | |||
|
199 | | | |||
|
200 | o 0 "0: add foo baz dir/" files: foo | |||
|
201 | ||||
|
202 | 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo | |||
|
203 | $ splitrepo 'copied file; source not included in new repo' copied | |||
|
204 | % copied: copied file; source not included in new repo | |||
|
205 | @ 0 "1: add bar quux; copy foo to copied" files: copied | |||
|
206 | ||||
|
207 | 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 copied | |||
|
208 | $ hg --cwd copied.repo debugrename copied | |||
|
209 | copied not renamed | |||
|
210 | $ splitrepo 'copied file; source included in new repo' 'foo copied' | |||
|
211 | % foo copied: copied file; source included in new repo | |||
|
212 | @ 4 "8: change foo" files: foo | |||
|
213 | | | |||
|
214 | o 3 "6: change foo baz" files: foo | |||
|
215 | | | |||
|
216 | o 2 "2: change foo" files: foo | |||
|
217 | | | |||
|
218 | o 1 "1: add bar quux; copy foo to copied" files: copied | |||
|
219 | | | |||
|
220 | o 0 "0: add foo baz dir/" files: foo | |||
|
221 | ||||
|
222 | 7711d36246cc83e61fb29cd6d4ef394c63f1ceaf 644 copied | |||
|
223 | 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo | |||
|
224 | $ hg --cwd foo-copied.repo debugrename copied | |||
|
225 | copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd | |||
|
226 | $ cat > renames.fmap <<EOF | |||
|
227 | > include dir | |||
|
228 | > exclude dir/file2 | |||
|
229 | > rename dir dir2 | |||
|
230 | > include foo | |||
|
231 | > include copied | |||
|
232 | > rename foo foo2 | |||
|
233 | > rename copied copied2 | |||
|
234 | > exclude dir/subdir | |||
|
235 | > include dir/subdir/file3 | |||
|
236 | > EOF | |||
|
237 | $ hg -q convert --filemap renames.fmap --datesort source renames.repo | |||
|
238 | $ hg up -q -R renames.repo | |||
|
239 | $ glog -R renames.repo | |||
|
240 | @ 4 "8: change foo" files: foo2 | |||
|
241 | | | |||
|
242 | o 3 "6: change foo baz" files: foo2 | |||
|
243 | | | |||
|
244 | o 2 "2: change foo" files: foo2 | |||
|
245 | | | |||
|
246 | o 1 "1: add bar quux; copy foo to copied" files: copied2 | |||
|
247 | | | |||
|
248 | o 0 "0: add foo baz dir/" files: dir2/file dir2/subdir/file3 foo2 | |||
|
249 | ||||
|
250 | $ hg -R renames.repo manifest --debug | |||
|
251 | d43feacba7a4f1f2080dde4a4b985bd8a0236d46 644 copied2 | |||
|
252 | 3e20847584beff41d7cd16136b7331ab3d754be0 644 dir2/file | |||
|
253 | 5fe139720576e18e34bcc9f79174db8897c8afe9 644 dir2/subdir/file3 | |||
|
254 | 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo2 | |||
|
255 | $ hg --cwd renames.repo debugrename copied2 | |||
|
256 | copied2 renamed from foo2:2ed2a3912a0b24502043eae84ee4b279c18b90dd | |||
104 |
|
257 | |||
105 | splitrepo 'copied file; source not included in new repo' copied |
|
258 | copied: | |
106 | hg --cwd copied.repo debugrename copied |
|
259 | ||
|
260 | $ hg --cwd source cat copied | |||
|
261 | foo | |||
107 |
|
262 | |||
108 | splitrepo 'copied file; source included in new repo' 'foo copied' |
|
263 | copied2: | |
109 | hg --cwd foo-copied.repo debugrename copied |
|
264 | ||
|
265 | $ hg --cwd renames.repo cat copied2 | |||
|
266 | foo | |||
|
267 | ||||
|
268 | filemap errors | |||
110 |
|
269 | |||
111 |
cat > |
|
270 | $ cat > errors.fmap <<EOF | |
112 | include dir |
|
271 | > include dir/ # beware that comments changes error line numbers! | |
113 |
exclude dir |
|
272 | > exclude /dir | |
114 | rename dir dir2 |
|
273 | > rename dir//dir /dir//dir/ "out of sync" | |
115 |
include |
|
274 | > include | |
116 | include copied |
|
275 | > EOF | |
117 | rename foo foo2 |
|
276 | $ hg -q convert --filemap errors.fmap source errors.repo | |
118 | rename copied copied2 |
|
277 | errors.fmap:1: superfluous / in exclude 'dir/' | |
119 | exclude dir/subdir |
|
278 | errors.fmap:3: superfluous / in include '/dir' | |
120 | include dir/subdir/file3 |
|
279 | errors.fmap:3: superfluous / in rename '/dir' | |
121 | EOF |
|
280 | errors.fmap:3: superfluous / in exclude 'dir//dir' | |
122 | hg -q convert --filemap renames.fmap --datesort source renames.repo |
|
281 | errors.fmap:4: unknown directive 'out of sync' | |
123 | hg up -q -R renames.repo |
|
282 | errors.fmap:5: path to exclude is missing | |
124 | glog -R renames.repo |
|
283 | abort: errors in filemap | |
125 | hg -R renames.repo manifest --debug |
|
284 | [255] | |
126 | hg --cwd renames.repo debugrename copied2 |
|
|||
127 | echo 'copied:' |
|
|||
128 | hg --cwd source cat copied |
|
|||
129 | echo 'copied2:' |
|
|||
130 | hg --cwd renames.repo cat copied2 |
|
|||
131 |
|
||||
132 | echo % filemap errors |
|
|||
133 | cat > errors.fmap <<EOF |
|
|||
134 | include dir/ # beware that comments changes error line numbers! |
|
|||
135 | exclude /dir |
|
|||
136 | rename dir//dir /dir//dir/ "out of sync" |
|
|||
137 | include |
|
|||
138 | EOF |
|
|||
139 | hg -q convert --filemap errors.fmap source errors.repo |
|
|||
140 |
|
||||
141 | true # happy ending |
|
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now