关于mercurial转换subversion库遇到的文件乱码问题

好容易在网上找到答案

我使用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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值