convert/svn: remove useless encoding/decoding calls (issue1676)
authorPatrick Mezard <pmezard@gmail.com>
Sun, 21 Jun 2009 23:04:02 +0200
changeset 8882 48a04961b0dd
parent 8881 76d3cd914c5e
child 8883 ede2247e61aa
convert/svn: remove useless encoding/decoding calls (issue1676)
hgext/convert/subversion.py
tests/svn/encoding.svndump
tests/svn/svndump-encoding.sh
tests/test-convert-svn-encoding
tests/test-convert-svn-encoding.out
--- a/hgext/convert/subversion.py	Sun Jun 21 23:04:01 2009 +0200
+++ b/hgext/convert/subversion.py	Sun Jun 21 23:04:02 2009 +0200
@@ -744,8 +744,7 @@
                 pmodule, prevnum = self.revsplit(parents[0])[1:]
                 if ent.copyfrom_rev < prevnum:
                     continue
-                copyfrompath = ent.copyfrom_path.decode(self.encoding)
-                copyfrompath = self.getrelpath(copyfrompath, pmodule)
+                copyfrompath = self.getrelpath(ent.copyfrom_path, pmodule)
                 if not copyfrompath:
                     continue
                 copyfrom[path] = ent
@@ -757,10 +756,9 @@
                     entrypath = self.getrelpath("/" + child, pmodule)
                     if not entrypath:
                         continue
-                    entry = entrypath.decode(self.encoding)
-                    copytopath = path + entry[len(copyfrompath):]
+                    copytopath = path + entrypath[len(copyfrompath):]
                     copytopath = self.getrelpath(copytopath)
-                    copies[self.recode(copytopath)] = self.recode(entry, pmodule)
+                    copies[self.recode(copytopath)] = self.recode(entrypath)
 
         return (list(set(entries)), copies)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/svn/encoding.svndump	Sun Jun 21 23:04:02 2009 +0200
@@ -0,0 +1,180 @@
+SVN-fs-dump-format-version: 2
+
+UUID: 64cf20ed-79ff-4f10-8aaf-041d1993b42e
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2009-06-21T10:05:28.031033Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 112
+Content-length: 112
+
+K 7
+svn:log
+V 10
+init projA
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2009-06-21T10:05:28.108227Z
+PROPS-END
+
+Node-path: branches
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: tags
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: trunk
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Revision-number: 2
+Prop-content-length: 106
+Content-length: 106
+
+K 7
+svn:log
+V 5
+hello
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2009-06-21T10:05:29.109026Z
+PROPS-END
+
+Node-path: trunk/à
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: trunk/à/é
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: e29311f6f1bf1af907f9ef9f44b8328b
+Text-content-sha1: e983f374794de9c64e3d1c1de1d490c0756eeeff
+Content-length: 12
+
+PROPS-END
+d
+
+
+Node-path: trunk/é
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 9ffbf43126e33be52cd2bf7e01d627f9
+Text-content-sha1: 094e3afb2fe8dfe82f63731cdcd3b999f4856cff
+Content-length: 12
+
+PROPS-END
+e
+
+
+Revision-number: 3
+Prop-content-length: 112
+Content-length: 112
+
+K 7
+svn:log
+V 10
+copy files
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2009-06-21T10:05:32.061964Z
+PROPS-END
+
+Node-path: trunk/è
+Node-kind: file
+Node-action: add
+Node-copyfrom-rev: 2
+Node-copyfrom-path: trunk/é
+Text-copy-source-md5: 9ffbf43126e33be52cd2bf7e01d627f9
+Text-copy-source-sha1: 094e3afb2fe8dfe82f63731cdcd3b999f4856cff
+
+
+Node-path: trunk/ù
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 2
+Node-copyfrom-path: trunk/à
+
+
+Node-path: trunk/à
+Node-action: delete
+
+
+Node-path: trunk/é
+Node-action: delete
+
+
+Revision-number: 4
+Prop-content-length: 114
+Content-length: 114
+
+K 7
+svn:log
+V 12
+remove files
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2009-06-21T10:05:33.096353Z
+PROPS-END
+
+Node-path: trunk/è
+Node-action: delete
+
+
+Node-path: trunk/ù
+Node-action: delete
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/svn/svndump-encoding.sh	Sun Jun 21 23:04:02 2009 +0200
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+#!/bin/sh
+#
+# Use this script to generate encoding.svndump
+#
+
+mkdir temp
+cd temp
+
+mkdir project-orig
+cd project-orig
+mkdir trunk
+mkdir branches
+mkdir tags
+cd ..
+
+svnadmin create svn-repo
+svnurl=file://`pwd`/svn-repo
+svn import project-orig $svnurl -m "init projA"
+
+svn co $svnurl project
+cd project
+echo e > trunk/é
+mkdir trunk/à
+echo d > trunk/à/é
+svn add trunk/é trunk/à
+svn ci -m hello
+
+# Copy files and directories
+svn mv trunk/é trunk/è
+svn mv trunk/à trunk/ù
+svn ci -m "copy files"
+
+# Remove files
+svn rm trunk/è
+svn rm trunk/ù
+svn ci -m 'remove files'
+cd ..
+
+svnadmin dump svn-repo > ../encoding.svndump
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-svn-encoding	Sun Jun 21 23:04:02 2009 +0200
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+"$TESTDIR/hghave" svn svn-bindings || exit 80
+
+echo "[extensions]" >> $HGRCPATH
+echo "convert = " >> $HGRCPATH
+
+svnadmin create svn-repo
+cat "$TESTDIR/svn/encoding.svndump" | svnadmin load svn-repo > /dev/null
+
+echo '% convert while testing all possible outputs'
+hg --debug convert svn-repo A-hg > /dev/null
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-convert-svn-encoding.out	Sun Jun 21 23:04:02 2009 +0200
@@ -0,0 +1,1 @@
+% convert while testing all possible outputs