# HG changeset patch # User Jeff Hammel # Date 1354431919 28800 # Node ID 3eaee0d10880d87ef48237b5faaf2da709acc5f9 # Parent 0f8e4a3b4e1c1a751e657d11855fa2eb867a821b make getting mozilla-central slightly less of a hack; soon, we should transition to configuration to make this nice, though lets build the API around it first for now diff -r 0f8e4a3b4e1c -r 3eaee0d10880 mozillatry.py --- a/mozillatry.py Sat Dec 01 19:42:38 2012 -0800 +++ b/mozillatry.py Sat Dec 01 23:05:19 2012 -0800 @@ -10,15 +10,6 @@ from subprocess import check_call as call -def config(filename): - """read .mozutils.ini config file""" - # XXX stub; this should really use - # e.g. http://k0s.org/mozilla/hg/configuration/ - from ConfigParser import ConfigParser - parser = ConfigParser() - parser.read(filename) - return os.path.expanduser(parser.get('hg', 'mozilla-central')) - def reset(directory): """reset an hg directory to a good state""" assert os.path.exists(directory) and os.path.isdir(directory) @@ -92,6 +83,25 @@ parser.add_option('-c', '--config', dest='config', default=os.path.join(os.environ['HOME'], '.mozutils.ini'), help='location of config file') + parser.add_option('-m', '--m-c', '--mozilla-central', + help="path to mozilla-central repository") + + +def read_config(filename, options): + """read .mozutils config file and substitute for options if None""" + + # XXX stub; this should really use + # e.g. http://k0s.org/mozilla/hg/configuration/ + from ConfigParser import ConfigParser + parser = ConfigParser() + parser.read(filename) + if options.mozilla_central is None: + try: + path = parser.get('hg', 'mozilla-central') + os.path.expanduser(path) + except Exception: # XXX temporary hack + pass + return parser def main(args=sys.argv[1:]): @@ -117,10 +127,10 @@ # get mozilla-central repository directory config_file = options.__dict__.pop('config') - if not os.path.exists(config_file): - parser.error("You need a config file at ~/.mozutils.ini") - try_directory = config(config_file) # XXX temporary hack - if not os.path.exists(try_directory): + if os.path.exists(config_file): + read_config(config_file) + try_directory = options.mozilla_central + if (try_directory is None) or (not os.path.exists(try_directory)): parser.error("mozilla-central try directory does not exist: %s" % try_directory) # build try syntax