--- a/client.py
+++ b/client.py
@@ -24,39 +24,40 @@ except ImportError:
def check_call(*popenargs, **kwargs):
retcode = subprocess.call(*popenargs, **kwargs)
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
-def do_hg_checkout(dir, remote, hgroot, hg):
- fulldir = os.path.join(topsrcdir, dir)
- repository = '%s/%s' % (hgroot, remote)
- check_call([hg, 'clone', repository, fulldir])
-
def do_hg_pull(dir, remote, hgroot, hg):
fulldir = os.path.join(topsrcdir, dir)
- repository = '%s/%s' % (hgroot, remote)
- cmd = [hg, 'pull', '-R', fulldir, repository]
- check_call(cmd)
+ # clone if the dir doesn't exist, pull if it does
+ if not os.path.exists(fulldir):
+ fulldir = os.path.join(topsrcdir, dir)
+ repository = '%s/%s' % (hgroot, remote)
+ check_call([hg, 'clone', repository, fulldir])
+ else:
+ repository = '%s/%s' % (hgroot, remote)
+ cmd = [hg, 'pull', '-u', '-R', fulldir, repository]
+ check_call(cmd)
def do_cvs_checkout(modules, tag, cvsroot, cvs):
"""Check out a CVS directory.
modules is a list of directories to check out, e.g. ['nsprpub']
"""
for module in modules:
(parent, leaf) = os.path.split(module)
check_call([cvs, '-d', cvsroot,
'checkout', '-P', '-r', tag, '-d', leaf,
'mozilla/%s' % module],
cwd=os.path.join(topsrcdir, parent))
-o = OptionParser(usage="client.py [options] {checkout|update}")
+o = OptionParser(usage="client.py [options] checkout")
o.add_option("-m", "--mozilla-repo", dest="mozilla_repo",
default="mozilla-central",
help="Specify the Mozilla repository to pull from, default 'mozilla-central'")
o.add_option("-t", "--tamarin-repo", dest="tamarin_repo",
default="tamarin-central",
help="Specify the Tamarin repository to pull from, default 'tamarin-central'")
o.add_option("--hg", dest="hg", default=os.environ.get('HG', 'hg'),
help="The location of the hg binary")
@@ -72,17 +73,13 @@ try:
(options, (action,)) = o.parse_args()
except ValueError:
o.print_help()
sys.exit(2)
if action in ('checkout', 'co'):
do_cvs_checkout(NSPR_DIRS, NSPR_CO_TAG, options.cvsroot, options.cvs)
do_cvs_checkout(NSS_DIRS, NSS_CO_TAG, options.cvsroot, options.cvs)
- do_hg_checkout('js/tamarin', options.tamarin_repo, options.hgroot, options.hg)
-elif action in ('update', 'up', 'pull'):
- do_cvs_checkout(NSPR_DIRS, NSPR_CO_TAG, options.cvsroot, options.cvs)
- do_cvs_checkout(NSS_DIRS, NSS_CO_TAG, options.cvsroot, options.cvs)
do_hg_pull('js/tamarin', options.tamarin_repo, options.hgroot, options.hg)
do_hg_pull('.', options.mozilla_repo, options.hgroot, options.hg)
else:
o.print_help()
sys.exit(2)