text = regexp.sub(r'$\1$', text)
contents = [ text ]
- if gitConfig("git-p4.pathEncoding"):
- relPath = relPath.decode(gitConfig("git-p4.pathEncoding")).encode('utf8', 'replace')
- elif self.verbose:
- try:
- relPath.decode('ascii')
- except:
- print (
- "Path with Non-ASCII characters detected and no path encoding defined. "
- "Please check the encoding: %s" % relPath
- )
+ try:
+ relPath.decode('ascii')
+ except:
+ encoding = 'utf8'
+ if gitConfig('git-p4.pathEncoding'):
+ encoding = gitConfig('git-p4.pathEncoding')
+ relPath = relPath.decode(encoding).encode('utf8', 'replace')
+ if self.verbose:
+ print 'Path with non-ASCII characters detected. Used %s to encode: %s ' % (encoding, relPath)
self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))