Ryan Schmidt wrote:
> With python 3.0rc1, the log-police.py script says this:
>
>
> File "/opt/local/share/subversion/tools/hook-scripts/log-police.py",
> line 24
> True = 1
> SyntaxError: assignment to keyword
>
>
> It works fine with python 2.5.2.
Infact in python 2.5 you can say True = 0 !
This code is trying to maintain compatability with python pre 2.3 which
didn't have True and False. There must be loads of code out there that
does this, it will all be broken because the syntax check happens
regardless of whether the except clause is actually invoked.
Maybe the Python guys can offer a solution to what surely is about to
become a common problem.
If not, I offer two: either:
1) Define our own true and false (as True and False if available or as 0
and 1 if not). log-police.patch attached
or
2) Don't try and assign to True and False at all, this will break
compatibility with python pre 2.3. log-police2.patch attached.
Index: tools/hook-scripts/log-police.py
===================================================================
--- tools/hook-scripts/log-police.py (revision 33393)
+++ tools/hook-scripts/log-police.py (working copy)
@@ -17,14 +17,7 @@
import svn.core
-# Pretend we have true booleans on older python versions
-try:
- True
-except:
- True = 1
- False = 0
-
def fix_log_message(log_message):
"""Return a fixed version of LOG_MESSAGE. By default, this just
means ensuring that the result ends with exactly one newline and no
Index: tools/hook-scripts/log-police.py
===================================================================
--- tools/hook-scripts/log-police.py (revision 33393)
+++ tools/hook-scripts/log-police.py (working copy)
@@ -17,14 +17,14 @@
import svn.core
-# Pretend we have true booleans on older python versions
+# Define our own true and false. Use true boolean types if available.
try:
- True
+ true = True
+ false = False
except:
- True = 1
- False = 0
+ true = 1
+ false = 0
-
def fix_log_message(log_message):
"""Return a fixed version of LOG_MESSAGE. By default, this just
means ensuring that the result ends with exactly one newline and no
@@ -78,7 +78,7 @@
repos_path = None
txn_name = None
rev_name = None
- all_revs = False
+ all_revs = false
try:
opts, args = my_getopt(argv[1:], 't:r:h?', ["help", "all-revs"])
@@ -92,7 +92,7 @@
elif opt == '-r':
rev_name = value
elif opt == '--all-revs':
- all_revs = True
+ all_revs = true
else:
usage_and_exit("unknown option '%s'." % opt)
@@ -122,7 +122,7 @@
# Do it such that if we're running on a live repository, we'll
# catch up even with commits that came in after we started.
last_youngest = 0
- while True:
+ while true:
youngest = svn.fs.svn_fs_youngest_rev(fs)
if youngest >= last_youngest:
for this_rev in range(last_youngest, youngest + 1):
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-10-02 14:48:39 CEST