Mercurial > hg > mercurial-source
comparison tests/test-convert-git.t @ 12530:f11793a8c107
tests: unify test-convert-git
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Sep 2010 17:16:46 -0500 |
parents | tests/test-convert-git@bb377a311109 |
children | 4c4aeaab2339 |
comparison
equal
deleted
inserted
replaced
12529:00e7a7fdae7d | 12530:f11793a8c107 |
---|---|
1 | |
2 $ "$TESTDIR/hghave" git || exit 80 | |
3 $ echo "[extensions]" >> $HGRCPATH | |
4 $ echo "convert=" >> $HGRCPATH | |
5 $ echo 'hgext.graphlog =' >> $HGRCPATH | |
6 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME | |
7 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL | |
8 $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE | |
9 $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME | |
10 $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL | |
11 $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE | |
12 $ count=10 | |
13 $ commit() | |
14 > { | |
15 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000" | |
16 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" | |
17 > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" | |
18 > count=`expr $count + 1` | |
19 > } | |
20 $ mkdir git-repo | |
21 $ cd git-repo | |
22 $ git init-db >/dev/null 2>/dev/null | |
23 $ echo a > a | |
24 $ mkdir d | |
25 $ echo b > d/b | |
26 $ git add a d | |
27 $ commit -a -m t1 | |
28 | |
29 Remove the directory, then try to replace it with a file | |
30 (issue 754) | |
31 | |
32 $ git rm -f d/b | |
33 rm 'd/b' | |
34 $ commit -m t2 | |
35 $ echo d > d | |
36 $ git add d | |
37 $ commit -m t3 | |
38 $ echo b >> a | |
39 $ commit -a -m t4.1 | |
40 $ git checkout -b other HEAD~ >/dev/null 2>/dev/null | |
41 $ echo c > a | |
42 $ echo a >> a | |
43 $ commit -a -m t4.2 | |
44 $ git checkout master >/dev/null 2>/dev/null | |
45 $ git pull --no-commit . other > /dev/null 2>/dev/null | |
46 $ commit -m 'Merge branch other' | |
47 $ cd .. | |
48 $ hg convert --datesort git-repo | |
49 assuming destination git-repo-hg | |
50 initializing destination git-repo-hg repository | |
51 scanning source... | |
52 sorting... | |
53 converting... | |
54 5 t1 | |
55 4 t2 | |
56 3 t3 | |
57 2 t4.1 | |
58 1 t4.2 | |
59 0 Merge branch other | |
60 $ hg up -q -R git-repo-hg | |
61 $ hg -R git-repo-hg tip -v | |
62 changeset: 5:c78094926be2 | |
63 tag: tip | |
64 parent: 3:f5f5cb45432b | |
65 parent: 4:4e174f80c67c | |
66 user: test <test@example.org> | |
67 date: Mon Jan 01 00:00:15 2007 +0000 | |
68 files: a | |
69 description: | |
70 Merge branch other | |
71 | |
72 | |
73 $ count=10 | |
74 $ mkdir git-repo2 | |
75 $ cd git-repo2 | |
76 $ git init-db >/dev/null 2>/dev/null | |
77 $ echo foo > foo | |
78 $ git add foo | |
79 $ commit -a -m 'add foo' | |
80 $ echo >> foo | |
81 $ commit -a -m 'change foo' | |
82 $ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null | |
83 $ echo quux >> quux | |
84 $ git add quux | |
85 $ commit -a -m 'add quux' | |
86 $ echo bar > bar | |
87 $ git add bar | |
88 $ commit -a -m 'add bar' | |
89 $ git checkout -b Baz HEAD~ >/dev/null 2>/dev/null | |
90 $ echo baz > baz | |
91 $ git add baz | |
92 $ commit -a -m 'add baz' | |
93 $ git checkout master >/dev/null 2>/dev/null | |
94 $ git pull --no-commit . Bar Baz > /dev/null 2>/dev/null | |
95 $ commit -m 'Octopus merge' | |
96 $ echo bar >> bar | |
97 $ commit -a -m 'change bar' | |
98 $ git checkout -b Foo HEAD~ >/dev/null 2>/dev/null | |
99 $ echo >> foo | |
100 $ commit -a -m 'change foo' | |
101 $ git checkout master >/dev/null 2>/dev/null | |
102 $ git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null | |
103 $ commit -m 'Discard change to foo' | |
104 $ cd .. | |
105 $ glog() | |
106 > { | |
107 > hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@" | |
108 > } | |
109 $ splitrepo() | |
110 > { | |
111 > msg="$1" | |
112 > files="$2" | |
113 > opts=$3 | |
114 > echo "% $files: $msg" | |
115 > prefix=`echo "$files" | sed -e 's/ /-/g'` | |
116 > fmap="$prefix.fmap" | |
117 > repo="$prefix.repo" | |
118 > for i in $files; do | |
119 > echo "include $i" >> "$fmap" | |
120 > done | |
121 > hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo" | |
122 > hg up -q -R "$repo" | |
123 > glog -R "$repo" | |
124 > hg -R "$repo" manifest --debug | |
125 > } | |
126 | |
127 full conversion | |
128 | |
129 $ hg -q convert --datesort git-repo2 fullrepo | |
130 $ hg up -q -R fullrepo | |
131 $ glog -R fullrepo | |
132 @ 9 "Discard change to foo" files: foo | |
133 |\ | |
134 | o 8 "change foo" files: foo | |
135 | | | |
136 o | 7 "change bar" files: bar | |
137 |/ | |
138 o 6 "(octopus merge fixup)" files: | |
139 |\ | |
140 | o 5 "Octopus merge" files: baz | |
141 | |\ | |
142 o | | 4 "add baz" files: baz | |
143 | | | | |
144 +---o 3 "add bar" files: bar | |
145 | | | |
146 o | 2 "add quux" files: quux | |
147 | | | |
148 | o 1 "change foo" files: foo | |
149 |/ | |
150 o 0 "add foo" files: foo | |
151 | |
152 $ hg -R fullrepo manifest --debug | |
153 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar | |
154 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz | |
155 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo | |
156 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux | |
157 $ splitrepo 'octopus merge' 'foo bar baz' | |
158 % foo bar baz: octopus merge | |
159 @ 8 "Discard change to foo" files: foo | |
160 |\ | |
161 | o 7 "change foo" files: foo | |
162 | | | |
163 o | 6 "change bar" files: bar | |
164 |/ | |
165 o 5 "(octopus merge fixup)" files: | |
166 |\ | |
167 | o 4 "Octopus merge" files: baz | |
168 | |\ | |
169 o | | 3 "add baz" files: baz | |
170 | | | | |
171 +---o 2 "add bar" files: bar | |
172 | | | |
173 | o 1 "change foo" files: foo | |
174 |/ | |
175 o 0 "add foo" files: foo | |
176 | |
177 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar | |
178 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz | |
179 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo | |
180 $ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' | |
181 % foo baz quux: only some parents of an octopus merge; "discard" a head | |
182 @ 6 "Discard change to foo" files: foo | |
183 | | |
184 o 5 "change foo" files: foo | |
185 | | |
186 o 4 "Octopus merge" files: | |
187 |\ | |
188 | o 3 "add baz" files: baz | |
189 | | | |
190 | o 2 "add quux" files: quux | |
191 | | | |
192 o | 1 "change foo" files: foo | |
193 |/ | |
194 o 0 "add foo" files: foo | |
195 | |
196 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz | |
197 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo | |
198 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux | |
199 $ echo | |
200 | |
201 | |
202 test binary conversion (issue 1359) | |
203 | |
204 $ mkdir git-repo3 | |
205 $ cd git-repo3 | |
206 $ git init-db >/dev/null 2>/dev/null | |
207 $ python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)' | |
208 $ git add b | |
209 $ commit -a -m addbinary | |
210 $ cd .. | |
211 | |
212 convert binary file | |
213 | |
214 $ hg convert git-repo3 git-repo3-hg | |
215 initializing destination git-repo3-hg repository | |
216 scanning source... | |
217 sorting... | |
218 converting... | |
219 0 addbinary | |
220 $ cd git-repo3-hg | |
221 $ hg up -C | |
222 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
223 $ python -c 'print len(file("b", "rb").read())' | |
224 4096 | |
225 $ cd .. | |
226 $ echo | |
227 | |
228 | |
229 test author vs committer | |
230 | |
231 $ mkdir git-repo4 | |
232 $ cd git-repo4 | |
233 $ git init-db >/dev/null 2>/dev/null | |
234 $ echo >> foo | |
235 $ git add foo | |
236 $ commit -a -m addfoo | |
237 $ echo >> foo | |
238 $ GIT_AUTHOR_NAME="nottest" | |
239 $ commit -a -m addfoo2 | |
240 $ cd .. | |
241 | |
242 convert author committer | |
243 | |
244 $ hg convert git-repo4 git-repo4-hg | |
245 initializing destination git-repo4-hg repository | |
246 scanning source... | |
247 sorting... | |
248 converting... | |
249 1 addfoo | |
250 0 addfoo2 | |
251 $ hg -R git-repo4-hg log -v | |
252 changeset: 1:d63e967f93da | |
253 tag: tip | |
254 user: nottest <test@example.org> | |
255 date: Mon Jan 01 00:00:21 2007 +0000 | |
256 files: foo | |
257 description: | |
258 addfoo2 | |
259 | |
260 committer: test <test@example.org> | |
261 | |
262 | |
263 changeset: 0:0735477b0224 | |
264 user: test <test@example.org> | |
265 date: Mon Jan 01 00:00:20 2007 +0000 | |
266 files: foo | |
267 description: | |
268 addfoo | |
269 | |
270 | |
271 | |
272 --sourceorder should fail | |
273 | |
274 $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg | |
275 initializing destination git-repo4-sourcesort-hg repository | |
276 abort: --sourcesort is not supported by this data source | |
277 [255] | |
278 | |
279 damage git repository and convert again | |
280 | |
281 $ cat > damage.py <<EOF | |
282 > import os | |
283 > for root, dirs, files in os.walk('git-repo4/.git/objects'): | |
284 > if files: | |
285 > path = os.path.join(root, files[0]) | |
286 > os.remove(path) | |
287 > break | |
288 > EOF | |
289 $ python damage.py | |
290 $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | \ | |
291 > grep 'abort:' | sed 's/abort:.*/abort:/g' | |
292 abort: |