# HG changeset patch # User Jeff Hammel # Date 1357685059 28800 # Node ID cbf6ec23895253af85230f65f6550b573a484053 # Parent 3a7e8aa80328348ff7c60972122a2524121bd2dc another convenience method diff -r 3a7e8aa80328 -r cbf6ec238952 mozillatry.py --- a/mozillatry.py Tue Jan 08 14:30:13 2013 -0800 +++ b/mozillatry.py Tue Jan 08 14:44:19 2013 -0800 @@ -140,6 +140,15 @@ # configuration items to interpolate as paths paths = ['mozilla_central'] + @classmethod + def main(cls, args=sys.argv[1:]): + instance = cls() + options, args = instance.parse_args() + if not args: + instance.print_usage() + instance.exit() + return instance, options, args + def __init__(self): configuration.Configuration.__init__(self, usage=self.usage, load='--config') @@ -183,14 +192,17 @@ talos=self.config.get('talostests', []), bug=self.config.get('bug')) + def push_to_try(self, patches, commit=None, repo=None): + assert patches + if commit is None: + commit = self.try_syntax() + repo = repo or self.config['mozilla_central'] + push_to_try(patch=patches, repo=repo, commit=commit) + def main(args=sys.argv[1:]): # parse command line arguments - mozillatry = MozillaTryConfiguration() - options, args = mozillatry.parse_args() - if not args: - mozillatry.print_usage() - mozillatry.exit() + mozillatry, options, args = MozillaTryConfiguration.create(args) # get mozilla-central repository directory try_directory = options.mozilla_central @@ -200,7 +212,7 @@ print commit # push to try - push_to_try(patches=args, repo=options.mozilla_central, commit=commit) + mozillatry.push_to_try(patches, commit=commit) if __name__ == '__main__': main()