好容易在网上找到答案
我使用cygwin的mercurial版本,为什么?因为可以直接改源码
$ hg --version
Mercurial Distributed SCM (version 1.8.1)
(see http://mercurial.selenic.com for more information)
Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cd /usr/lib/python2.6/site-packages/hgext/convert/
先备份一下
$ mv hg.pyc hhhg.pyc
$ cp hg.py hhhg.py
修改后的差别
def putcommit(self, files, copies, parents, commit, source, revmap):
###gegogi mod###
def _cp936(s):
return s.decode('utf-8').encode('cp936')
def _utf8(s):
return s.decode('cp936').encode('utf-8')
##################
files = dict(files)
### gegogi mod ###
for k, v in files.items():
del files[k]
files[_cp936(k)] = v
for k, v in copies.items():
del copies[k]
copies[_cp936(k)] = _cp936(v)
##################
def getfilectx(repo, memctx, f):
v = files[f]
#data, mode = source.getfile(f, v)
data,e = source.getfile(_utf8(f), v)
if f == '.hgtags':
data = self._rewritetags(source, revmap, data)
#return context.memfilectx(f, data, 'l' in mode, 'x' in mode,
return context.memfilectx(f, data, 'l' in e, 'x' in e,
copies.get(f))
在用hg convert所有的中文文件名都对了
原文在这里http://mercurial.selenic.com/bts/issue2223