changeset 37:cbf6ec238952

another convenience method
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 08 Jan 2013 14:44:19 -0800
parents 3a7e8aa80328
children 2d900a1f9951
files mozillatry.py
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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()