Bug 507080 - TM: "Assertion failure: !(sprop->attrs & JSPROP_GETTER), at ../jstracer...
[mozilla-central.git] / client.py
blobb30dee3ec695e8a19ce9d3ddda7bf5563078b941
1 #!/usr/bin/python
3 NSPR_DIRS = ('nsprpub',)
4 NSS_DIRS = ('dbm',
5 'security/nss',
6 'security/coreconf',
7 'security/dbm')
9 import os
10 import sys
11 import datetime
12 import shutil
13 from optparse import OptionParser
14 from build.util import check_call
16 topsrcdir = os.path.dirname(__file__)
17 if topsrcdir == '':
18 topsrcdir = '.'
20 def check_call_noisy(cmd, *args, **kwargs):
21 print "Executing command:", cmd
22 check_call(cmd, *args, **kwargs)
24 def do_hg_pull(dir, repository, hg):
25 fulldir = os.path.join(topsrcdir, dir)
26 # clone if the dir doesn't exist, pull if it does
27 if not os.path.exists(fulldir):
28 fulldir = os.path.join(topsrcdir, dir)
29 check_call_noisy([hg, 'clone', repository, fulldir])
30 else:
31 cmd = [hg, 'pull', '-u', '-R', fulldir]
32 if repository is not None:
33 cmd.append(repository)
34 check_call_noisy(cmd)
35 check_call([hg, 'parent', '-R', fulldir,
36 '--template=Updated to revision {node}.\n'])
38 def do_cvs_export(modules, tag, cvsroot, cvs):
39 """Check out a CVS directory without CVS metadata, using "export"
40 modules is a list of directories to check out, e.g. ['nsprpub']
41 """
42 for module in modules:
43 fullpath = os.path.join(topsrcdir, module)
44 if os.path.exists(fullpath):
45 print "Removing '%s'" % fullpath
46 shutil.rmtree(fullpath)
48 (parent, leaf) = os.path.split(module)
49 print "CVS export begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
50 check_call_noisy([cvs, '-d', cvsroot,
51 'export', '-r', tag, '-d', leaf,
52 'mozilla/%s' % module],
53 cwd=os.path.join(topsrcdir, parent))
54 print "CVS export end: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
56 o = OptionParser(usage="client.py [options] update_nspr tagname | update_nss tagname")
57 o.add_option("--skip-mozilla", dest="skip_mozilla",
58 action="store_true", default=False,
59 help="Obsolete")
61 o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
62 help="The location of the cvs binary")
63 o.add_option("--cvsroot", dest="cvsroot",
64 default=os.environ.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
65 help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
67 try:
68 options, args = o.parse_args()
69 action = args[0]
70 except IndexError:
71 o.print_help()
72 sys.exit(2)
74 if action in ('checkout', 'co'):
75 print >>sys.stderr, "Warning: client.py checkout is obsolete."
76 pass
77 elif action in ('update_nspr'):
78 tag, = args[1:]
79 do_cvs_export(NSPR_DIRS, tag, options.cvsroot, options.cvs)
80 elif action in ('update_nss'):
81 tag, = args[1:]
82 do_cvs_export(NSS_DIRS, tag, options.cvsroot, options.cvs)
83 else:
84 o.print_help()
85 sys.exit(2)