git-p4: improve path encoding verbose output

If a path with non-ASCII characters is detected then print the
encoding and the encoded string in verbose mode.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Lars Schneider 2015-09-16 14:37:04 +02:00 committed by Junio C Hamano
parent a9e38359e3
commit 00a9403a10

View File

@ -2213,16 +2213,15 @@ class P4Sync(Command, P4UserMap):
text = regexp.sub(r'$\1$', text) text = regexp.sub(r'$\1$', text)
contents = [ text ] contents = [ text ]
if gitConfig("git-p4.pathEncoding"): try:
relPath = relPath.decode(gitConfig("git-p4.pathEncoding")).encode('utf8', 'replace') relPath.decode('ascii')
elif self.verbose: except:
try: encoding = 'utf8'
relPath.decode('ascii') if gitConfig('git-p4.pathEncoding'):
except: encoding = gitConfig('git-p4.pathEncoding')
print ( relPath = relPath.decode(encoding).encode('utf8', 'replace')
"Path with Non-ASCII characters detected and no path encoding defined. " if self.verbose:
"Please check the encoding: %s" % relPath 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)) self.gitStream.write("M %s inline %s\n" % (git_mode, relPath))