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