##// END OF EJS Templates
convert/bzr: expect unicode metadata, encode in UTF-8 (issue3232)...
Patrick Mezard -
r16059:f5b6046f default
parent child Browse files
Show More
@@ -143,7 +143,6 b' class bzr_source(converter_source):'
143 143 return commit(parents=parents,
144 144 date='%d %d' % (rev.timestamp, -rev.timezone),
145 145 author=self.recode(rev.committer),
146 # bzr returns bytestrings or unicode, depending on the content
147 146 desc=self.recode(rev.message),
148 147 rev=version)
149 148
@@ -231,7 +230,11 b' class bzr_source(converter_source):'
231 230 continue
232 231
233 232 # we got unicode paths, need to convert them
234 path, topath = [self.recode(part) for part in paths]
233 path, topath = paths
234 if path is not None:
235 path = self.recode(path)
236 if topath is not None:
237 topath = self.recode(topath)
235 238 seen.add(path or topath)
236 239
237 240 if topath is None:
@@ -260,19 +263,3 b' class bzr_source(converter_source):'
260 263 parentmap = self.sourcerepo.get_parent_map(ids)
261 264 parents = tuple([parent for parent in ids if parent in parentmap])
262 265 return parents
263
264 def recode(self, s, encoding=None):
265 """This version of recode tries to encode unicode to bytecode,
266 and preferably using the UTF-8 codec.
267 Other types than Unicode are silently returned, this is by
268 intention, e.g. the None-type is not going to be encoded but instead
269 just passed through
270 """
271 if not encoding:
272 encoding = self.encoding or 'utf-8'
273
274 if isinstance(s, unicode):
275 return s.encode(encoding)
276 else:
277 # leave it alone
278 return s
General Comments 0
You need to be logged in to leave comments. Login now