summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorLars Schneider <larsxschneider@gmail.com>2015-09-16 12:37:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-16 22:53:08 (GMT)
commit00a9403a1069b19f27d690853db34459b32b3d3d (patch)
tree1ca71350fae31c45608bed0abbe6cc4cdc54cd58 /git-p4.py
parenta9e38359e356de7d6397395bdde8af61440262d0 (diff)
downloadgit-00a9403a1069b19f27d690853db34459b32b3d3d.zip
git-00a9403a1069b19f27d690853db34459b32b3d3d.tar.gz
git-00a9403a1069b19f27d690853db34459b32b3d3d.tar.bz2
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>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/git-p4.py b/git-p4.py
index b1ad86d..65feb22 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2213,16 +2213,15 @@ class P4Sync(Command, P4UserMap):
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))