merge with main
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 08 Dec 2006 07:48:47 +0100
changeset 3828 ed5a9b27bedc
parent 3827 3674ca805a5b (current diff)
parent 3821 158fce02dc40 (diff)
child 3830 4e488ccc8120
child 3831 2db191165e9a
merge with main
--- a/contrib/convert-repo	Fri Dec 08 01:36:50 2006 -0200
+++ b/contrib/convert-repo	Fri Dec 08 07:48:47 2006 +0100
@@ -21,8 +21,20 @@
 # interrupted and can be run repeatedly to copy new commits.
 
 import sys, os, zlib, sha, time
+
+os.environ["HGENCODING"] = "utf-8"
+
 from mercurial import hg, ui, util
 
+def recode(s):
+    try:
+        return s.decode("utf-8").encode("utf-8")
+    except:
+        try:
+            return s.decode("latin-1").encode("utf-8")
+        except:
+            return s.decode("utf-8", "replace").encode("utf-8")
+
 class convert_git:
     def __init__(self, path):
         self.path = path
@@ -55,6 +67,7 @@
         c = self.catfile(version, "commit") # read the commit hash
         end = c.find("\n\n")
         message = c[end+2:]
+        message = recode(message)
         l = c[:end].splitlines()
         manifest = l[0].split()[1]
         parents = []
@@ -65,11 +78,13 @@
                 tm, tz = p[-2:]
                 author = " ".join(p[:-2])
                 if author[0] == "<": author = author[1:-1]
+                author = recode(author)
             if n == "committer":
                 p = v.split()
                 tm, tz = p[-2:]
                 committer = " ".join(p[:-2])
                 if committer[0] == "<": committer = committer[1:-1]
+                committer = recode(committer)
                 message += "\ncommitter: %s\n" % v
             if n == "parent": parents.append(v)