Show More
@@ -1,1171 +1,1171 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 | $ cat >> $HGRCPATH <<EOF |
|
10 | 10 | > [subrepos] |
|
11 | 11 | > git:allowed = true |
|
12 | 12 | > EOF |
|
13 | 13 | $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME |
|
14 | 14 | $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL |
|
15 | 15 | $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE |
|
16 | 16 | $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME |
|
17 | 17 | $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL |
|
18 | 18 | $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE |
|
19 | 19 | $ INVALIDID1=afd12345af |
|
20 | 20 | $ INVALIDID2=28173x36ddd1e67bf7098d541130558ef5534a86 |
|
21 | 21 | $ VALIDID1=39b3d83f9a69a9ba4ebb111461071a0af0027357 |
|
22 | 22 | $ VALIDID2=8dd6476bd09d9c7776355dc454dafe38efaec5da |
|
23 | 23 | $ count=10 |
|
24 | 24 | $ commit() |
|
25 | 25 | > { |
|
26 | 26 | > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000" |
|
27 | 27 | > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" |
|
28 | 28 | > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" |
|
29 | 29 | > count=`expr $count + 1` |
|
30 | 30 | > } |
|
31 | 31 | $ mkdir git-repo |
|
32 | 32 | $ cd git-repo |
|
33 | 33 | $ git init-db >/dev/null 2>/dev/null |
|
34 | 34 | $ echo a > a |
|
35 | 35 | $ mkdir d |
|
36 | 36 | $ echo b > d/b |
|
37 | 37 | $ git add a d |
|
38 | 38 | $ commit -a -m t1 |
|
39 | 39 | |
|
40 | 40 | Remove the directory, then try to replace it with a file (issue754) |
|
41 | 41 | |
|
42 | 42 | $ git rm -f d/b |
|
43 | 43 | rm 'd/b' |
|
44 | 44 | $ commit -m t2 |
|
45 | 45 | $ echo d > d |
|
46 | 46 | $ git add d |
|
47 | 47 | $ commit -m t3 |
|
48 | 48 | $ echo b >> a |
|
49 | 49 | $ commit -a -m t4.1 |
|
50 | 50 | $ git checkout -b other HEAD~ >/dev/null 2>/dev/null |
|
51 | 51 | $ echo c > a |
|
52 | 52 | $ echo a >> a |
|
53 | 53 | $ commit -a -m t4.2 |
|
54 | 54 | $ git checkout master >/dev/null 2>/dev/null |
|
55 | 55 | $ git pull --no-commit . other > /dev/null 2>/dev/null |
|
56 | 56 | $ commit -m 'Merge branch other' |
|
57 | 57 | $ cd .. |
|
58 | 58 | $ hg convert --config extensions.progress= --config progress.assume-tty=1 \ |
|
59 | 59 | > --config progress.delay=0 --config progress.changedelay=0 \ |
|
60 | 60 | > --config progress.refresh=0 --config progress.width=60 \ |
|
61 | 61 | > --config progress.format='topic, bar, number' --datesort git-repo |
|
62 | 62 | \r (no-eol) (esc) |
|
63 | 63 | scanning [======> ] 1/6\r (no-eol) (esc) |
|
64 | 64 | scanning [=============> ] 2/6\r (no-eol) (esc) |
|
65 | 65 | scanning [=====================> ] 3/6\r (no-eol) (esc) |
|
66 | 66 | scanning [============================> ] 4/6\r (no-eol) (esc) |
|
67 | 67 | scanning [===================================> ] 5/6\r (no-eol) (esc) |
|
68 | 68 | scanning [===========================================>] 6/6\r (no-eol) (esc) |
|
69 | 69 | \r (no-eol) (esc) |
|
70 | 70 | \r (no-eol) (esc) |
|
71 | 71 | converting [ ] 0/6\r (no-eol) (esc) |
|
72 | 72 | getting files [==================> ] 1/2\r (no-eol) (esc) |
|
73 | 73 | getting files [======================================>] 2/2\r (no-eol) (esc) |
|
74 | 74 | \r (no-eol) (esc) |
|
75 | 75 | \r (no-eol) (esc) |
|
76 | 76 | converting [======> ] 1/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 [=============> ] 2/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 [====================> ] 3/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 [===========================> ] 4/6\r (no-eol) (esc) |
|
89 | 89 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
90 | 90 | \r (no-eol) (esc) |
|
91 | 91 | \r (no-eol) (esc) |
|
92 | 92 | converting [==================================> ] 5/6\r (no-eol) (esc) |
|
93 | 93 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
94 | 94 | \r (no-eol) (esc) |
|
95 | 95 | assuming destination git-repo-hg |
|
96 | 96 | initializing destination git-repo-hg repository |
|
97 | 97 | scanning source... |
|
98 | 98 | sorting... |
|
99 | 99 | converting... |
|
100 | 100 | 5 t1 |
|
101 | 101 | 4 t2 |
|
102 | 102 | 3 t3 |
|
103 | 103 | 2 t4.1 |
|
104 | 104 | 1 t4.2 |
|
105 | 105 | 0 Merge branch other |
|
106 | 106 | updating bookmarks |
|
107 | 107 | $ hg up -q -R git-repo-hg |
|
108 | 108 | $ hg -R git-repo-hg tip -v |
|
109 | 109 | changeset: 5:c78094926be2 |
|
110 | 110 | bookmark: master |
|
111 | 111 | tag: tip |
|
112 | 112 | parent: 3:f5f5cb45432b |
|
113 | 113 | parent: 4:4e174f80c67c |
|
114 | 114 | user: test <test@example.org> |
|
115 | 115 | date: Mon Jan 01 00:00:15 2007 +0000 |
|
116 | 116 | files: a |
|
117 | 117 | description: |
|
118 | 118 | Merge branch other |
|
119 | 119 | |
|
120 | 120 | |
|
121 | 121 | $ count=10 |
|
122 | 122 | $ mkdir git-repo2 |
|
123 | 123 | $ cd git-repo2 |
|
124 | 124 | $ git init-db >/dev/null 2>/dev/null |
|
125 | 125 | $ echo foo > foo |
|
126 | 126 | $ git add foo |
|
127 | 127 | $ commit -a -m 'add foo' |
|
128 | 128 | $ echo >> foo |
|
129 | 129 | $ commit -a -m 'change foo' |
|
130 | 130 | $ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null |
|
131 | 131 | $ echo quux >> quux |
|
132 | 132 | $ git add quux |
|
133 | 133 | $ commit -a -m 'add quux' |
|
134 | 134 | $ echo bar > bar |
|
135 | 135 | $ git add bar |
|
136 | 136 | $ commit -a -m 'add bar' |
|
137 | 137 | $ git checkout -b Baz HEAD~ >/dev/null 2>/dev/null |
|
138 | 138 | $ echo baz > baz |
|
139 | 139 | $ git add baz |
|
140 | 140 | $ commit -a -m 'add baz' |
|
141 | 141 | $ git checkout master >/dev/null 2>/dev/null |
|
142 | 142 | $ git pull --no-commit . Bar Baz > /dev/null 2>/dev/null |
|
143 | 143 | $ commit -m 'Octopus merge' |
|
144 | 144 | $ echo bar >> bar |
|
145 | 145 | $ commit -a -m 'change bar' |
|
146 | 146 | $ git checkout -b Foo HEAD~ >/dev/null 2>/dev/null |
|
147 | 147 | $ echo >> foo |
|
148 | 148 | $ commit -a -m 'change foo' |
|
149 | 149 | $ git checkout master >/dev/null 2>/dev/null |
|
150 | 150 | $ git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null |
|
151 | 151 | $ commit -m 'Discard change to foo' |
|
152 | 152 | $ cd .. |
|
153 | 153 | $ glog() |
|
154 | 154 | > { |
|
155 | 155 | > hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@" |
|
156 | 156 | > } |
|
157 | 157 | $ splitrepo() |
|
158 | 158 | > { |
|
159 | 159 | > msg="$1" |
|
160 | 160 | > files="$2" |
|
161 | 161 | > opts=$3 |
|
162 | 162 | > echo "% $files: $msg" |
|
163 | 163 | > prefix=`echo "$files" | sed -e 's/ /-/g'` |
|
164 | 164 | > fmap="$prefix.fmap" |
|
165 | 165 | > repo="$prefix.repo" |
|
166 | 166 | > for i in $files; do |
|
167 | 167 | > echo "include $i" >> "$fmap" |
|
168 | 168 | > done |
|
169 | 169 | > hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo" |
|
170 | 170 | > hg up -q -R "$repo" |
|
171 | 171 | > glog -R "$repo" |
|
172 | 172 | > hg -R "$repo" manifest --debug |
|
173 | 173 | > } |
|
174 | 174 | |
|
175 | 175 | full conversion |
|
176 | 176 | |
|
177 | 177 | $ hg convert --datesort git-repo2 fullrepo \ |
|
178 | 178 | > --config extensions.progress= --config progress.assume-tty=1 \ |
|
179 | 179 | > --config progress.delay=0 --config progress.changedelay=0 \ |
|
180 | 180 | > --config progress.refresh=0 --config progress.width=60 \ |
|
181 | 181 | > --config progress.format='topic, bar, number' |
|
182 | 182 | \r (no-eol) (esc) |
|
183 | 183 | scanning [===> ] 1/9\r (no-eol) (esc) |
|
184 | 184 | scanning [========> ] 2/9\r (no-eol) (esc) |
|
185 | 185 | scanning [=============> ] 3/9\r (no-eol) (esc) |
|
186 | 186 | scanning [==================> ] 4/9\r (no-eol) (esc) |
|
187 | 187 | scanning [=======================> ] 5/9\r (no-eol) (esc) |
|
188 | 188 | scanning [============================> ] 6/9\r (no-eol) (esc) |
|
189 | 189 | scanning [=================================> ] 7/9\r (no-eol) (esc) |
|
190 | 190 | scanning [======================================> ] 8/9\r (no-eol) (esc) |
|
191 | 191 | scanning [===========================================>] 9/9\r (no-eol) (esc) |
|
192 | 192 | \r (no-eol) (esc) |
|
193 | 193 | \r (no-eol) (esc) |
|
194 | 194 | converting [ ] 0/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 [===> ] 1/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 [========> ] 2/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 [=============> ] 3/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 [=================> ] 4/9\r (no-eol) (esc) |
|
211 | 211 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
212 | 212 | \r (no-eol) (esc) |
|
213 | 213 | \r (no-eol) (esc) |
|
214 | 214 | converting [======================> ] 5/9\r (no-eol) (esc) |
|
215 | 215 | getting files [===> ] 1/8\r (no-eol) (esc) |
|
216 | 216 | getting files [========> ] 2/8\r (no-eol) (esc) |
|
217 | 217 | getting files [=============> ] 3/8\r (no-eol) (esc) |
|
218 | 218 | getting files [==================> ] 4/8\r (no-eol) (esc) |
|
219 | 219 | getting files [=======================> ] 5/8\r (no-eol) (esc) |
|
220 | 220 | getting files [============================> ] 6/8\r (no-eol) (esc) |
|
221 | 221 | getting files [=================================> ] 7/8\r (no-eol) (esc) |
|
222 | 222 | getting files [======================================>] 8/8\r (no-eol) (esc) |
|
223 | 223 | \r (no-eol) (esc) |
|
224 | 224 | \r (no-eol) (esc) |
|
225 | 225 | converting [===========================> ] 6/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 [===============================> ] 7/9\r (no-eol) (esc) |
|
230 | 230 | getting files [======================================>] 1/1\r (no-eol) (esc) |
|
231 | 231 | \r (no-eol) (esc) |
|
232 | 232 | \r (no-eol) (esc) |
|
233 | 233 | converting [====================================> ] 8/9\r (no-eol) (esc) |
|
234 | 234 | getting files [==================> ] 1/2\r (no-eol) (esc) |
|
235 | 235 | getting files [======================================>] 2/2\r (no-eol) (esc) |
|
236 | 236 | \r (no-eol) (esc) |
|
237 | 237 | initializing destination fullrepo repository |
|
238 | 238 | scanning source... |
|
239 | 239 | sorting... |
|
240 | 240 | converting... |
|
241 | 241 | 8 add foo |
|
242 | 242 | 7 change foo |
|
243 | 243 | 6 add quux |
|
244 | 244 | 5 add bar |
|
245 | 245 | 4 add baz |
|
246 | 246 | 3 Octopus merge |
|
247 | 247 | 2 change bar |
|
248 | 248 | 1 change foo |
|
249 | 249 | 0 Discard change to foo |
|
250 | 250 | updating bookmarks |
|
251 | 251 | $ hg up -q -R fullrepo |
|
252 | 252 | $ glog -R fullrepo |
|
253 | 253 | @ 9 "Discard change to foo" files: foo |
|
254 | 254 | |\ |
|
255 | 255 | | o 8 "change foo" files: foo |
|
256 | 256 | | | |
|
257 | 257 | o | 7 "change bar" files: bar |
|
258 | 258 | |/ |
|
259 | 259 | o 6 "(octopus merge fixup)" files: |
|
260 | 260 | |\ |
|
261 | 261 | | o 5 "Octopus merge" files: baz |
|
262 | 262 | | |\ |
|
263 | 263 | o | | 4 "add baz" files: baz |
|
264 | 264 | | | | |
|
265 | 265 | +---o 3 "add bar" files: bar |
|
266 | 266 | | | |
|
267 | 267 | o | 2 "add quux" files: quux |
|
268 | 268 | | | |
|
269 | 269 | | o 1 "change foo" files: foo |
|
270 | 270 | |/ |
|
271 | 271 | o 0 "add foo" files: foo |
|
272 | 272 | |
|
273 | 273 | $ hg -R fullrepo manifest --debug |
|
274 | 274 | 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar |
|
275 | 275 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
|
276 | 276 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
|
277 | 277 | 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux |
|
278 | 278 | $ splitrepo 'octopus merge' 'foo bar baz' |
|
279 | 279 | % foo bar baz: octopus merge |
|
280 | 280 | @ 8 "Discard change to foo" files: foo |
|
281 | 281 | |\ |
|
282 | 282 | | o 7 "change foo" files: foo |
|
283 | 283 | | | |
|
284 | 284 | o | 6 "change bar" files: bar |
|
285 | 285 | |/ |
|
286 | 286 | o 5 "(octopus merge fixup)" files: |
|
287 | 287 | |\ |
|
288 | 288 | | o 4 "Octopus merge" files: baz |
|
289 | 289 | | |\ |
|
290 | 290 | o | | 3 "add baz" files: baz |
|
291 | 291 | | | | |
|
292 | 292 | +---o 2 "add bar" files: bar |
|
293 | 293 | | | |
|
294 | 294 | | o 1 "change foo" files: foo |
|
295 | 295 | |/ |
|
296 | 296 | o 0 "add foo" files: foo |
|
297 | 297 | |
|
298 | 298 | 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar |
|
299 | 299 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
|
300 | 300 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
|
301 | 301 | $ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' |
|
302 | 302 | % foo baz quux: only some parents of an octopus merge; "discard" a head |
|
303 | 303 | @ 6 "Discard change to foo" files: foo |
|
304 | 304 | | |
|
305 | 305 | o 5 "change foo" files: foo |
|
306 | 306 | | |
|
307 | 307 | o 4 "Octopus merge" files: |
|
308 | 308 | |\ |
|
309 | 309 | | o 3 "add baz" files: baz |
|
310 | 310 | | | |
|
311 | 311 | | o 2 "add quux" files: quux |
|
312 | 312 | | | |
|
313 | 313 | o | 1 "change foo" files: foo |
|
314 | 314 | |/ |
|
315 | 315 | o 0 "add foo" files: foo |
|
316 | 316 | |
|
317 | 317 | 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
|
318 | 318 | 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
|
319 | 319 | 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux |
|
320 | 320 | |
|
321 | 321 | test importing git renames and copies |
|
322 | 322 | |
|
323 | 323 | $ cd git-repo2 |
|
324 | 324 | $ git mv foo foo-renamed |
|
325 | 325 | since bar is not touched in this commit, this copy will not be detected |
|
326 | 326 | $ cp bar bar-copied |
|
327 | 327 | $ cp baz baz-copied |
|
328 | 328 | $ cp baz baz-copied2 |
|
329 | 329 | $ cp baz ba-copy |
|
330 | 330 | $ echo baz2 >> baz |
|
331 | 331 | $ git add bar-copied baz-copied baz-copied2 ba-copy |
|
332 | 332 | $ commit -a -m 'rename and copy' |
|
333 | 333 | $ cd .. |
|
334 | 334 | |
|
335 | 335 | input validation |
|
336 | 336 | $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo |
|
337 | 337 | abort: convert.git.similarity is not a valid integer ('foo') |
|
338 | 338 | [255] |
|
339 | 339 | $ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo |
|
340 | 340 | abort: similarity must be between 0 and 100 |
|
341 | 341 | [255] |
|
342 | 342 | $ hg convert --config convert.git.similarity=101 --datesort git-repo2 fullrepo |
|
343 | 343 | abort: similarity must be between 0 and 100 |
|
344 | 344 | [255] |
|
345 | 345 | |
|
346 | 346 | $ hg -q convert --config convert.git.similarity=100 --datesort git-repo2 fullrepo |
|
347 | 347 | $ hg -R fullrepo status -C --change master |
|
348 | 348 | M baz |
|
349 | 349 | A ba-copy |
|
350 | 350 | baz |
|
351 | 351 | A bar-copied |
|
352 | 352 | A baz-copied |
|
353 | 353 | baz |
|
354 | 354 | A baz-copied2 |
|
355 | 355 | baz |
|
356 | 356 | A foo-renamed |
|
357 | 357 | foo |
|
358 | 358 | R foo |
|
359 | 359 | |
|
360 | 360 | Ensure that the modification to the copy source was preserved |
|
361 | 361 | (there was a bug where if the copy dest was alphabetically prior to the copy |
|
362 | 362 | source, the copy source took the contents of the copy dest) |
|
363 | 363 | $ hg cat -r tip fullrepo/baz |
|
364 | 364 | baz |
|
365 | 365 | baz2 |
|
366 | 366 | |
|
367 | 367 | $ cd git-repo2 |
|
368 | 368 | $ echo bar2 >> bar |
|
369 | 369 | $ commit -a -m 'change bar' |
|
370 | 370 | $ cp bar bar-copied2 |
|
371 | 371 | $ git add bar-copied2 |
|
372 | 372 | $ commit -a -m 'copy with no changes' |
|
373 | 373 | $ cd .. |
|
374 | 374 | |
|
375 | 375 | $ hg -q convert --config convert.git.similarity=100 \ |
|
376 | 376 | > --config convert.git.findcopiesharder=1 --datesort git-repo2 fullrepo |
|
377 | 377 | $ hg -R fullrepo status -C --change master |
|
378 | 378 | A bar-copied2 |
|
379 | 379 | bar |
|
380 | 380 | |
|
381 | 381 | renamelimit config option works |
|
382 | 382 | |
|
383 | 383 | $ cd git-repo2 |
|
384 | 384 | $ cat >> copy-source << EOF |
|
385 | 385 | > sc0 |
|
386 | 386 | > sc1 |
|
387 | 387 | > sc2 |
|
388 | 388 | > sc3 |
|
389 | 389 | > sc4 |
|
390 | 390 | > sc5 |
|
391 | 391 | > sc6 |
|
392 | 392 | > EOF |
|
393 | 393 | $ git add copy-source |
|
394 | 394 | $ commit -m 'add copy-source' |
|
395 | 395 | $ cp copy-source source-copy0 |
|
396 | 396 | $ echo 0 >> source-copy0 |
|
397 | 397 | $ cp copy-source source-copy1 |
|
398 | 398 | $ echo 1 >> source-copy1 |
|
399 | 399 | $ git add source-copy0 source-copy1 |
|
400 | 400 | $ commit -a -m 'copy copy-source 2 times' |
|
401 | 401 | $ cd .. |
|
402 | 402 | |
|
403 | 403 | $ hg -q convert --config convert.git.renamelimit=1 \ |
|
404 | 404 | > --config convert.git.findcopiesharder=true --datesort git-repo2 fullrepo2 |
|
405 | 405 | $ hg -R fullrepo2 status -C --change master |
|
406 | 406 | A source-copy0 |
|
407 | 407 | A source-copy1 |
|
408 | 408 | |
|
409 | 409 | $ hg -q convert --config convert.git.renamelimit=100 \ |
|
410 | 410 | > --config convert.git.findcopiesharder=true --datesort git-repo2 fullrepo3 |
|
411 | 411 | $ hg -R fullrepo3 status -C --change master |
|
412 | 412 | A source-copy0 |
|
413 | 413 | copy-source |
|
414 | 414 | A source-copy1 |
|
415 | 415 | copy-source |
|
416 | 416 | |
|
417 | 417 | test binary conversion (issue1359) |
|
418 | 418 | |
|
419 | 419 | $ count=19 |
|
420 | 420 | $ mkdir git-repo3 |
|
421 | 421 | $ cd git-repo3 |
|
422 | 422 | $ git init-db >/dev/null 2>/dev/null |
|
423 |
$ $PYTHON -c ' |
|
|
423 | $ $PYTHON -c 'import struct; open("b", "wb").write(b"".join([struct.Struct(">B").pack(i) for i in range(256)])*16)' | |
|
424 | 424 | $ git add b |
|
425 | 425 | $ commit -a -m addbinary |
|
426 | 426 | $ cd .. |
|
427 | 427 | |
|
428 | 428 | convert binary file |
|
429 | 429 | |
|
430 | 430 | $ hg convert git-repo3 git-repo3-hg |
|
431 | 431 | initializing destination git-repo3-hg repository |
|
432 | 432 | scanning source... |
|
433 | 433 | sorting... |
|
434 | 434 | converting... |
|
435 | 435 | 0 addbinary |
|
436 | 436 | updating bookmarks |
|
437 | 437 | $ cd git-repo3-hg |
|
438 | 438 | $ hg up -C |
|
439 | 439 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
440 |
$ $PYTHON -c 'print len( |
|
|
440 | $ $PYTHON -c 'print len(open("b", "rb").read())' | |
|
441 | 441 | 4096 |
|
442 | 442 | $ cd .. |
|
443 | 443 | |
|
444 | 444 | test author vs committer |
|
445 | 445 | |
|
446 | 446 | $ mkdir git-repo4 |
|
447 | 447 | $ cd git-repo4 |
|
448 | 448 | $ git init-db >/dev/null 2>/dev/null |
|
449 | 449 | $ echo >> foo |
|
450 | 450 | $ git add foo |
|
451 | 451 | $ commit -a -m addfoo |
|
452 | 452 | $ echo >> foo |
|
453 | 453 | $ GIT_AUTHOR_NAME="nottest" |
|
454 | 454 | $ commit -a -m addfoo2 |
|
455 | 455 | $ cd .. |
|
456 | 456 | |
|
457 | 457 | convert author committer |
|
458 | 458 | |
|
459 | 459 | $ hg convert git-repo4 git-repo4-hg |
|
460 | 460 | initializing destination git-repo4-hg repository |
|
461 | 461 | scanning source... |
|
462 | 462 | sorting... |
|
463 | 463 | converting... |
|
464 | 464 | 1 addfoo |
|
465 | 465 | 0 addfoo2 |
|
466 | 466 | updating bookmarks |
|
467 | 467 | $ hg -R git-repo4-hg log -v |
|
468 | 468 | changeset: 1:d63e967f93da |
|
469 | 469 | bookmark: master |
|
470 | 470 | tag: tip |
|
471 | 471 | user: nottest <test@example.org> |
|
472 | 472 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
473 | 473 | files: foo |
|
474 | 474 | description: |
|
475 | 475 | addfoo2 |
|
476 | 476 | |
|
477 | 477 | committer: test <test@example.org> |
|
478 | 478 | |
|
479 | 479 | |
|
480 | 480 | changeset: 0:0735477b0224 |
|
481 | 481 | user: test <test@example.org> |
|
482 | 482 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
483 | 483 | files: foo |
|
484 | 484 | description: |
|
485 | 485 | addfoo |
|
486 | 486 | |
|
487 | 487 | |
|
488 | 488 | |
|
489 | 489 | Various combinations of committeractions fail |
|
490 | 490 | |
|
491 | 491 | $ hg --config convert.git.committeractions=messagedifferent,messagealways convert git-repo4 bad-committer |
|
492 | 492 | initializing destination bad-committer repository |
|
493 | 493 | abort: committeractions cannot define both messagedifferent and messagealways |
|
494 | 494 | [255] |
|
495 | 495 | |
|
496 | 496 | $ hg --config convert.git.committeractions=dropcommitter,replaceauthor convert git-repo4 bad-committer |
|
497 | 497 | initializing destination bad-committer repository |
|
498 | 498 | abort: committeractions cannot define both dropcommitter and replaceauthor |
|
499 | 499 | [255] |
|
500 | 500 | |
|
501 | 501 | $ hg --config convert.git.committeractions=dropcommitter,messagealways convert git-repo4 bad-committer |
|
502 | 502 | initializing destination bad-committer repository |
|
503 | 503 | abort: committeractions cannot define both dropcommitter and messagealways |
|
504 | 504 | [255] |
|
505 | 505 | |
|
506 | 506 | custom prefix on messagedifferent works |
|
507 | 507 | |
|
508 | 508 | $ hg --config convert.git.committeractions=messagedifferent=different: convert git-repo4 git-repo4-hg-messagedifferentprefix |
|
509 | 509 | initializing destination git-repo4-hg-messagedifferentprefix repository |
|
510 | 510 | scanning source... |
|
511 | 511 | sorting... |
|
512 | 512 | converting... |
|
513 | 513 | 1 addfoo |
|
514 | 514 | 0 addfoo2 |
|
515 | 515 | updating bookmarks |
|
516 | 516 | |
|
517 | 517 | $ hg -R git-repo4-hg-messagedifferentprefix log -v |
|
518 | 518 | changeset: 1:2fe0c98a109d |
|
519 | 519 | bookmark: master |
|
520 | 520 | tag: tip |
|
521 | 521 | user: nottest <test@example.org> |
|
522 | 522 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
523 | 523 | files: foo |
|
524 | 524 | description: |
|
525 | 525 | addfoo2 |
|
526 | 526 | |
|
527 | 527 | different: test <test@example.org> |
|
528 | 528 | |
|
529 | 529 | |
|
530 | 530 | changeset: 0:0735477b0224 |
|
531 | 531 | user: test <test@example.org> |
|
532 | 532 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
533 | 533 | files: foo |
|
534 | 534 | description: |
|
535 | 535 | addfoo |
|
536 | 536 | |
|
537 | 537 | |
|
538 | 538 | |
|
539 | 539 | messagealways will always add the "committer: " line even if committer identical |
|
540 | 540 | |
|
541 | 541 | $ hg --config convert.git.committeractions=messagealways convert git-repo4 git-repo4-hg-messagealways |
|
542 | 542 | initializing destination git-repo4-hg-messagealways repository |
|
543 | 543 | scanning source... |
|
544 | 544 | sorting... |
|
545 | 545 | converting... |
|
546 | 546 | 1 addfoo |
|
547 | 547 | 0 addfoo2 |
|
548 | 548 | updating bookmarks |
|
549 | 549 | |
|
550 | 550 | $ hg -R git-repo4-hg-messagealways log -v |
|
551 | 551 | changeset: 1:8db057d8cd37 |
|
552 | 552 | bookmark: master |
|
553 | 553 | tag: tip |
|
554 | 554 | user: nottest <test@example.org> |
|
555 | 555 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
556 | 556 | files: foo |
|
557 | 557 | description: |
|
558 | 558 | addfoo2 |
|
559 | 559 | |
|
560 | 560 | committer: test <test@example.org> |
|
561 | 561 | |
|
562 | 562 | |
|
563 | 563 | changeset: 0:8f71fe9c98be |
|
564 | 564 | user: test <test@example.org> |
|
565 | 565 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
566 | 566 | files: foo |
|
567 | 567 | description: |
|
568 | 568 | addfoo |
|
569 | 569 | |
|
570 | 570 | committer: test <test@example.org> |
|
571 | 571 | |
|
572 | 572 | |
|
573 | 573 | |
|
574 | 574 | custom prefix on messagealways works |
|
575 | 575 | |
|
576 | 576 | $ hg --config convert.git.committeractions=messagealways=always: convert git-repo4 git-repo4-hg-messagealwaysprefix |
|
577 | 577 | initializing destination git-repo4-hg-messagealwaysprefix repository |
|
578 | 578 | scanning source... |
|
579 | 579 | sorting... |
|
580 | 580 | converting... |
|
581 | 581 | 1 addfoo |
|
582 | 582 | 0 addfoo2 |
|
583 | 583 | updating bookmarks |
|
584 | 584 | |
|
585 | 585 | $ hg -R git-repo4-hg-messagealwaysprefix log -v |
|
586 | 586 | changeset: 1:83c17174de79 |
|
587 | 587 | bookmark: master |
|
588 | 588 | tag: tip |
|
589 | 589 | user: nottest <test@example.org> |
|
590 | 590 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
591 | 591 | files: foo |
|
592 | 592 | description: |
|
593 | 593 | addfoo2 |
|
594 | 594 | |
|
595 | 595 | always: test <test@example.org> |
|
596 | 596 | |
|
597 | 597 | |
|
598 | 598 | changeset: 0:2ac9bcb3534a |
|
599 | 599 | user: test <test@example.org> |
|
600 | 600 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
601 | 601 | files: foo |
|
602 | 602 | description: |
|
603 | 603 | addfoo |
|
604 | 604 | |
|
605 | 605 | always: test <test@example.org> |
|
606 | 606 | |
|
607 | 607 | |
|
608 | 608 | |
|
609 | 609 | replaceauthor replaces author with committer |
|
610 | 610 | |
|
611 | 611 | $ hg --config convert.git.committeractions=replaceauthor convert git-repo4 git-repo4-hg-replaceauthor |
|
612 | 612 | initializing destination git-repo4-hg-replaceauthor repository |
|
613 | 613 | scanning source... |
|
614 | 614 | sorting... |
|
615 | 615 | converting... |
|
616 | 616 | 1 addfoo |
|
617 | 617 | 0 addfoo2 |
|
618 | 618 | updating bookmarks |
|
619 | 619 | |
|
620 | 620 | $ hg -R git-repo4-hg-replaceauthor log -v |
|
621 | 621 | changeset: 1:122c1d8999ea |
|
622 | 622 | bookmark: master |
|
623 | 623 | tag: tip |
|
624 | 624 | user: test <test@example.org> |
|
625 | 625 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
626 | 626 | files: foo |
|
627 | 627 | description: |
|
628 | 628 | addfoo2 |
|
629 | 629 | |
|
630 | 630 | |
|
631 | 631 | changeset: 0:0735477b0224 |
|
632 | 632 | user: test <test@example.org> |
|
633 | 633 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
634 | 634 | files: foo |
|
635 | 635 | description: |
|
636 | 636 | addfoo |
|
637 | 637 | |
|
638 | 638 | |
|
639 | 639 | |
|
640 | 640 | dropcommitter removes the committer |
|
641 | 641 | |
|
642 | 642 | $ hg --config convert.git.committeractions=dropcommitter convert git-repo4 git-repo4-hg-dropcommitter |
|
643 | 643 | initializing destination git-repo4-hg-dropcommitter repository |
|
644 | 644 | scanning source... |
|
645 | 645 | sorting... |
|
646 | 646 | converting... |
|
647 | 647 | 1 addfoo |
|
648 | 648 | 0 addfoo2 |
|
649 | 649 | updating bookmarks |
|
650 | 650 | |
|
651 | 651 | $ hg -R git-repo4-hg-dropcommitter log -v |
|
652 | 652 | changeset: 1:190b2da396cc |
|
653 | 653 | bookmark: master |
|
654 | 654 | tag: tip |
|
655 | 655 | user: nottest <test@example.org> |
|
656 | 656 | date: Mon Jan 01 00:00:21 2007 +0000 |
|
657 | 657 | files: foo |
|
658 | 658 | description: |
|
659 | 659 | addfoo2 |
|
660 | 660 | |
|
661 | 661 | |
|
662 | 662 | changeset: 0:0735477b0224 |
|
663 | 663 | user: test <test@example.org> |
|
664 | 664 | date: Mon Jan 01 00:00:20 2007 +0000 |
|
665 | 665 | files: foo |
|
666 | 666 | description: |
|
667 | 667 | addfoo |
|
668 | 668 | |
|
669 | 669 | |
|
670 | 670 | |
|
671 | 671 | --sourceorder should fail |
|
672 | 672 | |
|
673 | 673 | $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg |
|
674 | 674 | initializing destination git-repo4-sourcesort-hg repository |
|
675 | 675 | abort: --sourcesort is not supported by this data source |
|
676 | 676 | [255] |
|
677 | 677 | |
|
678 | 678 | test converting certain branches |
|
679 | 679 | |
|
680 | 680 | $ mkdir git-testrevs |
|
681 | 681 | $ cd git-testrevs |
|
682 | 682 | $ git init |
|
683 | 683 | Initialized empty Git repository in $TESTTMP/git-testrevs/.git/ |
|
684 | 684 | $ echo a >> a ; git add a > /dev/null; git commit -m 'first' > /dev/null |
|
685 | 685 | $ echo a >> a ; git add a > /dev/null; git commit -m 'master commit' > /dev/null |
|
686 | 686 | $ git checkout -b goodbranch 'HEAD^' |
|
687 | 687 | Switched to a new branch 'goodbranch' |
|
688 | 688 | $ echo a >> b ; git add b > /dev/null; git commit -m 'good branch commit' > /dev/null |
|
689 | 689 | $ git checkout -b badbranch 'HEAD^' |
|
690 | 690 | Switched to a new branch 'badbranch' |
|
691 | 691 | $ echo a >> c ; git add c > /dev/null; git commit -m 'bad branch commit' > /dev/null |
|
692 | 692 | $ cd .. |
|
693 | 693 | $ hg convert git-testrevs hg-testrevs --rev master --rev goodbranch |
|
694 | 694 | initializing destination hg-testrevs repository |
|
695 | 695 | scanning source... |
|
696 | 696 | sorting... |
|
697 | 697 | converting... |
|
698 | 698 | 2 first |
|
699 | 699 | 1 good branch commit |
|
700 | 700 | 0 master commit |
|
701 | 701 | updating bookmarks |
|
702 | 702 | $ cd hg-testrevs |
|
703 | 703 | $ hg log -G -T '{rev} {bookmarks}' |
|
704 | 704 | o 2 master |
|
705 | 705 | | |
|
706 | 706 | | o 1 goodbranch |
|
707 | 707 | |/ |
|
708 | 708 | o 0 |
|
709 | 709 | |
|
710 | 710 | $ cd .. |
|
711 | 711 | |
|
712 | 712 | test sub modules |
|
713 | 713 | |
|
714 | 714 | $ mkdir git-repo5 |
|
715 | 715 | $ cd git-repo5 |
|
716 | 716 | $ git init-db >/dev/null 2>/dev/null |
|
717 | 717 | $ echo 'sub' >> foo |
|
718 | 718 | $ git add foo |
|
719 | 719 | $ commit -a -m 'addfoo' |
|
720 | 720 | $ BASE=`pwd` |
|
721 | 721 | $ cd .. |
|
722 | 722 | $ mkdir git-repo6 |
|
723 | 723 | $ cd git-repo6 |
|
724 | 724 | $ git init-db >/dev/null 2>/dev/null |
|
725 | 725 | $ git submodule add ${BASE} >/dev/null 2>/dev/null |
|
726 | 726 | $ commit -a -m 'addsubmodule' >/dev/null 2>/dev/null |
|
727 | 727 | |
|
728 | 728 | test non-tab whitespace .gitmodules |
|
729 | 729 | |
|
730 | 730 | $ cat >> .gitmodules <<EOF |
|
731 | 731 | > [submodule "git-repo5"] |
|
732 | 732 | > path = git-repo5 |
|
733 | 733 | > url = git-repo5 |
|
734 | 734 | > EOF |
|
735 | 735 | $ git commit -q -a -m "weird white space submodule" |
|
736 | 736 | $ cd .. |
|
737 | 737 | $ hg convert git-repo6 hg-repo6 |
|
738 | 738 | initializing destination hg-repo6 repository |
|
739 | 739 | scanning source... |
|
740 | 740 | sorting... |
|
741 | 741 | converting... |
|
742 | 742 | 1 addsubmodule |
|
743 | 743 | 0 weird white space submodule |
|
744 | 744 | updating bookmarks |
|
745 | 745 | |
|
746 | 746 | $ rm -rf hg-repo6 |
|
747 | 747 | $ cd git-repo6 |
|
748 | 748 | $ git reset --hard 'HEAD^' > /dev/null |
|
749 | 749 | |
|
750 | 750 | test missing .gitmodules |
|
751 | 751 | |
|
752 | 752 | $ git submodule add ../git-repo4 >/dev/null 2>/dev/null |
|
753 | 753 | $ git checkout HEAD .gitmodules |
|
754 | 754 | $ git rm .gitmodules |
|
755 | 755 | rm '.gitmodules' |
|
756 | 756 | $ git commit -q -m "remove .gitmodules" .gitmodules |
|
757 | 757 | $ git commit -q -m "missing .gitmodules" |
|
758 | 758 | $ cd .. |
|
759 | 759 | $ hg convert git-repo6 hg-repo6 --traceback 2>&1 | grep -v "fatal: Path '.gitmodules' does not exist" |
|
760 | 760 | initializing destination hg-repo6 repository |
|
761 | 761 | scanning source... |
|
762 | 762 | sorting... |
|
763 | 763 | converting... |
|
764 | 764 | 2 addsubmodule |
|
765 | 765 | 1 remove .gitmodules |
|
766 | 766 | 0 missing .gitmodules |
|
767 | 767 | warning: cannot read submodules config file in * (glob) |
|
768 | 768 | updating bookmarks |
|
769 | 769 | $ rm -rf hg-repo6 |
|
770 | 770 | $ cd git-repo6 |
|
771 | 771 | $ rm -rf git-repo4 |
|
772 | 772 | $ git reset --hard 'HEAD^^' > /dev/null |
|
773 | 773 | $ cd .. |
|
774 | 774 | |
|
775 | 775 | test invalid splicemap1 |
|
776 | 776 | |
|
777 | 777 | $ cat > splicemap <<EOF |
|
778 | 778 | > $VALIDID1 |
|
779 | 779 | > EOF |
|
780 | 780 | $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap1-hg |
|
781 | 781 | initializing destination git-repo2-splicemap1-hg repository |
|
782 | 782 | abort: syntax error in splicemap(1): child parent1[,parent2] expected |
|
783 | 783 | [255] |
|
784 | 784 | |
|
785 | 785 | test invalid splicemap2 |
|
786 | 786 | |
|
787 | 787 | $ cat > splicemap <<EOF |
|
788 | 788 | > $VALIDID1 $VALIDID2, $VALIDID2, $VALIDID2 |
|
789 | 789 | > EOF |
|
790 | 790 | $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap2-hg |
|
791 | 791 | initializing destination git-repo2-splicemap2-hg repository |
|
792 | 792 | abort: syntax error in splicemap(1): child parent1[,parent2] expected |
|
793 | 793 | [255] |
|
794 | 794 | |
|
795 | 795 | test invalid splicemap3 |
|
796 | 796 | |
|
797 | 797 | $ cat > splicemap <<EOF |
|
798 | 798 | > $INVALIDID1 $INVALIDID2 |
|
799 | 799 | > EOF |
|
800 | 800 | $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap3-hg |
|
801 | 801 | initializing destination git-repo2-splicemap3-hg repository |
|
802 | 802 | abort: splicemap entry afd12345af is not a valid revision identifier |
|
803 | 803 | [255] |
|
804 | 804 | |
|
805 | 805 | convert sub modules |
|
806 | 806 | $ hg convert git-repo6 git-repo6-hg |
|
807 | 807 | initializing destination git-repo6-hg repository |
|
808 | 808 | scanning source... |
|
809 | 809 | sorting... |
|
810 | 810 | converting... |
|
811 | 811 | 0 addsubmodule |
|
812 | 812 | updating bookmarks |
|
813 | 813 | $ hg -R git-repo6-hg log -v |
|
814 | 814 | changeset: 0:* (glob) |
|
815 | 815 | bookmark: master |
|
816 | 816 | tag: tip |
|
817 | 817 | user: nottest <test@example.org> |
|
818 | 818 | date: Mon Jan 01 00:00:23 2007 +0000 |
|
819 | 819 | files: .hgsub .hgsubstate |
|
820 | 820 | description: |
|
821 | 821 | addsubmodule |
|
822 | 822 | |
|
823 | 823 | committer: test <test@example.org> |
|
824 | 824 | |
|
825 | 825 | |
|
826 | 826 | |
|
827 | 827 | $ cd git-repo6-hg |
|
828 | 828 | $ hg up >/dev/null 2>/dev/null |
|
829 | 829 | $ cat .hgsubstate |
|
830 | 830 | * git-repo5 (glob) |
|
831 | 831 | $ cd git-repo5 |
|
832 | 832 | $ cat foo |
|
833 | 833 | sub |
|
834 | 834 | |
|
835 | 835 | $ cd ../.. |
|
836 | 836 | |
|
837 | 837 | make sure rename detection doesn't break removing and adding gitmodules |
|
838 | 838 | |
|
839 | 839 | $ cd git-repo6 |
|
840 | 840 | $ git mv .gitmodules .gitmodules-renamed |
|
841 | 841 | $ commit -a -m 'rename .gitmodules' |
|
842 | 842 | $ git mv .gitmodules-renamed .gitmodules |
|
843 | 843 | $ commit -a -m 'rename .gitmodules back' |
|
844 | 844 | $ cd .. |
|
845 | 845 | |
|
846 | 846 | $ hg --config convert.git.similarity=100 convert -q git-repo6 git-repo6-hg |
|
847 | 847 | $ hg -R git-repo6-hg log -r 'tip^' -T "{desc|firstline}\n" |
|
848 | 848 | rename .gitmodules |
|
849 | 849 | $ hg -R git-repo6-hg status -C --change 'tip^' |
|
850 | 850 | A .gitmodules-renamed |
|
851 | 851 | R .hgsub |
|
852 | 852 | R .hgsubstate |
|
853 | 853 | $ hg -R git-repo6-hg log -r tip -T "{desc|firstline}\n" |
|
854 | 854 | rename .gitmodules back |
|
855 | 855 | $ hg -R git-repo6-hg status -C --change tip |
|
856 | 856 | A .hgsub |
|
857 | 857 | A .hgsubstate |
|
858 | 858 | R .gitmodules-renamed |
|
859 | 859 | |
|
860 | 860 | convert the revision removing '.gitmodules' itself (and related |
|
861 | 861 | submodules) |
|
862 | 862 | |
|
863 | 863 | $ cd git-repo6 |
|
864 | 864 | $ git rm .gitmodules |
|
865 | 865 | rm '.gitmodules' |
|
866 | 866 | $ git rm --cached git-repo5 |
|
867 | 867 | rm 'git-repo5' |
|
868 | 868 | $ commit -a -m 'remove .gitmodules and submodule git-repo5' |
|
869 | 869 | $ cd .. |
|
870 | 870 | |
|
871 | 871 | $ hg convert -q git-repo6 git-repo6-hg |
|
872 | 872 | $ hg -R git-repo6-hg tip -T "{desc|firstline}\n" |
|
873 | 873 | remove .gitmodules and submodule git-repo5 |
|
874 | 874 | $ hg -R git-repo6-hg tip -T "{file_dels}\n" |
|
875 | 875 | .hgsub .hgsubstate |
|
876 | 876 | |
|
877 | 877 | skip submodules in the conversion |
|
878 | 878 | |
|
879 | 879 | $ hg convert -q git-repo6 no-submodules --config convert.git.skipsubmodules=True |
|
880 | 880 | $ hg -R no-submodules manifest --all |
|
881 | 881 | .gitmodules-renamed |
|
882 | 882 | |
|
883 | 883 | convert using a different remote prefix |
|
884 | 884 | $ git init git-repo7 |
|
885 | 885 | Initialized empty Git repository in $TESTTMP/git-repo7/.git/ |
|
886 | 886 | $ cd git-repo7 |
|
887 | 887 | TODO: it'd be nice to use (?) lines instead of grep -v to handle the |
|
888 | 888 | git output variance, but that doesn't currently work in the middle of |
|
889 | 889 | a block, so do this for now. |
|
890 | 890 | $ touch a && git add a && git commit -am "commit a" | grep -v changed |
|
891 | 891 | [master (root-commit) 8ae5f69] commit a |
|
892 | 892 | Author: nottest <test@example.org> |
|
893 | 893 | create mode 100644 a |
|
894 | 894 | $ cd .. |
|
895 | 895 | $ git clone git-repo7 git-repo7-client |
|
896 | 896 | Cloning into 'git-repo7-client'... |
|
897 | 897 | done. |
|
898 | 898 | $ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 |
|
899 | 899 | initializing destination hg-repo7 repository |
|
900 | 900 | scanning source... |
|
901 | 901 | sorting... |
|
902 | 902 | converting... |
|
903 | 903 | 0 commit a |
|
904 | 904 | updating bookmarks |
|
905 | 905 | $ hg -R hg-repo7 bookmarks |
|
906 | 906 | master 0:03bf38caa4c6 |
|
907 | 907 | origin/master 0:03bf38caa4c6 |
|
908 | 908 | |
|
909 | 909 | Run convert when the remote branches have changed |
|
910 | 910 | (there was an old bug where the local convert read branches from the server) |
|
911 | 911 | |
|
912 | 912 | $ cd git-repo7 |
|
913 | 913 | $ echo a >> a |
|
914 | 914 | $ git commit -q -am "move master forward" |
|
915 | 915 | $ cd .. |
|
916 | 916 | $ rm -rf hg-repo7 |
|
917 | 917 | $ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 |
|
918 | 918 | initializing destination hg-repo7 repository |
|
919 | 919 | scanning source... |
|
920 | 920 | sorting... |
|
921 | 921 | converting... |
|
922 | 922 | 0 commit a |
|
923 | 923 | updating bookmarks |
|
924 | 924 | $ hg -R hg-repo7 bookmarks |
|
925 | 925 | master 0:03bf38caa4c6 |
|
926 | 926 | origin/master 0:03bf38caa4c6 |
|
927 | 927 | |
|
928 | 928 | damaged git repository tests: |
|
929 | 929 | In case the hard-coded hashes change, the following commands can be used to |
|
930 | 930 | list the hashes and their corresponding types in the repository: |
|
931 | 931 | cd git-repo4/.git/objects |
|
932 | 932 | find . -type f | cut -c 3- | sed 's_/__' | xargs -n 1 -t git cat-file -t |
|
933 | 933 | cd ../../.. |
|
934 | 934 | |
|
935 | 935 | damage git repository by renaming a commit object |
|
936 | 936 | $ COMMIT_OBJ=1c/0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd |
|
937 | 937 | $ mv git-repo4/.git/objects/$COMMIT_OBJ git-repo4/.git/objects/$COMMIT_OBJ.tmp |
|
938 | 938 | $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
|
939 | 939 | abort: cannot retrieve number of commits in $TESTTMP/git-repo4/.git |
|
940 | 940 | $ mv git-repo4/.git/objects/$COMMIT_OBJ.tmp git-repo4/.git/objects/$COMMIT_OBJ |
|
941 | 941 | damage git repository by renaming a blob object |
|
942 | 942 | |
|
943 | 943 | $ BLOB_OBJ=8b/137891791fe96927ad78e64b0aad7bded08bdc |
|
944 | 944 | $ mv git-repo4/.git/objects/$BLOB_OBJ git-repo4/.git/objects/$BLOB_OBJ.tmp |
|
945 | 945 | $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
|
946 | 946 | abort: cannot read 'blob' object at 8b137891791fe96927ad78e64b0aad7bded08bdc |
|
947 | 947 | $ mv git-repo4/.git/objects/$BLOB_OBJ.tmp git-repo4/.git/objects/$BLOB_OBJ |
|
948 | 948 | damage git repository by renaming a tree object |
|
949 | 949 | |
|
950 | 950 | $ TREE_OBJ=72/49f083d2a63a41cc737764a86981eb5f3e4635 |
|
951 | 951 | $ mv git-repo4/.git/objects/$TREE_OBJ git-repo4/.git/objects/$TREE_OBJ.tmp |
|
952 | 952 | $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
|
953 | 953 | abort: cannot read changes in 1c0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd |
|
954 | 954 | |
|
955 | 955 | #if no-windows git19 |
|
956 | 956 | |
|
957 | 957 | test for escaping the repo name (CVE-2016-3069) |
|
958 | 958 | |
|
959 | 959 | $ git init '`echo pwned >COMMAND-INJECTION`' |
|
960 | 960 | Initialized empty Git repository in $TESTTMP/`echo pwned >COMMAND-INJECTION`/.git/ |
|
961 | 961 | $ cd '`echo pwned >COMMAND-INJECTION`' |
|
962 | 962 | $ git commit -q --allow-empty -m 'empty' |
|
963 | 963 | $ cd .. |
|
964 | 964 | $ hg convert '`echo pwned >COMMAND-INJECTION`' 'converted' |
|
965 | 965 | initializing destination converted repository |
|
966 | 966 | scanning source... |
|
967 | 967 | sorting... |
|
968 | 968 | converting... |
|
969 | 969 | 0 empty |
|
970 | 970 | updating bookmarks |
|
971 | 971 | $ test -f COMMAND-INJECTION |
|
972 | 972 | [1] |
|
973 | 973 | |
|
974 | 974 | test for safely passing paths to git (CVE-2016-3105) |
|
975 | 975 | |
|
976 | 976 | $ git init 'ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #' |
|
977 | 977 | Initialized empty Git repository in $TESTTMP/ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #/.git/ |
|
978 | 978 | $ cd 'ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #' |
|
979 | 979 | $ git commit -q --allow-empty -m 'empty' |
|
980 | 980 | $ cd .. |
|
981 | 981 | $ hg convert 'ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #' 'converted-git-ext' |
|
982 | 982 | initializing destination converted-git-ext repository |
|
983 | 983 | scanning source... |
|
984 | 984 | sorting... |
|
985 | 985 | converting... |
|
986 | 986 | 0 empty |
|
987 | 987 | updating bookmarks |
|
988 | 988 | $ test -f GIT-EXT-COMMAND-INJECTION |
|
989 | 989 | [1] |
|
990 | 990 | |
|
991 | 991 | #endif |
|
992 | 992 | |
|
993 | 993 | Conversion of extra commit metadata to extras works |
|
994 | 994 | |
|
995 | 995 | $ git init gitextras >/dev/null 2>/dev/null |
|
996 | 996 | $ cd gitextras |
|
997 | 997 | $ touch foo |
|
998 | 998 | $ git add foo |
|
999 | 999 | $ commit -m initial |
|
1000 | 1000 | $ echo 1 > foo |
|
1001 | 1001 | $ tree=`git write-tree` |
|
1002 | 1002 | |
|
1003 | 1003 | Git doesn't provider a user-facing API to write extra metadata into the |
|
1004 | 1004 | commit, so create the commit object by hand |
|
1005 | 1005 | |
|
1006 | 1006 | $ git hash-object -t commit -w --stdin << EOF |
|
1007 | 1007 | > tree ${tree} |
|
1008 | 1008 | > parent ba6b1344e977ece9e00958dbbf17f1f09384b2c1 |
|
1009 | 1009 | > author test <test@example.com> 1000000000 +0000 |
|
1010 | 1010 | > committer test <test@example.com> 1000000000 +0000 |
|
1011 | 1011 | > extra-1 extra-1 |
|
1012 | 1012 | > extra-2 extra-2 with space |
|
1013 | 1013 | > convert_revision 0000aaaabbbbccccddddeeee |
|
1014 | 1014 | > |
|
1015 | 1015 | > message with extras |
|
1016 | 1016 | > EOF |
|
1017 | 1017 | 8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
|
1018 | 1018 | |
|
1019 | 1019 | $ git reset --hard 8123727c8361a4117d1a2d80e0c4e7d70c757f18 > /dev/null |
|
1020 | 1020 | |
|
1021 | 1021 | $ cd .. |
|
1022 | 1022 | |
|
1023 | 1023 | convert will not retain custom metadata keys by default |
|
1024 | 1024 | |
|
1025 | 1025 | $ hg convert gitextras hgextras1 |
|
1026 | 1026 | initializing destination hgextras1 repository |
|
1027 | 1027 | scanning source... |
|
1028 | 1028 | sorting... |
|
1029 | 1029 | converting... |
|
1030 | 1030 | 1 initial |
|
1031 | 1031 | 0 message with extras |
|
1032 | 1032 | updating bookmarks |
|
1033 | 1033 | |
|
1034 | 1034 | $ hg -R hgextras1 log --debug -r 1 |
|
1035 | 1035 | changeset: 1:e13a39880f68479127b2a80fa0b448cc8524aa09 |
|
1036 | 1036 | bookmark: master |
|
1037 | 1037 | tag: tip |
|
1038 | 1038 | phase: draft |
|
1039 | 1039 | parent: 0:dcb68977c55cd02cbd13b901df65c4b6e7b9c4b9 |
|
1040 | 1040 | parent: -1:0000000000000000000000000000000000000000 |
|
1041 | 1041 | manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
|
1042 | 1042 | user: test <test@example.com> |
|
1043 | 1043 | date: Sun Sep 09 01:46:40 2001 +0000 |
|
1044 | 1044 | extra: branch=default |
|
1045 | 1045 | extra: convert_revision=8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
|
1046 | 1046 | description: |
|
1047 | 1047 | message with extras |
|
1048 | 1048 | |
|
1049 | 1049 | |
|
1050 | 1050 | |
|
1051 | 1051 | Attempting to convert a banned extra is disallowed |
|
1052 | 1052 | |
|
1053 | 1053 | $ hg convert --config convert.git.extrakeys=tree,parent gitextras hgextras-banned |
|
1054 | 1054 | initializing destination hgextras-banned repository |
|
1055 | 1055 | abort: copying of extra key is forbidden: parent, tree |
|
1056 | 1056 | [255] |
|
1057 | 1057 | |
|
1058 | 1058 | Converting a specific extra works |
|
1059 | 1059 | |
|
1060 | 1060 | $ hg convert --config convert.git.extrakeys=extra-1 gitextras hgextras2 |
|
1061 | 1061 | initializing destination hgextras2 repository |
|
1062 | 1062 | scanning source... |
|
1063 | 1063 | sorting... |
|
1064 | 1064 | converting... |
|
1065 | 1065 | 1 initial |
|
1066 | 1066 | 0 message with extras |
|
1067 | 1067 | updating bookmarks |
|
1068 | 1068 | |
|
1069 | 1069 | $ hg -R hgextras2 log --debug -r 1 |
|
1070 | 1070 | changeset: 1:d40fb205d58597e6ecfd55b16f198be5bf436391 |
|
1071 | 1071 | bookmark: master |
|
1072 | 1072 | tag: tip |
|
1073 | 1073 | phase: draft |
|
1074 | 1074 | parent: 0:dcb68977c55cd02cbd13b901df65c4b6e7b9c4b9 |
|
1075 | 1075 | parent: -1:0000000000000000000000000000000000000000 |
|
1076 | 1076 | manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
|
1077 | 1077 | user: test <test@example.com> |
|
1078 | 1078 | date: Sun Sep 09 01:46:40 2001 +0000 |
|
1079 | 1079 | extra: branch=default |
|
1080 | 1080 | extra: convert_revision=8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
|
1081 | 1081 | extra: extra-1=extra-1 |
|
1082 | 1082 | description: |
|
1083 | 1083 | message with extras |
|
1084 | 1084 | |
|
1085 | 1085 | |
|
1086 | 1086 | |
|
1087 | 1087 | Converting multiple extras works |
|
1088 | 1088 | |
|
1089 | 1089 | $ hg convert --config convert.git.extrakeys=extra-1,extra-2 gitextras hgextras3 |
|
1090 | 1090 | initializing destination hgextras3 repository |
|
1091 | 1091 | scanning source... |
|
1092 | 1092 | sorting... |
|
1093 | 1093 | converting... |
|
1094 | 1094 | 1 initial |
|
1095 | 1095 | 0 message with extras |
|
1096 | 1096 | updating bookmarks |
|
1097 | 1097 | |
|
1098 | 1098 | $ hg -R hgextras3 log --debug -r 1 |
|
1099 | 1099 | changeset: 1:0105af33379e7b6491501fd34141b7af700fe125 |
|
1100 | 1100 | bookmark: master |
|
1101 | 1101 | tag: tip |
|
1102 | 1102 | phase: draft |
|
1103 | 1103 | parent: 0:dcb68977c55cd02cbd13b901df65c4b6e7b9c4b9 |
|
1104 | 1104 | parent: -1:0000000000000000000000000000000000000000 |
|
1105 | 1105 | manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
|
1106 | 1106 | user: test <test@example.com> |
|
1107 | 1107 | date: Sun Sep 09 01:46:40 2001 +0000 |
|
1108 | 1108 | extra: branch=default |
|
1109 | 1109 | extra: convert_revision=8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
|
1110 | 1110 | extra: extra-1=extra-1 |
|
1111 | 1111 | extra: extra-2=extra-2 with space |
|
1112 | 1112 | description: |
|
1113 | 1113 | message with extras |
|
1114 | 1114 | |
|
1115 | 1115 | |
|
1116 | 1116 | |
|
1117 | 1117 | convert.git.saverev can be disabled to prevent convert_revision from being written |
|
1118 | 1118 | |
|
1119 | 1119 | $ hg convert --config convert.git.saverev=false gitextras hgextras4 |
|
1120 | 1120 | initializing destination hgextras4 repository |
|
1121 | 1121 | scanning source... |
|
1122 | 1122 | sorting... |
|
1123 | 1123 | converting... |
|
1124 | 1124 | 1 initial |
|
1125 | 1125 | 0 message with extras |
|
1126 | 1126 | updating bookmarks |
|
1127 | 1127 | |
|
1128 | 1128 | $ hg -R hgextras4 log --debug -r 1 |
|
1129 | 1129 | changeset: 1:1dcaf4ffe5bee43fa86db2800821f6f0af212c5c |
|
1130 | 1130 | bookmark: master |
|
1131 | 1131 | tag: tip |
|
1132 | 1132 | phase: draft |
|
1133 | 1133 | parent: 0:a13935fec4daf06a5a87a7307ccb0fc94f98d06d |
|
1134 | 1134 | parent: -1:0000000000000000000000000000000000000000 |
|
1135 | 1135 | manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
|
1136 | 1136 | user: test <test@example.com> |
|
1137 | 1137 | date: Sun Sep 09 01:46:40 2001 +0000 |
|
1138 | 1138 | extra: branch=default |
|
1139 | 1139 | description: |
|
1140 | 1140 | message with extras |
|
1141 | 1141 | |
|
1142 | 1142 | |
|
1143 | 1143 | |
|
1144 | 1144 | convert.git.saverev and convert.git.extrakeys can be combined to preserve |
|
1145 | 1145 | convert_revision from source |
|
1146 | 1146 | |
|
1147 | 1147 | $ hg convert --config convert.git.saverev=false --config convert.git.extrakeys=convert_revision gitextras hgextras5 |
|
1148 | 1148 | initializing destination hgextras5 repository |
|
1149 | 1149 | scanning source... |
|
1150 | 1150 | sorting... |
|
1151 | 1151 | converting... |
|
1152 | 1152 | 1 initial |
|
1153 | 1153 | 0 message with extras |
|
1154 | 1154 | updating bookmarks |
|
1155 | 1155 | |
|
1156 | 1156 | $ hg -R hgextras5 log --debug -r 1 |
|
1157 | 1157 | changeset: 1:574d85931544d4542007664fee3747360e85ee28 |
|
1158 | 1158 | bookmark: master |
|
1159 | 1159 | tag: tip |
|
1160 | 1160 | phase: draft |
|
1161 | 1161 | parent: 0:a13935fec4daf06a5a87a7307ccb0fc94f98d06d |
|
1162 | 1162 | parent: -1:0000000000000000000000000000000000000000 |
|
1163 | 1163 | manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
|
1164 | 1164 | user: test <test@example.com> |
|
1165 | 1165 | date: Sun Sep 09 01:46:40 2001 +0000 |
|
1166 | 1166 | extra: branch=default |
|
1167 | 1167 | extra: convert_revision=0000aaaabbbbccccddddeeee |
|
1168 | 1168 | description: |
|
1169 | 1169 | message with extras |
|
1170 | 1170 | |
|
1171 | 1171 |
General Comments 0
You need to be logged in to leave comments.
Login now