当我从远程Hg仓库中提取和更新变更集时,我收到以下错误消息:
Traceback (most recent call last):
File "/opt/local/bin/hg", line 38, in <module>
mercurial.dispatch.run()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 28, in run
sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 65, in dispatch
return _runcatch(req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 88, in _runcatch
return _dispatch(req)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 741, in _dispatch
cmdpats, cmdoptions)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 514, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 831, in _runcommand
return checkargs()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 802, in checkargs
return cmdfunc()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/dispatch.py", line 738, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 472, in check
return func(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/extensions.py", line 144, in wrap
util.checksignature(origfn), *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 472, in check
return func(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/hgext/mq.py", line 3546, in mqcommand
return orig(ui, repo, *args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 472, in check
return func(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/commands.py", line 5916, in update
ret = hg.update(repo, rev)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 472, in update
stats = updaterepo(repo, node, False)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/hg.py", line 468, in updaterepo
return mergemod.update(repo, node, False, overwrite, None)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/merge.py", line 618, in update
_checkcollision(p2, None)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/merge.py", line 125, in _checkcollision
fold = util.normcase(fn)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/posix.py", line 198, in normcase
u = s.decode('utf-8')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position 44: invalid continuation byte
我发现有一个提交导致错误,但它在我的同事的PC上工作正常。我怎样才能跳过该变更集,或者还有其他方法来修复我的本地仓库?
答案 0 :(得分:0)
将Mercurial升级到2.6后,问题解决了。我想原因是python在Windows和其他系统上对文件名使用不同的编码:
http://wiki.python.org/moin/Python3UnicodeDecodeError
Mercurial 2.6添加了一些代码来处理可能的DecodeError:
try:
path.decode('ascii') # throw exception for non-ASCII character
return path.lower()
except UnicodeDecodeError:
pass
try:
u = path.decode('utf-8')
except UnicodeDecodeError:
# OS X percent-encodes any bytes that aren't valid utf-8
s = ''
g = ''
l = 0
for c in path:
o = ord(c)
if l and o < 128 or o >= 192:
# we want a continuation byte, but didn't get one
s += ''.join(["%%%02X" % ord(x) for x in g])
g = ''
l = 0
if l == 0 and o < 128:
# ascii
s += c
elif l == 0 and 194 <= o < 245:
# valid leading bytes
if o < 224:
l = 1
elif o < 240:
l = 2
else:
l = 3
g = c
elif l > 0 and 128 <= o < 192:
# valid continuations
g += c
l -= 1
if not l:
s += g
g = ''
else:
# invalid
s += "%%%02X" % o
# any remaining partial characters
s += ''.join(["%%%02X" % ord(x) for x in g])
u = s.decode('utf-8')`
posix.py中的