scripts/new_branch.py
changeset 51 9f288fee8a82
parent 47 a237c3c5763e
--- a/scripts/new_branch.py	Tue Jun 10 16:10:31 2008 +0000
+++ b/scripts/new_branch.py	Tue Jun 10 16:19:59 2008 +0000
@@ -38,11 +38,12 @@
 from trunk.scripts import svn_helper
 
 
-def buildOptionList(defaults):
+def buildOptionList(defaults={}):
   """Returns a list of command-line settings.Options for this script.
 
   Args:
-    defaults: dict of possible pre-loaded default values (may be empty)
+    defaults: dict of possible pre-loaded default values; default is empty
+      dict (which is safe because it is not altered)
   """
   help_user = defaults.get('user', '<user>')
   user_help_msg = (
@@ -57,14 +58,14 @@
   if def_repo:
     repo_help_msg = 'SVN repository; default is %s' % def_repo
   else:
-    repo_help_msg = 'SVN repository; REQUIRED if default unavailable'
+    repo_help_msg = 'SVN repository; REQUIRED if a default is missing'
 
   def_wc = defaults.get('wc')
 
   if def_wc:
     wc_help_msg = 'working copy directory; default is %s' % def_wc
   else:
-    wc_help_msg = 'working copy directory; REQUIRED if default unavailable'
+    wc_help_msg = 'working copy directory; REQUIRED if a default is missing'
 
   return [
       settings.Option(
@@ -91,9 +92,11 @@
 
 
 def main(args):
+  # create parser just for usage info before settings file is read successfully
+  usage_parser = settings.OptionParser(option_list=buildOptionList())
+
   # attempt to read the common trunk/scripts settings file
-  defaults = settings.readPythonSettingsOrDie(
-      parser=settings.OptionParser(option_list=buildOptionList({})))
+  defaults = settings.readPythonSettingsOrDie(parser=usage_parser)
 
   # create the command-line options parser
   parser = settings.makeOptionParserOrDie(