Return back Qt font using
[mozilla-central.git] / client.py
blobbb41df24afb11f9a05eb00b494a70e3c59934fa9
1 #!/usr/bin/python
3 NSPR_CO_TAG = 'NSPR_4_7_1_BETA2'
4 NSS_CO_TAG = 'NSS_3_12_RC2'
6 NSPR_DIRS = ('nsprpub',)
7 NSS_DIRS = ('dbm',
8 'security/nss',
9 'security/coreconf',
10 'security/dbm')
12 # URL of the default hg repository to clone for Tamarin.
13 DEFAULT_TAMARIN_REPO = 'http://hg.mozilla.org/tamarin-central/'
15 import os
16 import sys
17 from optparse import OptionParser
19 topsrcdir = os.path.dirname(__file__)
20 if topsrcdir == '':
21 topsrcdir = '.'
23 try:
24 from subprocess import check_call
25 except ImportError:
26 import subprocess
27 def check_call(*popenargs, **kwargs):
28 retcode = subprocess.call(*popenargs, **kwargs)
29 if retcode:
30 cmd = kwargs.get("args")
31 if cmd is None:
32 cmd = popenargs[0]
33 raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
35 def check_call_noisy(cmd, *args, **kwargs):
36 print "Executing command:", cmd
37 check_call(cmd, *args, **kwargs)
39 def do_hg_pull(dir, repository, hg):
40 fulldir = os.path.join(topsrcdir, dir)
41 # clone if the dir doesn't exist, pull if it does
42 if not os.path.exists(fulldir):
43 fulldir = os.path.join(topsrcdir, dir)
44 check_call_noisy([hg, 'clone', repository, fulldir])
45 else:
46 cmd = [hg, 'pull', '-u', '-R', fulldir]
47 if repository is not None:
48 cmd.append(repository)
49 check_call_noisy(cmd)
51 def do_cvs_checkout(modules, tag, cvsroot, cvs):
52 """Check out a CVS directory.
53 modules is a list of directories to check out, e.g. ['nsprpub']
54 """
55 for module in modules:
56 (parent, leaf) = os.path.split(module)
57 check_call_noisy([cvs, '-d', cvsroot,
58 'checkout', '-P', '-r', tag, '-d', leaf,
59 'mozilla/%s' % module],
60 cwd=os.path.join(topsrcdir, parent))
62 o = OptionParser(usage="client.py [options] checkout")
63 o.add_option("-m", "--mozilla-repo", dest="mozilla_repo",
64 default=None,
65 help="URL of Mozilla repository to pull from (default: use hg default in .hg/hgrc)")
66 o.add_option("--skip-mozilla", dest="skip_mozilla",
67 action="store_true", default=False,
68 help="Skip pulling the Mozilla repository.")
70 o.add_option("-t", "--tamarin-repo", dest="tamarin_repo",
71 default=None,
72 help="URL of Tamarin repository to pull from (default: use hg default in js/tamarin/.hg/hgrc; or if that file doesn't exist, use \"" + DEFAULT_TAMARIN_REPO + "\".)")
73 o.add_option("--skip-tamarin", dest="skip_tamarin",
74 action="store_true", default=False,
75 help="Skip pulling the Tamarin repository.")
77 o.add_option("--skip-nspr", dest="skip_nspr",
78 action="store_true", default=False,
79 help="Skip pulling the NSPR repository.")
80 o.add_option("--skip-nss", dest="skip_nss",
81 action="store_true", default=False,
82 help="Skip pulling the NSS repository.")
84 o.add_option("--hg", dest="hg", default=os.environ.get('HG', 'hg'),
85 help="The location of the hg binary")
86 o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
87 help="The location of the cvs binary")
88 o.add_option("--cvsroot", dest="cvsroot",
89 default=os.environ.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
90 help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
93 def fixup_repo_options(options):
94 """ Check options.mozilla_repo and options.tamarin_repo values;
95 populate tamarin_repo if needed.
97 options.mozilla_repo and options.tamarin_repo are normally None.
98 This is fine-- our "hg pull" commands will omit the repo URL.
99 The exception is the initial checkout, which does an "hg clone"
100 for Tamarin. That command requires a repository URL.
103 if (options.mozilla_repo is None
104 and not os.path.exists(os.path.join(topsrcdir, '.hg'))):
105 o.print_help()
106 print
107 print "*** The -m option is required for the initial checkout."
108 sys.exit(2)
110 # Handle special case: initial checkout of Tamarin.
111 if (options.tamarin_repo is None
112 and not os.path.exists(os.path.join(topsrcdir, 'js', 'tamarin'))):
113 options.tamarin_repo = DEFAULT_TAMARIN_REPO
115 try:
116 (options, (action,)) = o.parse_args()
117 except ValueError:
118 o.print_help()
119 sys.exit(2)
121 fixup_repo_options(options)
123 if action in ('checkout', 'co'):
124 if not options.skip_nspr:
125 do_cvs_checkout(NSPR_DIRS, NSPR_CO_TAG, options.cvsroot, options.cvs)
127 if not options.skip_nss:
128 do_cvs_checkout(NSS_DIRS, NSS_CO_TAG, options.cvsroot, options.cvs)
130 if not options.skip_tamarin:
131 do_hg_pull('js/tamarin', options.tamarin_repo, options.hg)
133 if not options.skip_mozilla:
134 do_hg_pull('.', options.mozilla_repo, options.hg)
136 else:
137 o.print_help()
138 sys.exit(2)