bug 381809 - get rid of client.py's update, make checkout smarter
authorluser@bluck
Thu, 24 May 2007 00:05:33 -0400
changeset 848 a0b38e534c243ce8eb045b24202edba60b82714a
parent 847 52123bb691069bf3295e76bc02caf0b83723d689
child 849 e2cabae2f338b065664723f2c13f40ef174eb53d
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs381809
milestone1.9a4pre
bug 381809 - get rid of client.py's update, make checkout smarter
client.py
--- 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)