Show More
@@ -1,186 +1,292 | |||||
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 | |
|
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 | |||
54 |
|
71 | |||
55 | hg convert --datesort git-repo |
|
|||
56 | hg up -q -R git-repo-hg |
|
|||
57 | hg -R git-repo-hg tip -v |
|
|||
58 |
|
||||
59 | count=10 |
|
|||
60 | mkdir git-repo2 |
|
|||
61 | cd git-repo2 |
|
|||
62 | git init-db >/dev/null 2>/dev/null |
|
|||
63 |
|
||||
64 | echo foo > foo |
|
|||
65 | git add foo |
|
|||
66 | commit -a -m 'add foo' |
|
|||
67 |
|
72 | |||
68 | echo >> foo |
|
73 | $ count=10 | |
69 | commit -a -m 'change foo' |
|
74 | $ mkdir git-repo2 | |
70 |
|
75 | $ cd git-repo2 | ||
71 |
|
|
76 | $ git init-db >/dev/null 2>/dev/null | |
72 | echo quux >> quux |
|
77 | $ echo foo > foo | |
73 | git add quux |
|
78 | $ git add foo | |
74 |
commit -a -m 'add |
|
79 | $ commit -a -m 'add foo' | |
75 |
|
80 | $ echo >> foo | ||
76 | echo bar > bar |
|
81 | $ commit -a -m 'change foo' | |
77 | git add bar |
|
82 | $ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null | |
78 | commit -a -m 'add bar' |
|
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 | > } | |||
79 |
|
126 | |||
80 | git checkout -b Baz HEAD~ >/dev/null 2>/dev/null |
|
127 | full conversion | |
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 | |||
106 |
|
151 | |||
107 | splitrepo() |
|
152 | $ hg -R fullrepo manifest --debug | |
108 | { |
|
153 | 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar | |
109 | msg="$1" |
|
154 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz | |
110 | files="$2" |
|
155 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo | |
111 | opts=$3 |
|
156 | 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux | |
112 | echo "% $files: $msg" |
|
157 | $ splitrepo 'octopus merge' 'foo bar baz' | |
113 | prefix=`echo "$files" | sed -e 's/ /-/g'` |
|
158 | % foo bar baz: octopus merge | |
114 | fmap="$prefix.fmap" |
|
159 | @ 8 "Discard change to foo" files: foo | |
115 | repo="$prefix.repo" |
|
160 | |\ | |
116 | for i in $files; do |
|
161 | | o 7 "change foo" files: foo | |
117 | echo "include $i" >> "$fmap" |
|
162 | | | | |
118 | done |
|
163 | o | 6 "change bar" files: bar | |
119 | hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo" |
|
164 | |/ | |
120 | hg up -q -R "$repo" |
|
165 | o 5 "(octopus merge fixup)" files: | |
121 | glog -R "$repo" |
|
166 | |\ | |
122 | hg -R "$repo" manifest --debug |
|
167 | | o 4 "Octopus merge" files: baz | |
123 | } |
|
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 | |||
124 |
|
176 | |||
125 | echo '% full conversion' |
|
177 | 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar | |
126 | hg -q convert --datesort git-repo2 fullrepo |
|
178 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz | |
127 | hg up -q -R fullrepo |
|
179 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo | |
128 | glog -R fullrepo |
|
180 | $ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' | |
129 | hg -R fullrepo manifest --debug |
|
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 | |||
130 |
|
195 | |||
131 | splitrepo 'octopus merge' 'foo bar baz' |
|
196 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz | |
|
197 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo | |||
|
198 | 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux | |||
|
199 | $ echo | |||
132 |
|
200 | |||
133 | splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' |
|
201 | ||
|
202 | test binary conversion (issue 1359) | |||
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 |
|
|
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 | |
|
256 | files: foo | |||
|
257 | description: | |||
|
258 | addfoo2 | |||
165 |
|
259 | |||
166 | echo '% convert author committer' |
|
260 | committer: test <test@example.org> | |
167 | hg convert git-repo4 git-repo4-hg |
|
261 | ||
168 | hg -R git-repo4-hg log -v |
|
|||
169 |
|
262 | |||
170 | echo '% --sourceorder should fail' |
|
263 | changeset: 0:0735477b0224 | |
171 | hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg |
|
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 | |||
172 |
|
273 | |||
173 | echo '% damage git repository and convert again' |
|
274 | $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg | |
174 | cat > damage.py <<EOF |
|
275 | initializing destination git-repo4-sourcesort-hg repository | |
175 | import os |
|
276 | abort: --sourcesort is not supported by this data source | |
176 | for root, dirs, files in os.walk('git-repo4/.git/objects'): |
|
277 | [255] | |
177 | if files: |
|
278 | ||
178 | path = os.path.join(root, files[0]) |
|
279 | damage git repository and convert again | |
179 | os.remove(path) |
|
|||
180 | break |
|
|||
181 | EOF |
|
|||
182 | python damage.py |
|
|||
183 | hg convert git-repo4 git-repo4-broken-hg 2>&1 | \ |
|
|||
184 | grep 'abort:' | sed 's/abort:.*/abort:/g' |
|
|||
185 |
|
280 | |||
186 | true |
|
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: |
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