Bug 482686 - comm-central should pull Venkman from hg rather than CVS; (Av5) Pull Hg instead of cvs; r=(bugspam.Callek + kairo)
authorSerge Gautherie <sgautherie.bz@free.fr>
Thu, 19 Mar 2009 16:35:42 +0100
changeset 2240 c09d5a915273974794927e305b01fb624ebd661d
parent 2239 d2a8e9f48fa3c2f761fb763d23b01b69b34e1cde
child 2241 8b894b596e6ebffabb259cf28956b36cb844a4cf
push idunknown
push userunknown
push dateunknown
bugs482686
Bug 482686 - comm-central should pull Venkman from hg rather than CVS; (Av5) Pull Hg instead of cvs; r=(bugspam.Callek + kairo)
client.py
--- a/client.py
+++ b/client.py
@@ -1,34 +1,36 @@
 #!/usr/bin/python
 
-EXTENSION_CO_TAG = 'HEAD'
 LDAPCSDK_CO_TAG = 'LDAPCSDK_6_0_6_RTM'
 
 CHATZILLA_CO_TAG = 'HEAD'
-VENKMAN_CO_TAG = 'HEAD'
 
 LDAPCSDK_DIRS = ('directory/c-sdk',)
 
 CHATZILLA_DIRS = ('extensions/irc',)
-VENKMAN_DIRS = ('extensions/venkman',)
 
 DEFAULT_COMM_REV = "default"
+
 # URL of the default hg repository to clone for Mozilla.
 DEFAULT_MOZILLA_REPO = 'http://hg.mozilla.org/releases/mozilla-1.9.1/'
 DEFAULT_MOZILLA_REV = "default"
 
 # REGEX to match against, $1 should refer to protocol scheme
 MOZILLA_TRUNK_REPO_REGEXP = "(ssh|http|https):\/\/hg\.mozilla\.org\/mozilla-central\/?$"
 MOZILLA_BASE_REV = "GECKO_1_9_1_BASE"
 
 # URL of the default hg repository to clone for inspector.
 DEFAULT_INSPECTOR_REPO = 'http://hg.mozilla.org/dom-inspector/'
 DEFAULT_INSPECTOR_REV = "default"
 
+# URL of the default hg repository to clone for Venkman.
+DEFAULT_VENKMAN_REPO = 'http://hg.mozilla.org/venkman/'
+DEFAULT_VENKMAN_REV = "default"
+
 import os
 import sys
 import datetime
 from optparse import OptionParser
 
 topsrcdir = os.path.dirname(__file__)
 if topsrcdir == '':
     topsrcdir = '.'
@@ -107,16 +109,26 @@ def move_to_stable():
     #Rewrite hgrc for new local mozilla repo based on pre-existing hgrc
     # but with new values
     f = open(os.path.join(topsrcdir, 'mozilla', '.hg', 'hgrc'), 'w')
     try:
       config.write(f)
     finally:
       f.close()
 
+def backup_cvs_venkman():
+    venkmanpath = os.path.join(topsrcdir, 'mozilla', 'extensions', 'venkman')
+    # Do nothing if there is no Venkman cvs directory.
+    if not os.path.exists(os.path.join(venkmanpath, 'CVS')):
+        return
+
+    venkmancvspath = venkmanpath + '-cvs'
+    print "Moving venkman to venkman-cvs..."
+    os.rename(venkmanpath, venkmancvspath)
+
 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
     hgopts = []
     if options.hgopts:
         hgopts = options.hgopts.split()
     if not os.path.exists(fulldir):
         fulldir = os.path.join(topsrcdir, dir)
@@ -131,17 +143,17 @@ def do_hg_pull(dir, repository, hg, rev)
         cmd = [hg, 'update', '-v', '-r', rev, '-R', fulldir ] + hgopts
     else:
         cmd = [hg, 'update', '-r', rev, '-R', fulldir ] + hgopts
     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.
+    """Check out a CVS directory into the checkoutdir subdirectory.
     modules is a list of directories to check out, e.g. ['extensions/irc']
     """
     for module in modules:
         (parent, leaf) = os.path.split(module)
         print "CVS checkout begin: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
         if tag == 'HEAD':
             check_call_noisy([cvs, '-d', cvsroot, '-q',
                               'checkout', '-P', '-A', '-d', leaf,
@@ -183,22 +195,30 @@ o.add_option("--skip-inspector", dest="s
              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-ldap", dest="skip_ldap",
              action="store_true", default=False,
              help="Skip pulling LDAP 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("--venkman-repo", dest = "venkman_repo",
+             default = None,
+             help = "URL of Venkman repository to pull from (default: use hg default in mozilla/extensions/venkman/.hg/hgrc; or if that file doesn't exist, use \"" + DEFAULT_VENKMAN_REPO + "\".)")
 o.add_option("--skip-venkman", dest="skip_venkman",
              action="store_true", default=False,
              help="Skip pulling the Venkman repository.")
+o.add_option("--venkman-rev", dest = "venkman_rev",
+             default = DEFAULT_VENKMAN_REV,
+             help = "Revision of Venkman repository to update to. Default: \"" + DEFAULT_VENKMAN_REV + "\"")
 
 o.add_option("--hg", dest="hg", default=os.environ.get('HG', 'hg'),
              help="The location of the hg binary")
 o.add_option("--cvs", dest="cvs", default=os.environ.get('CVS', 'cvs'),
              help="The location of the cvs binary")
 o.add_option("--cvsroot", dest="cvsroot",
              default=os.environ.get('CVSROOT', ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'),
              help="The CVSROOT (default: :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot")
@@ -230,49 +250,61 @@ def fixup_repo_options(options):
             and not os.path.exists(os.path.join(topsrcdir, 'mozilla'))):
         options.mozilla_repo = DEFAULT_MOZILLA_REPO
 
     # Handle special case: initial checkout of inspector.
     if (options.inspector_repo is None
             and not os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions', 'inspector'))):
         options.inspector_repo = DEFAULT_INSPECTOR_REPO
 
+    # Handle special case: initial checkout of Venkman.
+    if (options.venkman_repo is None
+            and not os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions', 'venkman'))):
+        options.venkman_repo = DEFAULT_VENKMAN_REPO
+
 try:
     (options, (action,)) = o.parse_args()
 except ValueError:
     o.print_help()
     sys.exit(2)
 
 move_to_stable()
 repo_config()
 
+backup_cvs_venkman()
+
 fixup_repo_options(options)
 
 if action in ('checkout', 'co'):
     if not options.skip_comm:
         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, options.mozilla_rev)
 
+    # Check whether destination directory exists for these extensions.
+    if (not options.skip_chatzilla or not options.skip_inspector or \
+                not options.skip_venkman) and \
+            not os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
+        # Don't create the directory: Mozilla repository should provide it...
+        print >>sys.stderr, "Warning: mozilla/extensions directory does not exist; ChatZilla, DOM Inspector and/or Venkman could not be checked out."
+        # Abort checking out dependent extensions.
+        options.skip_chatzilla = \
+        options.skip_inspector = \
+        options.skip_venkman = \
+            True
+
     if not options.skip_inspector:
+        # No cvs/hg check needed as DOM Inspector was part (and removed from)
+        # mozilla hg repository.
         do_hg_pull(os.path.join('mozilla', 'extensions', 'inspector'), options.inspector_repo, options.hg, options.inspector_rev)
 
     if not options.skip_ldap:
         do_cvs_checkout(LDAPCSDK_DIRS, LDAPCSDK_CO_TAG, options.cvsroot, options.cvs, '')
 
     if not options.skip_chatzilla:
-        if os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
-          do_cvs_checkout(CHATZILLA_DIRS, CHATZILLA_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
-        else:
-          print >>sys.stderr, "Warning: mozilla/extensions does not exist, ChatZilla could not be checked out."
-          pass
+        do_cvs_checkout(CHATZILLA_DIRS, CHATZILLA_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
 
     if not options.skip_venkman:
-        if os.path.exists(os.path.join(topsrcdir, 'mozilla', 'extensions')):
-          do_cvs_checkout(VENKMAN_DIRS, VENKMAN_CO_TAG, options.cvsroot, options.cvs, 'mozilla')
-        else:
-          print >>sys.stderr, "Warning: mozilla/extensions does not exist, Venkman could not be checked out."
-          pass
-
+        do_hg_pull(os.path.join('mozilla', 'extensions', 'venkman'), options.venkman_repo, options.hg, options.venkman_rev)
 else:
     o.print_help()
     sys.exit(2)