# HG changeset patch # User Todd Larsen # Date 1213114799 0 # Node ID 9f288fee8a82c0235bb8cb41787adaa7f6903b10 # Parent 43df6d7be888d467933a1b3f152324861d7ca60e 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 diff -r 43df6d7be888 -r 9f288fee8a82 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_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(