Bug 451811, comm-central's client.py needs ability to pull specific revisions/tags
authorJustin Wood <Callek@gmail.com>
Fri, 29 Aug 2008 10:40:21 -0400
changeset 223 abb590b3397d5b030efcee393e4f7633c884fcb0
parent 222 b24b58bc9e71ff289b522d88c23fbd0f3a7d93a4
child 224 cfaac96a1c737c12d74660eac3ee4e69228d7317
push id198
push userCallek@gmail.com
push dateFri, 29 Aug 2008 14:40:43 +0000
treeherdercomm-central@abb590b3397d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs451811
Bug 451811, comm-central's client.py needs ability to pull specific revisions/tags r=KaiRo
client.py
--- a/client.py
+++ b/client.py
@@ -10,20 +10,23 @@ VENKMAN_CO_TAG = 'HEAD'
 CALENDAR_DIRS = ('calendar',)
 EXTENSION_DIRS = ('extensions/typeaheadfind',
                   'extensions/wallet',)
 LDAPCSDK_DIRS = ('directory/c-sdk',)
 
 CHATZILLA_DIRS = ('extensions/irc',)
 VENKMAN_DIRS = ('extensions/venkman',)
 
+DEFAULT_COMM_REV = "tip"
 # URL of the default hg repository to clone for Mozilla.
 DEFAULT_MOZILLA_REPO = 'http://hg.mozilla.org/mozilla-central/'
+DEFAULT_MOZILLA_REV = "tip"
 # URL of the default hg repository to clone for inspector.
 DEFAULT_INSPECTOR_REPO = 'http://hg.mozilla.org/dom-inspector/'
+DEFAULT_INSPECTOR_REV = "tip"
 
 import os
 import sys
 import datetime
 from optparse import OptionParser
 
 topsrcdir = os.path.dirname(__file__)
 if topsrcdir == '':
@@ -40,30 +43,33 @@ except ImportError:
             if cmd is None:
                 cmd = popenargs[0]
                 raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
 
 def check_call_noisy(cmd, *args, **kwargs):
     print "Executing command:", cmd
     check_call(cmd, *args, **kwargs)
 
-def do_hg_pull(dir, repository, hg):
+def do_hg_pull(dir, repository, hg, rev):
     fulldir = os.path.join(topsrcdir, dir)
     # clone if the dir doesn't exist, pull if it does
     if not os.path.exists(fulldir):
         fulldir = os.path.join(topsrcdir, dir)
         check_call_noisy([hg, 'clone', repository, fulldir])
     else:
-        if options.verbose:
-            cmd = [hg, 'pull', '-u', '-v', '-R', fulldir]
-        else:
-            cmd = [hg, 'pull', '-u', '-R', fulldir]
+        cmd = [hg, 'pull', '-R', fulldir]
         if repository is not None:
             cmd.append(repository)
         check_call_noisy(cmd)
+    # update to specific revision
+    if options.verbose:
+        cmd = [hg, 'update', '-v', '-r', rev, '-R', fulldir]
+    else:
+        cmd = [hg, 'update', '-r', rev, '-R', fulldir]
+    check_call_noisy(cmd)
     check_call([hg, 'parent', '-R', fulldir,
                 '--template=Updated to revision {node}.\n'])
 
 def do_cvs_checkout(modules, tag, cvsroot, cvs, checkoutdir):
     """Check out a CVS directory into the mozilla/ subdirectory.
     modules is a list of directories to check out, e.g. ['extensions/irc']
     """
     for module in modules:
@@ -83,30 +89,39 @@ def do_cvs_checkout(modules, tag, cvsroo
 
 o = OptionParser(usage="client.py [options] checkout")
 o.add_option("-m", "--comm-repo", dest="comm_repo",
              default=None,
              help="URL of comm (Calendar/Mail/Suite) repository to pull from (default: use hg default in .hg/hgrc)")
 o.add_option("--skip-comm", dest="skip_comm",
              action="store_true", default=False,
              help="Skip pulling the comm (Calendar/Mail/Suite) repository.")
+o.add_option("--comm-rev", dest="comm_rev",
+             default=DEFAULT_COMM_REV,
+             help="Revision of comm (Calendar/Mail/Suite) repository to update to. Default: \"" + DEFAULT_COMM_REV + "\"")
 
 o.add_option("-z", "--mozilla-repo", dest="mozilla_repo",
              default=None,
              help="URL of Mozilla repository to pull from (default: use hg default in mozilla/.hg/hgrc; or if that file doesn't exist, use \"" + DEFAULT_MOZILLA_REPO + "\".)")
 o.add_option("--skip-mozilla", dest="skip_mozilla",
              action="store_true", default=False,
              help="Skip pulling the Mozilla repository.")
+o.add_option("--mozilla-rev", dest="mozilla_rev",
+             default=DEFAULT_MOZILLA_REV,
+             help="Revision of Mozilla repository to update to. Default: \"" + DEFAULT_MOZILLA_REV + "\"")
 
 o.add_option("--inspector-repo", dest="inspector_repo",
              default=None,
              help="URL of DOM inspector repository to pull from (default: use hg default in mozilla/extensions/inspector/.hg/hgrc; or if that file doesn't exist, use \"" + DEFAULT_INSPECTOR_REPO + "\".)")
 o.add_option("--skip-inspector", dest="skip_inspector",
              action="store_true", default=False,
              help="Skip pulling the DOM inspector repository.")
+o.add_option("--inspector-rev", dest="inspector_rev",
+             default=DEFAULT_INSPECTOR_REV,
+             help="Revision of DOM inspector repository to update to. Default: \"" + DEFAULT_INSPECTOR_REV + "\"")
 
 o.add_option("--skip-cvs", dest="skip_cvs",
              action="store_true", default=False,
              help="Skip pulling the old directories from the Mozilla CVS repository.")
 o.add_option("--skip-chatzilla", dest="skip_chatzilla",
              action="store_true", default=False,
              help="Skip pulling the ChatZilla repository.")
 o.add_option("--skip-venkman", dest="skip_venkman",
@@ -160,23 +175,23 @@ try:
 except ValueError:
     o.print_help()
     sys.exit(2)
 
 fixup_repo_options(options)
 
 if action in ('checkout', 'co'):
     if not options.skip_comm:
-        do_hg_pull('.', options.comm_repo, options.hg)
+        do_hg_pull('.', options.comm_repo, options.hg, options.comm_rev)
 
     if not options.skip_mozilla:
-        do_hg_pull('mozilla', options.mozilla_repo, options.hg)
+        do_hg_pull('mozilla', options.mozilla_repo, options.hg, options.mozilla_rev)
 
     if not options.skip_inspector:
-        do_hg_pull(os.path.join('mozilla', 'extensions', 'inspector'), options.inspector_repo, options.hg)
+        do_hg_pull(os.path.join('mozilla', 'extensions', 'inspector'), options.inspector_repo, options.hg, options.inspector_rev)
 
     if not options.skip_cvs:
         if not options.skip_calendar:
           do_cvs_checkout(CALENDAR_DIRS, CALENDAR_CO_TAG, options.cvsroot, options.cvs, '')
         do_cvs_checkout(LDAPCSDK_DIRS, LDAPCSDK_CO_TAG, options.cvsroot, options.cvs, '')
         if os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
           do_cvs_checkout(EXTENSION_DIRS, EXTENSION_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
         else: