philvh wrote:
> This is my change for Python 3 under Windows:
Here's the diff of philvh's patch.
I'm not sure what the log should be, and probably someone
can make a better log (especially philvh) but :
[[[
Modified for Python 3 under Windows
* tools/client-side/change-svn-wc-format.py
(write_format): Modified comment,
Changed os.chmod call to use stat.S_IWRITE,
Changed os.chmod call to use stat.S_IREAD
(write_dir_format): Changed to Python 3 support with the
use of UnrecognizedWCFormatException as e:,
LossyConversionException as e:
(main): Changed LocalException, e: -> LocalException as e:
Patch by: philvh
]]]
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1589875
Index: tools/client-side/change-svn-wc-format.py
===================================================================
--- tools/client-side/change-svn-wc-format.py (revision 37093)
+++ tools/client-side/change-svn-wc-format.py (working copy)
@@ -19,6 +19,7 @@
import sys
import os
import getopt
+import stat
try:
my_getopt = getopt.gnu_getopt
except AttributeError:
@@ -89,7 +90,7 @@
print("Parsing file '%s'" % entries.path)
try:
entries.parse(self.verbosity)
- except UnrecognizedWCFormatException, e:
+ except UnrecognizedWCFormatException as e:
if self.error_on_unrecognized:
raise
sys.stderr.write("%s, skipping\n" % e)
@@ -109,7 +110,7 @@
print("Checking whether WC format can be converted")
try:
entries.assert_valid_format(format_nbr, self.verbosity)
- except LossyConversionException, e:
+ except LossyConversionException as e:
# In --force mode, ignore complaints about lossy conversion.
if self.force:
print("WARNING: WC format conversion will be lossy. Dropping "\
@@ -252,25 +253,29 @@
def write_format(self, format_nbr):
# Overwrite all bytes of the format number (which are the first bytes in
- # the file). Overwrite format '10' by format '09', which will be converted
- # to '9' by Subversion when it rewrites the file. (Subversion 1.4 and later
+ # the file). Overwrite format '10' by format '09', which will be
+converted
+ # to '9' by Subversion when it rewrites the file. (Subversion 1.4 and
+later
# ignore leading zeroes in the format number.)
assert len(str(format_nbr)) <= self.format_nbr_bytes
format_string = '%0' + str(self.format_nbr_bytes) + 'd'
- os.chmod(self.path, 0600)
- output = open(self.path, "r+", 0)
+ os.chmod(self.path, stat.S_IWRITE) #0600)
+ output = open(self.path, "r+", 1)
output.write(format_string % format_nbr)
output.close()
- os.chmod(self.path, 0400)
+ os.chmod(self.path, stat.S_IREAD)
class Entry:
"Describes an entry in a WC."
- # Maps format numbers to indices of fields within an entry's record that must
+ # Maps format numbers to indices of fields within an entry's record that
+must
# be retained when downgrading to that format.
must_retain_fields = {
- # Not in 1.4: changelist, keep-local, depth, tree-conflicts, file-externals
+ # Not in 1.4: changelist, keep-local, depth, tree-conflicts,
+file-externals
8 : (30, 31, 33, 34, 35),
# Not in 1.5: tree-conflicts, file-externals
9 : (34, 35),
@@ -292,7 +297,8 @@
raise LossyConversionException(lossy_fields,
"Lossy WC format conversion requested for entry '%s'\n"
"Data for the following field(s) is unsupported by older versions "
- "of\nSubversion, and is likely to be subsequently discarded, and/or "
+ "of\nSubversion, and is likely to be subsequently discarded, and/or
+"
"have\nunexpected side-effects: %s\n\n"
"WC format conversion was cancelled, use the --force option to "
"override\nthe default behavior."
@@ -320,14 +326,14 @@
if os.path.exists(self.path):
if verbosity >= 1:
print("%s will be updated." % self.path)
- os.chmod(self.path,0600)
+ os.chmod(self.path,stat.S_IWRITE)
else:
if verbosity >= 1:
print("%s does not exist, creating it." % self.path)
format = open(self.path, "w")
format.write(format_string % format_nbr)
format.close()
- os.chmod(self.path, 0400)
+ os.chmod(self.path, stat.S_IREAD)
class LocalException(Exception):
"""Root of local exception class hierarchy."""
@@ -389,7 +395,7 @@
try:
converter.change_wc_format(new_format_nbr)
- except LocalException, e:
+ except LocalException as e:
if debug:
raise
sys.stderr.write("%s\n" % e)
Received on 2009-04-08 06:50:49 CEST