git-p4.py: support Python 2.5
authorBrandon Casey <drafnel@gmail.com>
Sat, 26 Jan 2013 19:14:32 +0000 (11:14 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Jan 2013 03:00:03 +0000 (19:00 -0800)
Python 2.5 and older do not accept None as the first argument to
translate() and complain with:

TypeError: expected a character buffer object

As suggested by Pete Wyckoff, let's just replace the call to translate()
with a regex search which should be more clear and more portable.

This allows git-p4 to be used with Python 2.5.

Signed-off-by: Brandon Casey <bcasey@nvidia.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
INSTALL
git-p4.py
diff --git a/INSTALL b/INSTALL
index 28f34bd254d8b0be484b5aedce1c35079fd32cc4..fc723b3e7f8be1efcedd254def349a3c6b78d225 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -131,7 +131,7 @@ Issues of note:
          use English. Under autoconf the configure script will do this
          automatically if it can't find libintl on the system.
 
-       - Python version 2.6 or later is needed to use the git-p4
+       - Python version 2.5 or later is needed to use the git-p4
          interface to Perforce.
 
  - Some platform specific issues are dealt with Makefile rules,
index 551aec9417401dcd7ef526dd6c9b554e5194f861..a041b49818bff474a866514b7de8bcca7a5e7f0f 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -742,7 +742,8 @@ def wildcard_encode(path):
     return path
 
 def wildcard_present(path):
-    return path.translate(None, "*#@%") != path
+    m = re.search("[*#@%]", path)
+    return m is not None
 
 class Command:
     def __init__(self):