convert/gnuarch: fix switched copy source and destination
authorPatrick Mezard <pmezard@gmail.com>
Mon, 05 Jan 2009 14:34:20 +0100
changeset 7567 0946294d1f32
parent 7566 5f7e3f17aece
child 7568 12df451ce205
child 7603 d702a702259f
convert/gnuarch: fix switched copy source and destination Reported by Edouard Gomez <ed.gomez@free.fr>
hgext/convert/gnuarch.py
tests/test-convert-baz
tests/test-convert-baz.out
tests/test-convert-tla.out
--- a/hgext/convert/gnuarch.py	Sun Jan 04 21:32:40 2009 +0100
+++ b/hgext/convert/gnuarch.py	Mon Jan 05 14:34:20 2009 +0100
@@ -121,17 +121,16 @@
             to = self.changes[rev].ren_files[src]
             changes.append((src, rev))
             changes.append((to, rev))
-            copies[src] = to
+            copies[to] = src
 
         for src in self.changes[rev].ren_dirs:
             to = self.changes[rev].ren_dirs[src]
             chgs, cps = self._rendirchanges(src, to);
             changes += [(f, rev) for f in chgs]
-            for c in cps:
-                copies[c] = cps[c]
+            copies.update(cps)
 
         self.lastrev = rev
-        return util.sort(changes), copies
+        return util.sort(util.unique(changes)), copies
 
     def getcommit(self, rev):
         changes = self.changes[rev]
@@ -213,7 +212,7 @@
             d = os.path.join(dest, f)
             changes.append(s)
             changes.append(d)
-            copies[s] = d
+            copies[d] = s
         return changes, copies
 
     def _obtainrevision(self, rev):
--- a/tests/test-convert-baz	Sun Jan 04 21:32:40 2009 +0100
+++ b/tests/test-convert-baz	Mon Jan 05 14:34:20 2009 +0100
@@ -55,6 +55,14 @@
 baz mv src test
 baz commit -s "move and rename a-link-2 file and src directory"
 
+echo % move and add the moved file again
+echo e > e
+baz add e
+baz commit -s "add e"
+baz mv e f
+echo ee > e
+baz add e
+baz commit -s "move e and recreate it again"
 cd ..
 
 echo % converting baz repo to Mercurial
@@ -71,3 +79,4 @@
 glog -R baz-repo-hg
 hg up -q -R baz-repo-hg
 hg -R baz-repo-hg manifest --debug
+hg -R baz-repo-hg log -r 5 -r 7 -C --debug | grep copies
--- a/tests/test-convert-baz.out	Sun Jan 04 21:32:40 2009 +0100
+++ b/tests/test-convert-baz.out	Mon Jan 05 14:34:20 2009 +0100
@@ -44,19 +44,36 @@
 => src/.arch-ids/b.id	test/.arch-ids/b.id
 * update pristine tree (baz@mercurial--convert/baz--test--0--patch-4 => baz--test--0--patch-5)
 * committed baz@mercurial--convert/baz--test--0--patch-5
+% move and add the moved file again
+A  .arch-ids/e.id
+A  e
+* update pristine tree (baz@mercurial--convert/baz--test--0--patch-5 => baz--test--0--patch-6)
+* committed baz@mercurial--convert/baz--test--0--patch-6
+A  .arch-ids/e.id
+A  e
+=> .arch-ids/e.id	.arch-ids/f.id
+=> e	f
+* update pristine tree (baz@mercurial--convert/baz--test--0--patch-6 => baz--test--0--patch-7)
+* committed baz@mercurial--convert/baz--test--0--patch-7
 % converting baz repo to Mercurial
 initializing destination baz-repo-hg repository
 analyzing tree version baz@mercurial--convert/baz--test--0...
 scanning source...
 sorting...
 converting...
-5 initial import
-4 added a file, src and src/b (binary)
-3 added link to a and modify a
-2 added second link and modify b
-1 file to link and link to file test
-0 move and rename a-link-2 file and src directory
+7 initial import
+6 added a file, src and src/b (binary)
+5 added link to a and modify a
+4 added second link and modify b
+3 file to link and link to file test
+2 move and rename a-link-2 file and src directory
+1 add e
+0 move e and recreate it again
 % show graph log
+o  7 "move e and recreate it again" files: e f
+|
+o  6 "add e" files: e
+|
 o  5 "move and rename a-link-2 file and src directory" files: c src/a-link src/a-link-2 src/b test/a-link test/b
 |
 o  4 "file to link and link to file test" files: src/a-link-2 src/b
@@ -70,6 +87,10 @@
 o  0 "initial import" files:
 
 c4072c4b72e1cabace081888efa148ee80ca3cbb 644   a
-e3207be798aaf87a444a62903621edab4ddc1fb6 644   c
-1f6b5bb93f1da278ef1fead1e4740a03d8802e9f 644 @ test/a-link
-1f6b5bb93f1da278ef1fead1e4740a03d8802e9f 644 @ test/b
+623942606de842342ac7b221ae9ccabc13b5d8c8 644   c
+1a4a864db0073705a11b1439f563bfa4b46d9246 644   e
+ab9089704d7c988687521e6adf018ebf767da7d6 644   f
+43b4308708a4b36340566684df2e2a074b12ceb0 644 @ test/a-link
+73773e3389ef7ec5a070519b74895d2eaa4ad5db 644 @ test/b
+copies:      c (src/a-link-2) test/a-link (src/a-link) test/b (src/b)
+copies:      f (e)
--- a/tests/test-convert-tla.out	Sun Jan 04 21:32:40 2009 +0100
+++ b/tests/test-convert-tla.out	Mon Jan 05 14:34:20 2009 +0100
@@ -67,6 +67,6 @@
 o  0 "initial import" files:
 
 c4072c4b72e1cabace081888efa148ee80ca3cbb 644   a
-e3207be798aaf87a444a62903621edab4ddc1fb6 644   c
-1f6b5bb93f1da278ef1fead1e4740a03d8802e9f 644 @ test/a-link
-1f6b5bb93f1da278ef1fead1e4740a03d8802e9f 644 @ test/b
+623942606de842342ac7b221ae9ccabc13b5d8c8 644   c
+43b4308708a4b36340566684df2e2a074b12ceb0 644 @ test/a-link
+73773e3389ef7ec5a070519b74895d2eaa4ad5db 644 @ test/b