Show More
@@ -21,8 +21,20 b'' | |||
|
21 | 21 | # interrupted and can be run repeatedly to copy new commits. |
|
22 | 22 | |
|
23 | 23 | import sys, os, zlib, sha, time |
|
24 | ||
|
25 | os.environ["HGENCODING"] = "utf-8" | |
|
26 | ||
|
24 | 27 | from mercurial import hg, ui, util |
|
25 | 28 | |
|
29 | def recode(s): | |
|
30 | try: | |
|
31 | return s.decode("utf-8").encode("utf-8") | |
|
32 | except: | |
|
33 | try: | |
|
34 | return s.decode("latin-1").encode("utf-8") | |
|
35 | except: | |
|
36 | return s.decode("utf-8", "replace").encode("utf-8") | |
|
37 | ||
|
26 | 38 | class convert_git: |
|
27 | 39 | def __init__(self, path): |
|
28 | 40 | self.path = path |
@@ -55,6 +67,7 b' class convert_git:' | |||
|
55 | 67 | c = self.catfile(version, "commit") # read the commit hash |
|
56 | 68 | end = c.find("\n\n") |
|
57 | 69 | message = c[end+2:] |
|
70 | message = recode(message) | |
|
58 | 71 | l = c[:end].splitlines() |
|
59 | 72 | manifest = l[0].split()[1] |
|
60 | 73 | parents = [] |
@@ -65,11 +78,13 b' class convert_git:' | |||
|
65 | 78 | tm, tz = p[-2:] |
|
66 | 79 | author = " ".join(p[:-2]) |
|
67 | 80 | if author[0] == "<": author = author[1:-1] |
|
81 | author = recode(author) | |
|
68 | 82 | if n == "committer": |
|
69 | 83 | p = v.split() |
|
70 | 84 | tm, tz = p[-2:] |
|
71 | 85 | committer = " ".join(p[:-2]) |
|
72 | 86 | if committer[0] == "<": committer = committer[1:-1] |
|
87 | committer = recode(committer) | |
|
73 | 88 | message += "\ncommitter: %s\n" % v |
|
74 | 89 | if n == "parent": parents.append(v) |
|
75 | 90 |
General Comments 0
You need to be logged in to leave comments.
Login now