Show More
@@ -1,748 +1,753 b'' | |||
|
1 | 1 | #require git |
|
2 | 2 | |
|
3 | 3 | $ echo "[core]" >> $HOME/.gitconfig |
|
4 | 4 | $ echo "autocrlf = false" >> $HOME/.gitconfig |
|
5 | 5 | $ echo "[core]" >> $HOME/.gitconfig |
|
6 | 6 | $ echo "autocrlf = false" >> $HOME/.gitconfig |
|
7 | 7 | $ echo "[extensions]" >> $HGRCPATH |
|
8 | 8 | $ echo "convert=" >> $HGRCPATH |
|
9 | 9 | $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME |
|
10 | 10 | $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL |
|
11 | 11 | $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE |
|
12 | 12 | $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME |
|
13 | 13 | $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL |
|
14 | 14 | $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE |
|
15 | 15 | $ INVALIDID1=afd12345af |
|
16 | 16 | $ INVALIDID2=28173x36ddd1e67bf7098d541130558ef5534a86 |
|
17 | 17 | $ VALIDID1=39b3d83f9a69a9ba4ebb111461071a0af0027357 |
|
18 | 18 | $ VALIDID2=8dd6476bd09d9c7776355dc454dafe38efaec5da |
|
19 | 19 | $ count=10 |
|
20 | 20 | $ commit() |
|
21 | 21 | > { |
|
22 | 22 | > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000" |
|
23 | 23 | > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" |
|
24 | 24 | > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" |
|
25 | 25 | > count=`expr $count + 1` |
|
26 | 26 | > } |
|
27 | 27 | $ mkdir git-repo |
|
28 | 28 | $ cd git-repo |
|
29 | 29 | $ git init-db >/dev/null 2>/dev/null |
|
30 | 30 | $ echo a > a |
|
31 | 31 | $ mkdir d |
|
32 | 32 | $ echo b > d/b |
|
33 | 33 | $ git add a d |
|
34 | 34 | $ commit -a -m t1 |
|
35 | 35 | |
|
36 | 36 | Remove the directory, then try to replace it with a file (issue754) |
|
37 | 37 | |
|
38 | 38 | $ git rm -f d/b |
|
39 | 39 | rm 'd/b' |
|
40 | 40 | $ commit -m t2 |
|
41 | 41 | $ echo d > d |
|
42 | 42 | $ git add d |
|
43 | 43 | $ commit -m t3 |
|
44 | 44 | $ echo b >> a |
|
45 | 45 | $ commit -a -m t4.1 |
|
46 | 46 | $ git checkout -b other HEAD~ >/dev/null 2>/dev/null |
|
47 | 47 | $ echo c > a |
|
48 | 48 | $ echo a >> a |
|
49 | 49 | $ commit -a -m t4.2 |
|
50 | 50 | $ git checkout master >/dev/null 2>/dev/null |
|
51 | 51 | $ git pull --no-commit . other > /dev/null 2>/dev/null |
|
52 | 52 | $ commit -m 'Merge branch other' |
|
53 | 53 | $ cd .. |
|
54 | 54 | $ hg convert --config extensions.progress= --config progress.assume-tty=1 \ |
|
55 | 55 | > --config progress.delay=0 --config progress.changedelay=0 \ |
|
56 | 56 | > --config progress.refresh=0 --config progress.width=60 \ |
|
57 | 57 | > --config progress.format='topic, bar, number' --datesort git-repo |
|
58 | 58 | \r (no-eol) (esc) |
|
59 | 59 | scanning [======> ] 1/6\r (no-eol) (esc) |
|
60 | 60 | scanning [=============> ] 2/6\r (no-eol) (esc) |
|
61 | 61 | scanning [=====================> ] 3/6\r (no-eol) (esc) |
|
62 | 62 | scanning [============================> ] 4/6\r (no-eol) (esc) |
|
63 | 63 | scanning [===================================> ] 5/6\r (no-eol) (esc) |
|
64 | 64 | scanning [===========================================>] 6/6\r (no-eol) (esc) |
|
65 | 65 | \r (no-eol) (esc) |
|
66 | 66 | \r (no-eol) (esc) |
|
67 | 67 | converting [ ] 0/6\r (no-eol) (esc) |
|
68 | 68 | getting files [==================> ] 1/2\r (no-eol) (esc) |
|
69 | 69 | getting files [======================================>] 2/2\r (no-eol) (esc) |
|
70 | 70 | \r (no-eol) (esc) |
|
71 | 71 | \r (no-eol) (esc) |
|
72 | 72 | converting [======> ] 1/6\r (no-eol) (esc) |
|
73 | 73 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
74 | 74 | \r (no-eol) (esc) |
|
75 | 75 | \r (no-eol) (esc) |
|
76 | 76 | converting [=============> ] 2/6\r (no-eol) (esc) |
|
77 | 77 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
78 | 78 | \r (no-eol) (esc) |
|
79 | 79 | \r (no-eol) (esc) |
|
80 | 80 | converting [====================> ] 3/6\r (no-eol) (esc) |
|
81 | 81 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
82 | 82 | \r (no-eol) (esc) |
|
83 | 83 | \r (no-eol) (esc) |
|
84 | 84 | converting [===========================> ] 4/6\r (no-eol) (esc) |
|
85 | 85 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
86 | 86 | \r (no-eol) (esc) |
|
87 | 87 | \r (no-eol) (esc) |
|
88 | 88 | converting [==================================> ] 5/6\r (no-eol) (esc) |
|
89 | 89 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
90 | 90 | \r (no-eol) (esc) |
|
91 | 91 | assuming destination git-repo-hg |
|
92 | 92 | initializing destination git-repo-hg repository |
|
93 | 93 | scanning source... |
|
94 | 94 | sorting... |
|
95 | 95 | converting... |
|
96 | 96 | 5 t1 |
|
97 | 97 | 4 t2 |
|
98 | 98 | 3 t3 |
|
99 | 99 | 2 t4.1 |
|
100 | 100 | 1 t4.2 |
|
101 | 101 | 0 Merge branch other |
|
102 | 102 | updating bookmarks |
|
103 | 103 | $ hg up -q -R git-repo-hg |
|
104 | 104 | $ hg -R git-repo-hg tip -v |
|
105 | 105 | changeset: 5:c78094926be2 |
|
106 | 106 | bookmark: master |
|
107 | 107 | tag: tip |
|
108 | 108 | parent: 3:f5f5cb45432b |
|
109 | 109 | parent: 4:4e174f80c67c |
|
110 | 110 | user: test <test@example.org> |
|
111 | 111 | date: Mon Jan 01 00:00:15 2007 +0000 |
|
112 | 112 | files: a |
|
113 | 113 | description: |
|
114 | 114 | Merge branch other |
|
115 | 115 | |
|
116 | 116 | |
|
117 | 117 | $ count=10 |
|
118 | 118 | $ mkdir git-repo2 |
|
119 | 119 | $ cd git-repo2 |
|
120 | 120 | $ git init-db >/dev/null 2>/dev/null |
|
121 | 121 | $ echo foo > foo |
|
122 | 122 | $ git add foo |
|
123 | 123 | $ commit -a -m 'add foo' |
|
124 | 124 | $ echo >> foo |
|
125 | 125 | $ commit -a -m 'change foo' |
|
126 | 126 | $ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null |
|
127 | 127 | $ echo quux >> quux |
|
128 | 128 | $ git add quux |
|
129 | 129 | $ commit -a -m 'add quux' |
|
130 | 130 | $ echo bar > bar |
|
131 | 131 | $ git add bar |
|
132 | 132 | $ commit -a -m 'add bar' |
|
133 | 133 | $ git checkout -b Baz HEAD~ >/dev/null 2>/dev/null |
|
134 | 134 | $ echo baz > baz |
|
135 | 135 | $ git add baz |
|
136 | 136 | $ commit -a -m 'add baz' |
|
137 | 137 | $ git checkout master >/dev/null 2>/dev/null |
|
138 | 138 | $ git pull --no-commit . Bar Baz > /dev/null 2>/dev/null |
|
139 | 139 | $ commit -m 'Octopus merge' |
|
140 | 140 | $ echo bar >> bar |
|
141 | 141 | $ commit -a -m 'change bar' |
|
142 | 142 | $ git checkout -b Foo HEAD~ >/dev/null 2>/dev/null |
|
143 | 143 | $ echo >> foo |
|
144 | 144 | $ commit -a -m 'change foo' |
|
145 | 145 | $ git checkout master >/dev/null 2>/dev/null |
|
146 | 146 | $ git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null |
|
147 | 147 | $ commit -m 'Discard change to foo' |
|
148 | 148 | $ cd .. |
|
149 | 149 | $ glog() |
|
150 | 150 | > { |
|
151 | 151 | > hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@" |
|
152 | 152 | > } |
|
153 | 153 | $ splitrepo() |
|
154 | 154 | > { |
|
155 | 155 | > msg="$1" |
|
156 | 156 | > files="$2" |
|
157 | 157 | > opts=$3 |
|
158 | 158 | > echo "% $files: $msg" |
|
159 | 159 | > prefix=`echo "$files" | sed -e 's/ /-/g'` |
|
160 | 160 | > fmap="$prefix.fmap" |
|
161 | 161 | > repo="$prefix.repo" |
|
162 | 162 | > for i in $files; do |
|
163 | 163 | > echo "include $i" >> "$fmap" |
|
164 | 164 | > done |
|
165 | 165 | > hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo" |
|
166 | 166 | > hg up -q -R "$repo" |
|
167 | 167 | > glog -R "$repo" |
|
168 | 168 | > hg -R "$repo" manifest --debug |
|
169 | 169 | > } |
|
170 | 170 | |
|
171 | 171 | full conversion |
|
172 | 172 | |
|
173 | 173 | $ hg convert --datesort git-repo2 fullrepo \ |
|
174 | 174 | > --config extensions.progress= --config progress.assume-tty=1 \ |
|
175 | 175 | > --config progress.delay=0 --config progress.changedelay=0 \ |
|
176 | 176 | > --config progress.refresh=0 --config progress.width=60 \ |
|
177 | 177 | > --config progress.format='topic, bar, number' |
|
178 | 178 | \r (no-eol) (esc) |
|
179 | 179 | scanning [===> ] 1/9\r (no-eol) (esc) |
|
180 | 180 | scanning [========> ] 2/9\r (no-eol) (esc) |
|
181 | 181 | scanning [=============> ] 3/9\r (no-eol) (esc) |
|
182 | 182 | scanning [==================> ] 4/9\r (no-eol) (esc) |
|
183 | 183 | scanning [=======================> ] 5/9\r (no-eol) (esc) |
|
184 | 184 | scanning [============================> ] 6/9\r (no-eol) (esc) |
|
185 | 185 | scanning [=================================> ] 7/9\r (no-eol) (esc) |
|
186 | 186 | scanning [======================================> ] 8/9\r (no-eol) (esc) |
|
187 | 187 | scanning [===========================================>] 9/9\r (no-eol) (esc) |
|
188 | 188 | \r (no-eol) (esc) |
|
189 | 189 | \r (no-eol) (esc) |
|
190 | 190 | converting [ ] 0/9\r (no-eol) (esc) |
|
191 | 191 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
192 | 192 | \r (no-eol) (esc) |
|
193 | 193 | \r (no-eol) (esc) |
|
194 | 194 | converting [===> ] 1/9\r (no-eol) (esc) |
|
195 | 195 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
196 | 196 | \r (no-eol) (esc) |
|
197 | 197 | \r (no-eol) (esc) |
|
198 | 198 | converting [========> ] 2/9\r (no-eol) (esc) |
|
199 | 199 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
200 | 200 | \r (no-eol) (esc) |
|
201 | 201 | \r (no-eol) (esc) |
|
202 | 202 | converting [=============> ] 3/9\r (no-eol) (esc) |
|
203 | 203 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
204 | 204 | \r (no-eol) (esc) |
|
205 | 205 | \r (no-eol) (esc) |
|
206 | 206 | converting [=================> ] 4/9\r (no-eol) (esc) |
|
207 | 207 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
208 | 208 | \r (no-eol) (esc) |
|
209 | 209 | \r (no-eol) (esc) |
|
210 | 210 | converting [======================> ] 5/9\r (no-eol) (esc) |
|
211 | 211 | getting files [===> ] 1/8\r (no-eol) (esc) |
|
212 | 212 | getting files [========> ] 2/8\r (no-eol) (esc) |
|
213 | 213 | getting files [=============> ] 3/8\r (no-eol) (esc) |
|
214 | 214 | getting files [==================> ] 4/8\r (no-eol) (esc) |
|
215 | 215 | getting files [=======================> ] 5/8\r (no-eol) (esc) |
|
216 | 216 | getting files [============================> ] 6/8\r (no-eol) (esc) |
|
217 | 217 | getting files [=================================> ] 7/8\r (no-eol) (esc) |
|
218 | 218 | getting files [======================================>] 8/8\r (no-eol) (esc) |
|
219 | 219 | \r (no-eol) (esc) |
|
220 | 220 | \r (no-eol) (esc) |
|
221 | 221 | converting [===========================> ] 6/9\r (no-eol) (esc) |
|
222 | 222 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
223 | 223 | \r (no-eol) (esc) |
|
224 | 224 | \r (no-eol) (esc) |
|
225 | 225 | converting [===============================> ] 7/9\r (no-eol) (esc) |
|
226 | 226 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
227 | 227 | \r (no-eol) (esc) |
|
228 | 228 | \r (no-eol) (esc) |
|
229 | 229 | converting [====================================> ] 8/9\r (no-eol) (esc) |
|
230 | 230 | getting files [==================> ] 1/2\r (no-eol) (esc) |
|
231 | 231 | getting files [======================================>] 2/2\r (no-eol) (esc) |
|
232 | 232 | \r (no-eol) (esc) |
|
233 | 233 | initializing destination fullrepo repository |
|
234 | 234 | scanning source... |
|
235 | 235 | sorting... |
|
236 | 236 | converting... |
|
237 | 237 | 8 add foo |
|
238 | 238 | 7 change foo |
|
239 | 239 | 6 add quux |
|
240 | 240 | 5 add bar |
|
241 | 241 | 4 add baz |
|
242 | 242 | 3 Octopus merge |
|
243 | 243 | 2 change bar |
|
244 | 244 | 1 change foo |
|
245 | 245 | 0 Discard change to foo |
|
246 | 246 | updating bookmarks |
|
247 | 247 | $ hg up -q -R fullrepo |
|
248 | 248 | $ glog -R fullrepo |
|
249 | 249 | @ 9 "Discard change to foo" files: foo |
|
250 | 250 | |\ |
|
251 | 251 | | o 8 "change foo" files: foo |
|
252 | 252 | | | |
|
253 | 253 | o | 7 "change bar" files: bar |
|
254 | 254 | |/ |
|
255 | 255 | o 6 "(octopus merge fixup)" files: |
|
256 | 256 | |\ |
|
257 | 257 | | o 5 "Octopus merge" files: baz |
|
258 | 258 | | |\ |
|
259 | 259 | o | | 4 "add baz" files: baz |
|
260 | 260 | | | | |
|
261 | 261 | +---o 3 "add bar" files: bar |
|
262 | 262 | | | |
|
263 | 263 | o | 2 "add quux" files: quux |
|
264 | 264 | | | |
|
265 | 265 | | o 1 "change foo" files: foo |
|
266 | 266 | |/ |
|
267 | 267 | o 0 "add foo" files: foo |
|
268 | 268 | |
|
269 | 269 | $ hg -R fullrepo manifest --debug |
|
270 | 270 | 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar |
|
271 | 271 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
|
272 | 272 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
|
273 | 273 | 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux |
|
274 | 274 | $ splitrepo 'octopus merge' 'foo bar baz' |
|
275 | 275 | % foo bar baz: octopus merge |
|
276 | 276 | @ 8 "Discard change to foo" files: foo |
|
277 | 277 | |\ |
|
278 | 278 | | o 7 "change foo" files: foo |
|
279 | 279 | | | |
|
280 | 280 | o | 6 "change bar" files: bar |
|
281 | 281 | |/ |
|
282 | 282 | o 5 "(octopus merge fixup)" files: |
|
283 | 283 | |\ |
|
284 | 284 | | o 4 "Octopus merge" files: baz |
|
285 | 285 | | |\ |
|
286 | 286 | o | | 3 "add baz" files: baz |
|
287 | 287 | | | | |
|
288 | 288 | +---o 2 "add bar" files: bar |
|
289 | 289 | | | |
|
290 | 290 | | o 1 "change foo" files: foo |
|
291 | 291 | |/ |
|
292 | 292 | o 0 "add foo" files: foo |
|
293 | 293 | |
|
294 | 294 | 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar |
|
295 | 295 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
|
296 | 296 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
|
297 | 297 | $ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' |
|
298 | 298 | % foo baz quux: only some parents of an octopus merge; "discard" a head |
|
299 | 299 | @ 6 "Discard change to foo" files: foo |
|
300 | 300 | | |
|
301 | 301 | o 5 "change foo" files: foo |
|
302 | 302 | | |
|
303 | 303 | o 4 "Octopus merge" files: |
|
304 | 304 | |\ |
|
305 | 305 | | o 3 "add baz" files: baz |
|
306 | 306 | | | |
|
307 | 307 | | o 2 "add quux" files: quux |
|
308 | 308 | | | |
|
309 | 309 | o | 1 "change foo" files: foo |
|
310 | 310 | |/ |
|
311 | 311 | o 0 "add foo" files: foo |
|
312 | 312 | |
|
313 | 313 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
|
314 | 314 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
|
315 | 315 | 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux |
|
316 | 316 | |
|
317 | 317 | test importing git renames and copies |
|
318 | 318 | |
|
319 | 319 | $ cd git-repo2 |
|
320 | 320 | $ git mv foo foo-renamed |
|
321 | 321 | since bar is not touched in this commit, this copy will not be detected |
|
322 | 322 | $ cp bar bar-copied |
|
323 | 323 | $ cp baz baz-copied |
|
324 | 324 | $ cp baz baz-copied2 |
|
325 | 325 | $ cp baz ba-copy |
|
326 | 326 | $ echo baz2 >> baz |
|
327 | 327 | $ git add bar-copied baz-copied baz-copied2 ba-copy |
|
328 | 328 | $ commit -a -m 'rename and copy' |
|
329 | 329 | $ cd .. |
|
330 | 330 | |
|
331 | 331 | input validation |
|
332 | 332 | $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo |
|
333 | 333 | abort: convert.git.similarity is not an integer ('foo') |
|
334 | 334 | [255] |
|
335 | 335 | $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo |
|
336 | 336 | abort: similarity must be between 0 and 100 |
|
337 | 337 | [255] |
|
338 | 338 | $ hg convert --config convert.git.similarity=101 --datesort git-repo2 fullrepo |
|
339 | 339 | abort: similarity must be between 0 and 100 |
|
340 | 340 | [255] |
|
341 | 341 | |
|
342 | 342 | $ hg -q convert --config convert.git.similarity=100 --datesort git-repo2 fullrepo |
|
343 | 343 | $ hg -R fullrepo status -C --change master |
|
344 | 344 | M baz |
|
345 | 345 | A ba-copy |
|
346 | 346 | baz |
|
347 | 347 | A bar-copied |
|
348 | 348 | A baz-copied |
|
349 | 349 | baz |
|
350 | 350 | A baz-copied2 |
|
351 | 351 | baz |
|
352 | 352 | A foo-renamed |
|
353 | 353 | foo |
|
354 | 354 | R foo |
|
355 | 355 | |
|
356 | 356 | Ensure that the modification to the copy source was preserved |
|
357 | 357 | (there was a bug where if the copy dest was alphabetically prior to the copy |
|
358 | 358 | source, the copy source took the contents of the copy dest) |
|
359 | 359 | $ hg cat -r tip fullrepo/baz |
|
360 | 360 | baz |
|
361 | 361 | baz2 |
|
362 | 362 | |
|
363 | 363 | $ cd git-repo2 |
|
364 | 364 | $ echo bar2 >> bar |
|
365 | 365 | $ commit -a -m 'change bar' |
|
366 | 366 | $ cp bar bar-copied2 |
|
367 | 367 | $ git add bar-copied2 |
|
368 | 368 | $ commit -a -m 'copy with no changes' |
|
369 | 369 | $ cd .. |
|
370 | 370 | |
|
371 | 371 | $ hg -q convert --config convert.git.similarity=100 \ |
|
372 | 372 | > --config convert.git.findcopiesharder=1 --datesort git-repo2 fullrepo |
|
373 | 373 | $ hg -R fullrepo status -C --change master |
|
374 | 374 | A bar-copied2 |
|
375 | 375 | bar |
|
376 | 376 | |
|
377 | 377 | test binary conversion (issue1359) |
|
378 | 378 | |
|
379 | 379 | $ count=19 |
|
380 | 380 | $ mkdir git-repo3 |
|
381 | 381 | $ cd git-repo3 |
|
382 | 382 | $ git init-db >/dev/null 2>/dev/null |
|
383 | 383 | $ $PYTHON -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)' |
|
384 | 384 | $ git add b |
|
385 | 385 | $ commit -a -m addbinary |
|
386 | 386 | $ cd .. |
|
387 | 387 | |
|
388 | 388 | convert binary file |
|
389 | 389 | |
|
390 | 390 | $ hg convert git-repo3 git-repo3-hg |
|
391 | 391 | initializing destination git-repo3-hg repository |
|
392 | 392 | scanning source... |
|
393 | 393 | sorting... |
|
394 | 394 | converting... |
|
395 | 395 | 0 addbinary |
|
396 | 396 | updating bookmarks |
|
397 | 397 | $ cd git-repo3-hg |
|
398 | 398 | $ hg up -C |
|
399 | 399 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
400 | 400 | $ $PYTHON -c 'print len(file("b", "rb").read())' |
|
401 | 401 | 4096 |
|
402 | 402 | $ cd .. |
|
403 | 403 | |
|
404 | 404 | test author vs committer |
|
405 | 405 | |
|
406 | 406 | $ mkdir git-repo4 |
|
407 | 407 | $ cd git-repo4 |
|
408 | 408 | $ git init-db >/dev/null 2>/dev/null |
|
409 | 409 | $ echo >> foo |
|
410 | 410 | $ git add foo |
|
411 | 411 | $ commit -a -m addfoo |
|
412 | 412 | $ echo >> foo |
|
413 | 413 | $ GIT_AUTHOR_NAME="nottest" |
|
414 | 414 | $ commit -a -m addfoo2 |
|
415 | 415 | $ cd .. |
|
416 | 416 | |
|
417 | 417 | convert author committer |
|
418 | 418 | |
|
419 | 419 | $ hg convert git-repo4 git-repo4-hg |
|
420 | 420 | initializing destination git-repo4-hg repository |
|
421 | 421 | scanning source... |
|
422 | 422 | sorting... |
|
423 | 423 | converting... |
|
424 | 424 | 1 addfoo |
|
425 | 425 | 0 addfoo2 |
|
426 | 426 | updating bookmarks |
|
427 | 427 | $ hg -R git-repo4-hg log -v |
|
428 | 428 | changeset: 1:d63e967f93da |
|
429 | 429 | bookmark: master |
|
430 | 430 | tag: tip |
|
431 | 431 | user: nottest <test@example.org> |
|
432 | 432 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
433 | 433 | files: foo |
|
434 | 434 | description: |
|
435 | 435 | addfoo2 |
|
436 | 436 | |
|
437 | 437 | committer: test <test@example.org> |
|
438 | 438 | |
|
439 | 439 | |
|
440 | 440 | changeset: 0:0735477b0224 |
|
441 | 441 | user: test <test@example.org> |
|
442 | 442 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
443 | 443 | files: foo |
|
444 | 444 | description: |
|
445 | 445 | addfoo |
|
446 | 446 | |
|
447 | 447 | |
|
448 | 448 | |
|
449 | 449 | --sourceorder should fail |
|
450 | 450 | |
|
451 | 451 | $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg |
|
452 | 452 | initializing destination git-repo4-sourcesort-hg repository |
|
453 | 453 | abort: --sourcesort is not supported by this data source |
|
454 | 454 | [255] |
|
455 | 455 | |
|
456 | 456 | test converting certain branches |
|
457 | 457 | |
|
458 | 458 | $ mkdir git-testrevs |
|
459 | 459 | $ cd git-testrevs |
|
460 | 460 | $ git init |
|
461 | 461 | Initialized empty Git repository in $TESTTMP/git-testrevs/.git/ |
|
462 | 462 | $ echo a >> a ; git add a > /dev/null; git commit -m 'first' > /dev/null |
|
463 | 463 | $ echo a >> a ; git add a > /dev/null; git commit -m 'master commit' > /dev/null |
|
464 | 464 | $ git checkout -b goodbranch 'HEAD^' |
|
465 | 465 | Switched to a new branch 'goodbranch' |
|
466 | 466 | $ echo a >> b ; git add b > /dev/null; git commit -m 'good branch commit' > /dev/null |
|
467 | 467 | $ git checkout -b badbranch 'HEAD^' |
|
468 | 468 | Switched to a new branch 'badbranch' |
|
469 | 469 | $ echo a >> c ; git add c > /dev/null; git commit -m 'bad branch commit' > /dev/null |
|
470 | 470 | $ cd .. |
|
471 | 471 | $ hg convert git-testrevs hg-testrevs --rev master --rev goodbranch |
|
472 | 472 | initializing destination hg-testrevs repository |
|
473 | 473 | scanning source... |
|
474 | 474 | sorting... |
|
475 | 475 | converting... |
|
476 | 476 | 2 first |
|
477 | 477 | 1 good branch commit |
|
478 | 478 | 0 master commit |
|
479 | 479 | updating bookmarks |
|
480 | 480 | $ cd hg-testrevs |
|
481 | 481 | $ hg log -G -T '{rev} {bookmarks}' |
|
482 | 482 | o 2 master |
|
483 | 483 | | |
|
484 | 484 | | o 1 goodbranch |
|
485 | 485 | |/ |
|
486 | 486 | o 0 |
|
487 | 487 | |
|
488 | 488 | $ cd .. |
|
489 | 489 | |
|
490 | 490 | test sub modules |
|
491 | 491 | |
|
492 | 492 | $ mkdir git-repo5 |
|
493 | 493 | $ cd git-repo5 |
|
494 | 494 | $ git init-db >/dev/null 2>/dev/null |
|
495 | 495 | $ echo 'sub' >> foo |
|
496 | 496 | $ git add foo |
|
497 | 497 | $ commit -a -m 'addfoo' |
|
498 | 498 | $ BASE=`pwd` |
|
499 | 499 | $ cd .. |
|
500 | 500 | $ mkdir git-repo6 |
|
501 | 501 | $ cd git-repo6 |
|
502 | 502 | $ git init-db >/dev/null 2>/dev/null |
|
503 | 503 | $ git submodule add ${BASE} >/dev/null 2>/dev/null |
|
504 | 504 | $ commit -a -m 'addsubmodule' >/dev/null 2>/dev/null |
|
505 | 505 | |
|
506 | 506 | test non-tab whitespace .gitmodules |
|
507 | 507 | |
|
508 | 508 | $ cat >> .gitmodules <<EOF |
|
509 | 509 | > [submodule "git-repo5"] |
|
510 | 510 | > path = git-repo5 |
|
511 | 511 | > url = git-repo5 |
|
512 | 512 | > EOF |
|
513 | 513 | $ git commit -q -a -m "weird white space submodule" |
|
514 | 514 | $ cd .. |
|
515 | 515 | $ hg convert git-repo6 hg-repo6 |
|
516 | 516 | initializing destination hg-repo6 repository |
|
517 | 517 | scanning source... |
|
518 | 518 | sorting... |
|
519 | 519 | converting... |
|
520 | 520 | 1 addsubmodule |
|
521 | 521 | 0 weird white space submodule |
|
522 | 522 | updating bookmarks |
|
523 | 523 | |
|
524 | 524 | $ rm -rf hg-repo6 |
|
525 | 525 | $ cd git-repo6 |
|
526 | 526 | $ git reset --hard 'HEAD^' > /dev/null |
|
527 | 527 | |
|
528 | 528 | test missing .gitmodules |
|
529 | 529 | |
|
530 | 530 | $ git submodule add ../git-repo4 >/dev/null 2>/dev/null |
|
531 | 531 | $ git checkout HEAD .gitmodules |
|
532 | 532 | $ git rm .gitmodules |
|
533 | 533 | rm '.gitmodules' |
|
534 | 534 | $ git commit -q -m "remove .gitmodules" .gitmodules |
|
535 | 535 | $ git commit -q -m "missing .gitmodules" |
|
536 | 536 | $ cd .. |
|
537 | 537 | $ hg convert git-repo6 hg-repo6 --traceback 2>&1 | grep -v "fatal: Path '.gitmodules' does not exist" |
|
538 | 538 | initializing destination hg-repo6 repository |
|
539 | 539 | scanning source... |
|
540 | 540 | sorting... |
|
541 | 541 | converting... |
|
542 | 542 | 2 addsubmodule |
|
543 | 543 | 1 remove .gitmodules |
|
544 | 544 | 0 missing .gitmodules |
|
545 | 545 | warning: cannot read submodules config file in * (glob) |
|
546 | 546 | updating bookmarks |
|
547 | 547 | $ rm -rf hg-repo6 |
|
548 | 548 | $ cd git-repo6 |
|
549 | 549 | $ rm -rf git-repo4 |
|
550 | 550 | $ git reset --hard 'HEAD^^' > /dev/null |
|
551 | 551 | $ cd .. |
|
552 | 552 | |
|
553 | 553 | test invalid splicemap1 |
|
554 | 554 | |
|
555 | 555 | $ cat > splicemap <<EOF |
|
556 | 556 | > $VALIDID1 |
|
557 | 557 | > EOF |
|
558 | 558 | $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap1-hg |
|
559 | 559 | initializing destination git-repo2-splicemap1-hg repository |
|
560 | 560 | abort: syntax error in splicemap(1): child parent1[,parent2] expected |
|
561 | 561 | [255] |
|
562 | 562 | |
|
563 | 563 | test invalid splicemap2 |
|
564 | 564 | |
|
565 | 565 | $ cat > splicemap <<EOF |
|
566 | 566 | > $VALIDID1 $VALIDID2, $VALIDID2, $VALIDID2 |
|
567 | 567 | > EOF |
|
568 | 568 | $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap2-hg |
|
569 | 569 | initializing destination git-repo2-splicemap2-hg repository |
|
570 | 570 | abort: syntax error in splicemap(1): child parent1[,parent2] expected |
|
571 | 571 | [255] |
|
572 | 572 | |
|
573 | 573 | test invalid splicemap3 |
|
574 | 574 | |
|
575 | 575 | $ cat > splicemap <<EOF |
|
576 | 576 | > $INVALIDID1 $INVALIDID2 |
|
577 | 577 | > EOF |
|
578 | 578 | $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap3-hg |
|
579 | 579 | initializing destination git-repo2-splicemap3-hg repository |
|
580 | 580 | abort: splicemap entry afd12345af is not a valid revision identifier |
|
581 | 581 | [255] |
|
582 | 582 | |
|
583 | 583 | convert sub modules |
|
584 | 584 | $ hg convert git-repo6 git-repo6-hg |
|
585 | 585 | initializing destination git-repo6-hg repository |
|
586 | 586 | scanning source... |
|
587 | 587 | sorting... |
|
588 | 588 | converting... |
|
589 | 589 | 0 addsubmodule |
|
590 | 590 | updating bookmarks |
|
591 | 591 | $ hg -R git-repo6-hg log -v |
|
592 | 592 | changeset: 0:* (glob) |
|
593 | 593 | bookmark: master |
|
594 | 594 | tag: tip |
|
595 | 595 | user: nottest <test@example.org> |
|
596 | 596 | date: Mon Jan 01 00:00:23 2007 +0000 |
|
597 | 597 | files: .hgsub .hgsubstate |
|
598 | 598 | description: |
|
599 | 599 | addsubmodule |
|
600 | 600 | |
|
601 | 601 | committer: test <test@example.org> |
|
602 | 602 | |
|
603 | 603 | |
|
604 | 604 | |
|
605 | 605 | $ cd git-repo6-hg |
|
606 | 606 | $ hg up >/dev/null 2>/dev/null |
|
607 | 607 | $ cat .hgsubstate |
|
608 | 608 | * git-repo5 (glob) |
|
609 | 609 | $ cd git-repo5 |
|
610 | 610 | $ cat foo |
|
611 | 611 | sub |
|
612 | 612 | |
|
613 | 613 | $ cd ../.. |
|
614 | 614 | |
|
615 | 615 | make sure rename detection doesn't break removing and adding gitmodules |
|
616 | 616 | |
|
617 | 617 | $ cd git-repo6 |
|
618 | 618 | $ git mv .gitmodules .gitmodules-renamed |
|
619 | 619 | $ commit -a -m 'rename .gitmodules' |
|
620 | 620 | $ git mv .gitmodules-renamed .gitmodules |
|
621 | 621 | $ commit -a -m 'rename .gitmodules back' |
|
622 | 622 | $ cd .. |
|
623 | 623 | |
|
624 | 624 | $ hg --config convert.git.similarity=100 convert -q git-repo6 git-repo6-hg |
|
625 | 625 | $ hg -R git-repo6-hg log -r 'tip^' -T "{desc|firstline}\n" |
|
626 | 626 | rename .gitmodules |
|
627 | 627 | $ hg -R git-repo6-hg status -C --change 'tip^' |
|
628 | 628 | A .gitmodules-renamed |
|
629 | 629 | R .hgsub |
|
630 | 630 | R .hgsubstate |
|
631 | 631 | $ hg -R git-repo6-hg log -r tip -T "{desc|firstline}\n" |
|
632 | 632 | rename .gitmodules back |
|
633 | 633 | $ hg -R git-repo6-hg status -C --change tip |
|
634 | 634 | A .hgsub |
|
635 | 635 | A .hgsubstate |
|
636 | 636 | R .gitmodules-renamed |
|
637 | 637 | |
|
638 | 638 | convert the revision removing '.gitmodules' itself (and related |
|
639 | 639 | submodules) |
|
640 | 640 | |
|
641 | 641 | $ cd git-repo6 |
|
642 | 642 | $ git rm .gitmodules |
|
643 | 643 | rm '.gitmodules' |
|
644 | 644 | $ git rm --cached git-repo5 |
|
645 | 645 | rm 'git-repo5' |
|
646 | 646 | $ commit -a -m 'remove .gitmodules and submodule git-repo5' |
|
647 | 647 | $ cd .. |
|
648 | 648 | |
|
649 | 649 | $ hg convert -q git-repo6 git-repo6-hg |
|
650 | 650 | $ hg -R git-repo6-hg tip -T "{desc|firstline}\n" |
|
651 | 651 | remove .gitmodules and submodule git-repo5 |
|
652 | 652 | $ hg -R git-repo6-hg tip -T "{file_dels}\n" |
|
653 | 653 | .hgsub .hgsubstate |
|
654 | 654 | |
|
655 | 655 | skip submodules in the conversion |
|
656 | 656 | |
|
657 | 657 | $ hg convert -q git-repo6 no-submodules --config convert.git.skipsubmodules=True |
|
658 | 658 | $ hg -R no-submodules manifest --all |
|
659 | 659 | .gitmodules-renamed |
|
660 | 660 | |
|
661 | 661 | convert using a different remote prefix |
|
662 | 662 | $ git init git-repo7 |
|
663 | 663 | Initialized empty Git repository in $TESTTMP/git-repo7/.git/ |
|
664 | 664 | $ cd git-repo7 |
|
665 | 665 | TODO: it'd be nice to use (?) lines instead of grep -v to handle the |
|
666 | 666 | git output variance, but that doesn't currently work in the middle of |
|
667 | 667 | a block, so do this for now. |
|
668 | 668 | $ touch a && git add a && git commit -am "commit a" | grep -v changed |
|
669 | 669 | [master (root-commit) 8ae5f69] commit a |
|
670 | 670 | Author: nottest <test@example.org> |
|
671 | 671 | create mode 100644 a |
|
672 | 672 | $ cd .. |
|
673 | 673 | $ git clone git-repo7 git-repo7-client |
|
674 | 674 | Cloning into 'git-repo7-client'... |
|
675 | 675 | done. |
|
676 | 676 | $ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 |
|
677 | 677 | initializing destination hg-repo7 repository |
|
678 | 678 | scanning source... |
|
679 | 679 | sorting... |
|
680 | 680 | converting... |
|
681 | 681 | 0 commit a |
|
682 | 682 | updating bookmarks |
|
683 | 683 | $ hg -R hg-repo7 bookmarks |
|
684 | 684 | master 0:03bf38caa4c6 |
|
685 | 685 | origin/master 0:03bf38caa4c6 |
|
686 | 686 | |
|
687 | 687 | Run convert when the remote branches have changed |
|
688 | 688 | (there was an old bug where the local convert read branches from the server) |
|
689 | 689 | |
|
690 | 690 | $ cd git-repo7 |
|
691 | 691 | $ echo a >> a |
|
692 | 692 | $ git commit -q -am "move master forward" |
|
693 | 693 | $ cd .. |
|
694 | 694 | $ rm -rf hg-repo7 |
|
695 | 695 | $ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 |
|
696 | 696 | initializing destination hg-repo7 repository |
|
697 | 697 | scanning source... |
|
698 | 698 | sorting... |
|
699 | 699 | converting... |
|
700 | 700 | 0 commit a |
|
701 | 701 | updating bookmarks |
|
702 | 702 | $ hg -R hg-repo7 bookmarks |
|
703 | 703 | master 0:03bf38caa4c6 |
|
704 | 704 | origin/master 0:03bf38caa4c6 |
|
705 | 705 | |
|
706 | 706 | damaged git repository tests: |
|
707 | 707 | In case the hard-coded hashes change, the following commands can be used to |
|
708 | 708 | list the hashes and their corresponding types in the repository: |
|
709 | 709 | cd git-repo4/.git/objects |
|
710 | 710 | find . -type f | cut -c 3- | sed 's_/__' | xargs -n 1 -t git cat-file -t |
|
711 | 711 | cd ../../.. |
|
712 | 712 | |
|
713 | 713 | damage git repository by renaming a commit object |
|
714 | 714 | $ COMMIT_OBJ=1c/0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd |
|
715 | 715 | $ mv git-repo4/.git/objects/$COMMIT_OBJ git-repo4/.git/objects/$COMMIT_OBJ.tmp |
|
716 | 716 | $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
|
717 | 717 | abort: cannot retrieve number of commits in git-repo4/.git |
|
718 | 718 | $ mv git-repo4/.git/objects/$COMMIT_OBJ.tmp git-repo4/.git/objects/$COMMIT_OBJ |
|
719 | 719 | damage git repository by renaming a blob object |
|
720 | 720 | |
|
721 | 721 | $ BLOB_OBJ=8b/137891791fe96927ad78e64b0aad7bded08bdc |
|
722 | 722 | $ mv git-repo4/.git/objects/$BLOB_OBJ git-repo4/.git/objects/$BLOB_OBJ.tmp |
|
723 | 723 | $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
|
724 | 724 | abort: cannot read 'blob' object at 8b137891791fe96927ad78e64b0aad7bded08bdc |
|
725 | 725 | $ mv git-repo4/.git/objects/$BLOB_OBJ.tmp git-repo4/.git/objects/$BLOB_OBJ |
|
726 | 726 | damage git repository by renaming a tree object |
|
727 | 727 | |
|
728 | 728 | $ TREE_OBJ=72/49f083d2a63a41cc737764a86981eb5f3e4635 |
|
729 | 729 | $ mv git-repo4/.git/objects/$TREE_OBJ git-repo4/.git/objects/$TREE_OBJ.tmp |
|
730 | 730 | $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
|
731 | 731 | abort: cannot read changes in 1c0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd |
|
732 | 732 | |
|
733 | #if no-windows | |
|
734 | ||
|
733 | 735 | test for escaping the repo name (CVE-2016-3069) |
|
734 | 736 | |
|
735 | 737 | $ git init '`echo pwned >COMMAND-INJECTION`' |
|
736 | 738 | Initialized empty Git repository in $TESTTMP/`echo pwned >COMMAND-INJECTION`/.git/ |
|
737 | 739 | $ cd '`echo pwned >COMMAND-INJECTION`' |
|
738 | 740 | $ git commit -q --allow-empty -m 'empty' |
|
739 | 741 | $ cd .. |
|
740 | 742 | $ hg convert '`echo pwned >COMMAND-INJECTION`' 'converted' |
|
741 | 743 | initializing destination converted repository |
|
742 | 744 | scanning source... |
|
743 | 745 | sorting... |
|
744 | 746 | converting... |
|
745 | 747 | 0 empty |
|
746 | 748 | updating bookmarks |
|
747 | 749 | $ test -f COMMAND-INJECTION |
|
748 | 750 | [1] |
|
751 | ||
|
752 | #endif | |
|
753 |
General Comments 0
You need to be logged in to leave comments.
Login now