comparison tests/test-convert-git.t @ 25997:d4e1e947444b stable

convert: fix git copy file content conversions There was a bug in the git convert code where if you copied a file and modified the copy source in the same commit, and if the copy dest was alphabetically earlier than the copy source, the converted version would use the copy dest contents for both the source and the target. The root of the bug is that the git diff-tree output is formatted like so: :<mode> <mode> <oldhash> <newhash> <state> <src> <dest> :100644 100644 c1ab79a15... 3dfc779ab... C069 oldname newname :100644 100644 c1ab79a15... 03e2188a6... M oldname The old code would always take the 'oldname' field as the name of the file being processed, then it would try to do an extra convert for the newname. This works for renames because it does a delete for the oldname and a create for the newname. For copies though, it ends up associating the copied content (3dfc779ab above) with the oldname. It only happened when the dest was alphabetically before because that meant the copy got processed before the modification. The fix is the treat copy lines as affecting only the newname, and not marking the oldname as processed.
author Durham Goode <durham@fb.com>
date Thu, 06 Aug 2015 17:21:46 -0700
parents d9133e89d39d
children a7527c5769bb 97208371715a
comparison
equal deleted inserted replaced
25996:b12e00a05d57 25997:d4e1e947444b
319 $ git mv foo foo-renamed 319 $ git mv foo foo-renamed
320 since bar is not touched in this commit, this copy will not be detected 320 since bar is not touched in this commit, this copy will not be detected
321 $ cp bar bar-copied 321 $ cp bar bar-copied
322 $ cp baz baz-copied 322 $ cp baz baz-copied
323 $ cp baz baz-copied2 323 $ cp baz baz-copied2
324 $ cp baz ba-copy
324 $ echo baz2 >> baz 325 $ echo baz2 >> baz
325 $ git add bar-copied baz-copied baz-copied2 326 $ git add bar-copied baz-copied baz-copied2 ba-copy
326 $ commit -a -m 'rename and copy' 327 $ commit -a -m 'rename and copy'
327 $ cd .. 328 $ cd ..
328 329
329 input validation 330 input validation
330 $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo 331 $ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo
338 [255] 339 [255]
339 340
340 $ hg -q convert --config convert.git.similarity=100 --datesort git-repo2 fullrepo 341 $ hg -q convert --config convert.git.similarity=100 --datesort git-repo2 fullrepo
341 $ hg -R fullrepo status -C --change master 342 $ hg -R fullrepo status -C --change master
342 M baz 343 M baz
344 A ba-copy
345 baz
343 A bar-copied 346 A bar-copied
344 A baz-copied 347 A baz-copied
345 baz 348 baz
346 A baz-copied2 349 A baz-copied2
347 baz 350 baz
348 A foo-renamed 351 A foo-renamed
349 foo 352 foo
350 R foo 353 R foo
354
355 Ensure that the modification to the copy source was preserved
356 (there was a bug where if the copy dest was alphabetically prior to the copy
357 source, the copy source took the contents of the copy dest)
358 $ hg cat -r tip fullrepo/baz
359 baz
360 baz2
351 361
352 $ cd git-repo2 362 $ cd git-repo2
353 $ echo bar2 >> bar 363 $ echo bar2 >> bar
354 $ commit -a -m 'change bar' 364 $ commit -a -m 'change bar'
355 $ cp bar bar-copied2 365 $ cp bar bar-copied2