Changes to address comments by Sverre about the previous commit.
authorTodd Larsen <tlarsen@google.com>
Tue, 10 Jun 2008 16:19:59 +0000
changeset 51 9f288fee8a82
parent 50 43df6d7be888
child 52 25d8f4623447
Changes to address comments by Sverre about the previous commit. Patch by: Todd Larsen Review by: Sverre Rabbelier Review issue: 341 Review URL: http://codereviews.googleopensourceprograms.com/341
scripts/new_branch.py
--- 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(