##// END OF EJS Templates
py3: fix bytes/unicode issues in convert/darcs...
Ian Moody -
r50266:6833ccc5 stable
parent child Browse files
Show More
@@ -42,7 +42,7 b' class darcs_source(common.converter_sour'
42 42 _(b'darcs version 2.1 or newer needed (found %r)') % version
43 43 )
44 44
45 if b"ElementTree" not in globals():
45 if "ElementTree" not in globals():
46 46 raise error.Abort(_(b"Python ElementTree module is not available"))
47 47
48 48 self.path = os.path.realpath(path)
@@ -78,9 +78,9 b' class darcs_source(common.converter_sour'
78 78 )
79 79 tagname = None
80 80 child = None
81 for elt in tree.findall(b'patch'):
82 node = elt.get(b'hash')
83 name = elt.findtext(b'name', b'')
81 for elt in tree.findall('patch'):
82 node = self.recode(elt.get('hash'))
83 name = self.recode(elt.findtext('name', ''))
84 84 if name.startswith(b'TAG '):
85 85 tagname = name[4:].strip()
86 86 elif tagname is not None:
@@ -110,7 +110,7 b' class darcs_source(common.converter_sour'
110 110 # While we are decoding the XML as latin-1 to be as liberal as
111 111 # possible, etree will still raise an exception if any
112 112 # non-printable characters are in the XML changelog.
113 parser = XMLParser(encoding=b'latin-1')
113 parser = XMLParser(encoding='latin-1')
114 114 p = self._run(cmd, **kwargs)
115 115 etree.parse(p.stdout, parser=parser)
116 116 p.wait()
@@ -120,7 +120,7 b' class darcs_source(common.converter_sour'
120 120 def format(self):
121 121 output, status = self.run(b'show', b'repo', repodir=self.path)
122 122 self.checkexit(status)
123 m = re.search(r'^\s*Format:\s*(.*)$', output, re.MULTILINE)
123 m = re.search(br'^\s*Format:\s*(.*)$', output, re.MULTILINE)
124 124 if not m:
125 125 return None
126 126 return b','.join(sorted(f.strip() for f in m.group(1).split(b',')))
@@ -143,13 +143,13 b' class darcs_source(common.converter_sour'
143 143 def getcommit(self, rev):
144 144 elt = self.changes[rev]
145 145 dateformat = b'%a %b %d %H:%M:%S %Z %Y'
146 date = dateutil.strdate(elt.get(b'local_date'), dateformat)
147 desc = elt.findtext(b'name') + b'\n' + elt.findtext(b'comment', b'')
146 date = dateutil.strdate(elt.get('local_date'), dateformat)
147 desc = elt.findtext('name') + '\n' + elt.findtext('comment', '')
148 148 # etree can return unicode objects for name, comment, and author,
149 149 # so recode() is used to ensure str objects are emitted.
150 150 newdateformat = b'%Y-%m-%d %H:%M:%S %1%2'
151 151 return common.commit(
152 author=self.recode(elt.get(b'author')),
152 author=self.recode(elt.get('author')),
153 153 date=dateutil.datestr(date, newdateformat),
154 154 desc=self.recode(desc).strip(),
155 155 parents=self.parents[rev],
@@ -160,7 +160,7 b' class darcs_source(common.converter_sour'
160 160 b'pull',
161 161 self.path,
162 162 all=True,
163 match=b'hash %s' % rev,
163 match=b'hash %s' % self.recode(rev),
164 164 no_test=True,
165 165 no_posthook=True,
166 166 external_merge=b'/bin/false',
@@ -178,13 +178,14 b' class darcs_source(common.converter_sour'
178 178 copies = {}
179 179 changes = []
180 180 man = None
181 for elt in self.changes[rev].find(b'summary').getchildren():
182 if elt.tag in (b'add_directory', b'remove_directory'):
181 for elt in self.changes[rev].find('summary').getchildren():
182 if elt.tag in ('add_directory', 'remove_directory'):
183 183 continue
184 if elt.tag == b'move':
184 if elt.tag == 'move':
185 185 if man is None:
186 186 man = self.manifest()
187 source, dest = elt.get(b'from'), elt.get(b'to')
187 source = self.recode(elt.get('from'))
188 dest = self.recode(elt.get('to'))
188 189 if source in man:
189 190 # File move
190 191 changes.append((source, rev))
@@ -201,7 +202,7 b' class darcs_source(common.converter_sour'
201 202 changes.append((fdest, rev))
202 203 copies[fdest] = f
203 204 else:
204 changes.append((elt.text.strip(), rev))
205 changes.append((self.recode(elt.text.strip()), rev))
205 206 self.pull(rev)
206 207 self.lastrev = rev
207 208 return sorted(changes), copies, set()
General Comments 0
You need to be logged in to leave comments. Login now