bug 465521 - client.py needs a way to update the default repo for m-c, add move_to_stable functionality to switch comm-central pulls to mozilla-1.9.1 branch, r=Standard8,davida,KaiRo
authorJustin Wood <bugspam.Callek@gmail.com>
Mon, 01 Dec 2008 18:27:18 +0100
changeset 1280 87c1dc594c9b9a8f4af5f93943fe64cf0ce7d123
parent 1279 adcceee5712d614b0b02845958166f4834954820
child 1282 9e1e39f1e7e9bf5a743267503b5f0e7c0ac90341
push id1003
push userkairo@kairo.at
push dateMon, 01 Dec 2008 17:29:30 +0000
treeherdercomm-central@87c1dc594c9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, davida, KaiRo
bugs465521
bug 465521 - client.py needs a way to update the default repo for m-c, add move_to_stable functionality to switch comm-central pulls to mozilla-1.9.1 branch, r=Standard8,davida,KaiRo
.hgignore
client.py
--- a/.hgignore
+++ b/.hgignore
@@ -10,15 +10,19 @@
 ^mozconfig$
 ^\.mozconfig\.mk$
 ^\.mozconfig\.out$
 ^configure$
 ^config\.cache$
 ^config\.log$
 ^ID$
 
+#treestate
+^.treestate$
+
 # Build directories
 ^obj-
 ^objdir-
 
 # directories we check out from other repositories
 ^directory/c-sdk$
 ^mozilla$
+^.mozilla-trunk$
--- a/client.py
+++ b/client.py
@@ -9,47 +9,115 @@ VENKMAN_CO_TAG = 'HEAD'
 EXTENSION_DIRS = ('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_REPO = 'http://hg.mozilla.org/releases/mozilla-1.9.1/'
 DEFAULT_MOZILLA_REV = "tip"
+
+# 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 = "tip"
 
 import os
 import sys
 import datetime
 from optparse import OptionParser
 
 topsrcdir = os.path.dirname(__file__)
 if topsrcdir == '':
     topsrcdir = '.'
 
+TREE_STATE_FILE = os.path.join(topsrcdir, '.treestate')
+
 try:
     from subprocess import check_call
 except ImportError:
     import subprocess
     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 check_call_noisy(cmd, *args, **kwargs):
     print "Executing command:", cmd
     check_call(cmd, *args, **kwargs)
 
+def repo_config():
+    import ConfigParser
+    config = ConfigParser.ConfigParser()
+    config.read([TREE_STATE_FILE])
+    if not config.has_section('default'):
+      config.add_section('default')
+    config.set('default', 'src_update_version', '1')
+
+    # Write this file out
+    f = open(TREE_STATE_FILE, 'w')
+    try:
+      config.write(f)
+    finally:
+      f.close()
+
+def move_to_stable():
+    mozilla_path = os.path.join(topsrcdir, 'mozilla')
+    if not os.path.exists(mozilla_path):
+      return
+    if os.path.exists(TREE_STATE_FILE):
+      return
+
+    import ConfigParser, re
+    config = ConfigParser.ConfigParser()
+    config.read([os.path.join(mozilla_path, '.hg', 'hgrc')])
+
+    if not config.has_option('paths', 'default'):
+      return
+
+    #Compile the m-c regex
+    m_c_regex = re.compile(MOZILLA_TRUNK_REPO_REGEXP, re.I)
+    match = m_c_regex.match(config.get('paths', 'default'))
+    if not match:
+      return # We are not pulling from m-c, do nothing
+
+    config.set('paths', 'default',
+               "%s://hg.mozilla.org/releases/mozilla-1.9.1/" % match.group(1) )
+
+    if config.has_option('paths', 'default-push'):
+      match = m_c_regex.match(config.get('paths', 'default-push'))
+      if match: # failure is ok
+        config.set('paths', 'default-push',
+                   "%s://hg.mozilla.org/releases/mozilla-1.9.1/" % match.group(1) )
+
+    hgopts = []
+    if options.hgopts:
+        hgopts = options.hgopts.split()
+
+    mozilla_trunk_path = os.path.join(topsrcdir, '.mozilla-trunk')
+    print "Moving mozilla to .mozilla-trunk..."
+    os.rename(mozilla_path, mozilla_trunk_path)
+    check_call_noisy([options.hg, 'clone', '-r', MOZILLA_BASE_REV] + hgopts + [mozilla_trunk_path, mozilla_path])
+
+    #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 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)
@@ -172,16 +240,19 @@ def fixup_repo_options(options):
         options.inspector_repo = DEFAULT_INSPECTOR_REPO
 
 try:
     (options, (action,)) = o.parse_args()
 except ValueError:
     o.print_help()
     sys.exit(2)
 
+move_to_stable()
+repo_config()
+
 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)