##// END OF EJS Templates
tests: unify test-convert-git
Matt Mackall -
r12530:f11793a8 default
parent child Browse files
Show More
@@ -1,186 +1,292 b''
1 #!/bin/sh
2
3 "$TESTDIR/hghave" git || exit 80
4
5 echo "[extensions]" >> $HGRCPATH
6 echo "convert=" >> $HGRCPATH
7 echo 'hgext.graphlog =' >> $HGRCPATH
8
9 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
10 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
11 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
12 GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
13 GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
14 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
15
1
16 count=10
2 $ "$TESTDIR/hghave" git || exit 80
17 commit()
3 $ echo "[extensions]" >> $HGRCPATH
18 {
4 $ echo "convert=" >> $HGRCPATH
19 GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
5 $ echo 'hgext.graphlog =' >> $HGRCPATH
20 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
6 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
21 git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
7 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
22 count=`expr $count + 1`
8 $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
23 }
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
24
28
25 mkdir git-repo
29 Remove the directory, then try to replace it with a file
26 cd git-repo
30 (issue 754)
27 git init-db >/dev/null 2>/dev/null
28 echo a > a
29 mkdir d
30 echo b > d/b
31 git add a d
32 commit -a -m t1
33
34 # Remove the directory, then try to replace it with a file
35 # (issue 754)
36 git rm -f d/b
37 commit -m t2
38 echo d > d
39 git add d
40 commit -m t3
41
42 echo b >> a
43 commit -a -m t4.1
44
31
45 git checkout -b other HEAD~ >/dev/null 2>/dev/null
32 $ git rm -f d/b
46 echo c > a
33 rm 'd/b'
47 echo a >> a
34 $ commit -m t2
48 commit -a -m t4.2
35 $ echo d > d
49
36 $ git add d
50 git checkout master >/dev/null 2>/dev/null
37 $ commit -m t3
51 git pull --no-commit . other > /dev/null 2>/dev/null
38 $ echo b >> a
52 commit -m 'Merge branch other'
39 $ commit -a -m t4.1
53 cd ..
40 $ git checkout -b other HEAD~ >/dev/null 2>/dev/null
54
41 $ echo c > a
55 hg convert --datesort git-repo
42 $ echo a >> a
56 hg up -q -R git-repo-hg
43 $ commit -a -m t4.2
57 hg -R git-repo-hg tip -v
44 $ git checkout master >/dev/null 2>/dev/null
58
45 $ git pull --no-commit . other > /dev/null 2>/dev/null
59 count=10
46 $ commit -m 'Merge branch other'
60 mkdir git-repo2
47 $ cd ..
61 cd git-repo2
48 $ hg convert --datesort git-repo
62 git init-db >/dev/null 2>/dev/null
49 assuming destination git-repo-hg
63
50 initializing destination git-repo-hg repository
64 echo foo > foo
51 scanning source...
65 git add foo
52 sorting...
66 commit -a -m 'add foo'
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 > }
67
126
68 echo >> foo
127 full conversion
69 commit -a -m 'change foo'
70
71 git checkout -b Bar HEAD~ >/dev/null 2>/dev/null
72 echo quux >> quux
73 git add quux
74 commit -a -m 'add quux'
75
76 echo bar > bar
77 git add bar
78 commit -a -m 'add bar'
79
80 git checkout -b Baz HEAD~ >/dev/null 2>/dev/null
81 echo baz > baz
82 git add baz
83 commit -a -m 'add baz'
84
85 git checkout master >/dev/null 2>/dev/null
86 git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
87 commit -m 'Octopus merge'
88
89 echo bar >> bar
90 commit -a -m 'change bar'
91
128
92 git checkout -b Foo HEAD~ >/dev/null 2>/dev/null
129 $ hg -q convert --datesort git-repo2 fullrepo
93 echo >> foo
130 $ hg up -q -R fullrepo
94 commit -a -m 'change foo'
131 $ glog -R fullrepo
95
132 @ 9 "Discard change to foo" files: foo
96 git checkout master >/dev/null 2>/dev/null
133 |\
97 git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
134 | o 8 "change foo" files: foo
98 commit -m 'Discard change to foo'
135 | |
99
136 o | 7 "change bar" files: bar
100 cd ..
137 |/
101
138 o 6 "(octopus merge fixup)" files:
102 glog()
139 |\
103 {
140 | o 5 "Octopus merge" files: baz
104 hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
141 | |\
105 }
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
106
201
107 splitrepo()
202 test binary conversion (issue 1359)
108 {
109 msg="$1"
110 files="$2"
111 opts=$3
112 echo "% $files: $msg"
113 prefix=`echo "$files" | sed -e 's/ /-/g'`
114 fmap="$prefix.fmap"
115 repo="$prefix.repo"
116 for i in $files; do
117 echo "include $i" >> "$fmap"
118 done
119 hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
120 hg up -q -R "$repo"
121 glog -R "$repo"
122 hg -R "$repo" manifest --debug
123 }
124
125 echo '% full conversion'
126 hg -q convert --datesort git-repo2 fullrepo
127 hg up -q -R fullrepo
128 glog -R fullrepo
129 hg -R fullrepo manifest --debug
130
131 splitrepo 'octopus merge' 'foo bar baz'
132
133 splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux'
134
203
135 echo
204 $ mkdir git-repo3
136 echo '% test binary conversion (issue 1359)'
205 $ cd git-repo3
137 mkdir git-repo3
206 $ git init-db >/dev/null 2>/dev/null
138 cd git-repo3
207 $ python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
139 git init-db >/dev/null 2>/dev/null
208 $ git add b
140 python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
209 $ commit -a -m addbinary
141 git add b
210 $ cd ..
142 commit -a -m addbinary
211
143 cd ..
212 convert binary file
144
213
145 echo '% convert binary file'
214 $ hg convert git-repo3 git-repo3-hg
146 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
147
228
148 cd git-repo3-hg
229 test author vs committer
149 hg up -C
230
150 python -c 'print len(file("b", "rb").read())'
231 $ mkdir git-repo4
151 cd ..
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
152
243
153 echo
244 $ hg convert git-repo4 git-repo4-hg
154 echo '% test author vs committer'
245 initializing destination git-repo4-hg repository
155 mkdir git-repo4
246 scanning source...
156 cd git-repo4
247 sorting...
157 git init-db >/dev/null 2>/dev/null
248 converting...
158 echo >> foo
249 1 addfoo
159 git add foo
250 0 addfoo2
160 commit -a -m addfoo
251 $ hg -R git-repo4-hg log -v
161 echo >> foo
252 changeset: 1:d63e967f93da
162 GIT_AUTHOR_NAME="nottest"
253 tag: tip
163 commit -a -m addfoo2
254 user: nottest <test@example.org>
164 cd ..
255 date: Mon Jan 01 00:00:21 2007 +0000
165
256 files: foo
166 echo '% convert author committer'
257 description:
167 hg convert git-repo4 git-repo4-hg
258 addfoo2
168 hg -R git-repo4-hg log -v
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
169
271
170 echo '% --sourceorder should fail'
272 --sourceorder should fail
171 hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
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
172
280
173 echo '% damage git repository and convert again'
281 $ cat > damage.py <<EOF
174 cat > damage.py <<EOF
282 > import os
175 import os
283 > for root, dirs, files in os.walk('git-repo4/.git/objects'):
176 for root, dirs, files in os.walk('git-repo4/.git/objects'):
284 > if files:
177 if files:
285 > path = os.path.join(root, files[0])
178 path = os.path.join(root, files[0])
286 > os.remove(path)
179 os.remove(path)
287 > break
180 break
288 > EOF
181 EOF
289 $ python damage.py
182 python damage.py
290 $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
183 hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
291 > grep 'abort:' | sed 's/abort:.*/abort:/g'
184 grep 'abort:' | sed 's/abort:.*/abort:/g'
292 abort:
185
186 true
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