[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] change-svn-wc-format.py

From: Edmund Wong <edmund_at_belfordhk.com>
Date: Mon, 30 Mar 2009 23:02:16 +0800

Hi guys,

I know I posted this before, but for some reasons the posted
patch alignment was completely bonkers. I don't know if it's
the editor (was using Seamonkey, now I'm using the webmail to
see if it's the same. Sorry for the waste of bandwidth.
At the time of this writing, the patch seems aligned.
If this doesn't work, I'll have to use the attachment
method. Is this allowed here?

Log as follows:

[[[
   Followup to r36302.

   Modified change-svn-wc-format.py to create or update
   format file in the .svn folder.

   * tools/client-side/change-svn-wc-format.py
     (WCFormatConverter: write_dir_format): Added a check
        if the entries file was parsed properly. If so,
        the format file is also created (if it does not
        exist in the .svn folder) or updated with the
        given format_nbr value as given by the
        write_dir_format parameter.

     (Format): Added new class to take care of the
              .svn/format file.

   Patch by: Edmund Wong <edmund_at_belfordhk.com>
   Reviewed by: stsp
                arfrever
                danielsh
   ]]]
   
Index: change-svn-wc-format.py
===================================================================
--- change-svn-wc-format.py (revision 36847)
+++ change-svn-wc-format.py (working copy)
@@ -84,7 +84,7 @@
     if self.verbosity:
       print("Processing directory '%s'" % dirname)
     entries = Entries(os.path.join(dirname, get_adm_dir(), "entries"))
-
+ entries_parsed = True
     if self.verbosity:
       print("Parsing file '%s'" % entries.path)
     try:
@@ -94,7 +94,17 @@
         raise
       sys.stderr.write("%s, skipping\n" % e)
       sys.stderr.flush()
+ entries_parsed = False
 
+ if entries_parsed:
+ format = Format(os.path.join(dirname, get_adm_dir(), "format"))
+ if self.verbosity:
+ print("Updating file '%s'" % format.path)
+ format.write_format(format_nbr, self.verbosity)
+ else:
+ if self.verbosity:
+ print("Skipping file '%s'" % format.path)
+
     if self.verbosity:
       print("Checking whether WC format can be converted")
     try:
@@ -298,7 +308,26 @@
       rep += "[%s] %s\n" % (Entries.entry_fields[i], self.fields[i])
     return rep
 
+class Format:
+ """Represents a .svn/format file."""
 
+ def __init__(self, path):
+ self.path = path
+
+ def write_format(self, format_nbr, verbosity=0):
+ format_string = '%d\n'
+ if os.path.exists(self.path):
+ if verbosity >= 1:
+ print("%s will be updated." % self.path)
+ os.chmod(self.path,0600)
+ 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)
+
 class LocalException(Exception):
   """Root of local exception class hierarchy."""
   pass

--
"Pax tecum"
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1482738
Received on 2009-03-30 17:12:48 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.