mirror of
https://github.com/frej/fast-export.git
synced 2025-11-03 17:55:49 +01:00
Add option for specifying the text encoding used by Mercurial
When a mercurial repository does not use utf-8 for encoding author strings and commit messages the "-e <encoding>" command line option can be used to force fast-export to convert incoming meta data from <encoding> to utf-8. When "-e <encoding>" is given, we use Python's string decoding/encoding API to convert meta data on the fly when processing commits.
This commit is contained in:
@@ -67,9 +67,12 @@ def get_branch(name):
|
||||
return origin_name + '/' + name
|
||||
return name
|
||||
|
||||
def get_changeset(ui,repo,revision,authors={}):
|
||||
def get_changeset(ui,repo,revision,authors={},encoding=''):
|
||||
node=repo.lookup(revision)
|
||||
(manifest,user,(time,timezone),files,desc,extra)=repo.changelog.read(node)
|
||||
if encoding:
|
||||
user=user.decode(encoding).encode('utf8')
|
||||
desc=desc.decode(encoding).encode('utf8')
|
||||
tz="%+03d%02d" % (-timezone / 3600, ((-timezone % 3600) / 60))
|
||||
branch=get_branch(extra.get('branch','master'))
|
||||
return (node,manifest,fixup_user(user,authors),(time,tz),files,desc,branch,extra)
|
||||
|
||||
Reference in New Issue
Block a user