comparison mozillatry.py @ 37:cbf6ec238952

another convenience method
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 08 Jan 2013 14:44:19 -0800
parents 3a7e8aa80328
children 2d900a1f9951
comparison
equal deleted inserted replaced
36:3a7e8aa80328 37:cbf6ec238952
138 } 138 }
139 139
140 # configuration items to interpolate as paths 140 # configuration items to interpolate as paths
141 paths = ['mozilla_central'] 141 paths = ['mozilla_central']
142 142
143 @classmethod
144 def main(cls, args=sys.argv[1:]):
145 instance = cls()
146 options, args = instance.parse_args()
147 if not args:
148 instance.print_usage()
149 instance.exit()
150 return instance, options, args
151
143 def __init__(self): 152 def __init__(self):
144 configuration.Configuration.__init__(self, usage=self.usage, load='--config') 153 configuration.Configuration.__init__(self, usage=self.usage, load='--config')
145 154
146 def validate(self): 155 def validate(self):
147 """check configuration""" 156 """check configuration"""
181 debug=self.config.get('debug'), 190 debug=self.config.get('debug'),
182 unittests=self.config.get('unittests', []), 191 unittests=self.config.get('unittests', []),
183 talos=self.config.get('talostests', []), 192 talos=self.config.get('talostests', []),
184 bug=self.config.get('bug')) 193 bug=self.config.get('bug'))
185 194
195 def push_to_try(self, patches, commit=None, repo=None):
196 assert patches
197 if commit is None:
198 commit = self.try_syntax()
199 repo = repo or self.config['mozilla_central']
200 push_to_try(patch=patches, repo=repo, commit=commit)
201
186 def main(args=sys.argv[1:]): 202 def main(args=sys.argv[1:]):
187 203
188 # parse command line arguments 204 # parse command line arguments
189 mozillatry = MozillaTryConfiguration() 205 mozillatry, options, args = MozillaTryConfiguration.create(args)
190 options, args = mozillatry.parse_args()
191 if not args:
192 mozillatry.print_usage()
193 mozillatry.exit()
194 206
195 # get mozilla-central repository directory 207 # get mozilla-central repository directory
196 try_directory = options.mozilla_central 208 try_directory = options.mozilla_central
197 209
198 # build try syntax 210 # build try syntax
199 commit = mozillatry.try_syntax() 211 commit = mozillatry.try_syntax()
200 print commit 212 print commit
201 213
202 # push to try 214 # push to try
203 push_to_try(patches=args, repo=options.mozilla_central, commit=commit) 215 mozillatry.push_to_try(patches, commit=commit)
204 216
205 if __name__ == '__main__': 217 if __name__ == '__main__':
206 main() 218 main()
207 219