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

[PATCH] Support command line options in svn_apply_autoprops.py

From: Wei-Yin Chen <wychen_at_video.ee.ntu.edu.tw>
Date: Sat, 4 Sep 2010 21:05:56 +0800

Hi,

This patch makes trunk/contrib/client-side/svn_apply_autoprops.py take
command line options.
The usage would be:
svn_apply_autoprops.py [-c config_file] [paths to process...]

The -c option specifies the configuration file name, and it overrides
the setting in environment variable SVN_CONFIG_FILENAME.
The rest of the command line arguments are treated as paths to process.

[[[
Make svn_apply_autoprops.py take command line options.
Option -c for svn configuration filename, and the rest for paths to process.
]]]

Regards,
Wei-Yin

----------------------------------------------------------------
--- svn_apply_autoprops.py.old 2010-09-04 20:16:28.000000000 +0800
+++ svn_apply_autoprops.py.option 2010-09-04 20:53:47.000000000 +0800
@@ -8,12 +8,10 @@
 # auto-property to a single pathname, this script will apply all
 # matching lines to a single pathname.
 #
 # To do:
 # 1) Switch to using the Subversion Python bindings.
-# 2) Allow a command line option to specify the configuration file to
-# load the auto-properties from.
 #
 # $HeadURL$
 # $LastChangedRevision$
 # $LastChangedDate$
 # $LastChangedBy$
@@ -137,22 +135,39 @@
         print 'Command "%s" failed with exit status %s' \
               % (command, status)
         sys.exit(1)

 def main():
+ from optparse import OptionParser
+ op=OptionParser(usage="%prog [-c config_file] [paths to process...]")
+ op.add_option("-c",
+ dest="config_filename",action="store",help="SVN
config filename.",metavar="<args>")
+ options, args = op.parse_args()
+ for p in args:
+ if not os.path.exists(p):
+ print "Path '%s' doesn't exist." % p
+ sys.exit(1)
+ paths = [p for p in args if os.path.exists(p)]
+ if not paths:
+ paths = '.'
+
   config_filename = os.path.expandvars(SVN_CONFIG_FILENAME)
+ if options.config_filename:
+ config_filename = options.config_filename
   try:
     fd = file(config_filename)
   except IOError:
     print "Cannot open svn configuration file '%s' for reading: %s" \
           % (config_filename, sys.exc_value.strerror)
+ sys.exit(1)

   autoprop_lines = get_autoprop_lines(fd)

   fd.close()

   autoprop_lines = process_autoprop_lines(autoprop_lines)

- os.path.walk('.', filter_walk, autoprop_lines)
+ for p in paths:
+ os.path.walk(p, filter_walk, autoprop_lines)

 if __name__ == '__main__':
   sys.exit(main())
Received on 2010-09-04 15:07:12 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.