comparison mozillatry.py @ 24:484858dfbc03

add some options so this is more consumable
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 07 Dec 2012 14:53:54 -0800
parents 4016b1d28c79
children 295112b3e143
comparison
equal deleted inserted replaced
23:4016b1d28c79 24:484858dfbc03
5 """ 5 """
6 6
7 import configuration 7 import configuration
8 import optparse 8 import optparse
9 import os 9 import os
10 import shutil
10 import sys 11 import sys
11 12
12 from subprocess import check_call as call 13 from subprocess import check_call as call
13 14
14 def reset(directory): 15 def reset(directory):
15 """reset an hg directory to a good state""" 16 """reset an hg directory to a good state"""
16 assert os.path.exists(directory) and os.path.isdir(directory) 17 assert os.path.exists(directory) and os.path.isdir(directory)
17 hg_dir = os.path.join(directory, '.hg') 18 hg_dir = os.path.join(directory, '.hg')
18 assert os.path.exists(hg_dir) and os.path.isdir(hg_dir) 19 assert os.path.exists(hg_dir) and os.path.isdir(hg_dir)
20 patches = os.path.join(hg_dir, 'patches')
21 if os.path.exists(patches):
22 shutil.rmtree(patches)
19 call(['hg', 'revert', '--no-backup', '--all'], cwd=directory) 23 call(['hg', 'revert', '--no-backup', '--all'], cwd=directory)
20 call(['hg', 'qpop', '--all'], cwd=directory) 24 call(['hg', 'qpop', '--all'], cwd=directory)
21 try: 25 try:
22 shutil.rmtree(os.path.join(hg_dir, 'patches')) # remove patches 26 shutil.rmtree(os.path.join(hg_dir, 'patches')) # remove patches
23 except: 27 except:
24 pass 28 pass
25 29
26 def update(directory): 30 def update_repo(directory):
27 """update a mozilla-central checkout""" 31 """update an hg repository"""
28 assert os.path.exists(directory) and os.path.isdir(directory) 32 assert os.path.exists(directory) and os.path.isdir(directory)
29 reset(directory) 33 reset(directory)
30 call(['hg', 'pull'], cwd=directory) 34 call(['hg', 'pull'], cwd=directory)
31 call(['hg', 'update'], cwd=directory) 35 call(['hg', 'update'], cwd=directory)
32 call(['hg', 'qinit'], cwd=directory) 36 call(['hg', 'qinit'], cwd=directory)
33 37
34 def push_to_try(patches, repo, commit, _try='ssh://hg.mozilla.org/try/'): 38 def push_to_try(patches, repo, commit, _try='ssh://hg.mozilla.org/try/', update=True):
35 """push a series of patches to try repository""" 39 """push a series of patches to try repository"""
36 40
37 # ensure the repo is in a good state 41 # ensure the repo is in a good state
38 update(repo) 42 if update:
43 update_repo(repo)
39 44
40 try: 45 try:
41 # apply patches 46 # apply patches
42 for patch in patches: 47 for patch in patches:
43 call(['hg', 'qimport', patch], cwd=repo) 48 call(['hg', 'qimport', patch], cwd=repo)