Bug 538528 - Allow client.py network attempts to restart itself in case of failures; (Bv1a) Never retry 'hg update', Reorder/Rewrite some code, Improve documentation.
authorSerge Gautherie <sgautherie.bz@free.fr>
Wed, 17 Mar 2010 14:59:43 +0100
changeset 5195 c3a965df93aee8b4612e03d34a89d0cd084878a7
parent 5194 e8c5c544d57cf3929decabb70246b853505644e3
child 5196 8a5bc9cd07c37518082a2ccdbf68cfc970b4eced
push idunknown
push userunknown
push dateunknown
bugs538528
Bug 538528 - Allow client.py network attempts to restart itself in case of failures; (Bv1a) Never retry 'hg update', Reorder/Rewrite some code, Improve documentation. r=gozer.
client.py
--- a/client.py
+++ b/client.py
@@ -193,24 +193,24 @@ def switch_mozilla_repo():
 
     if config.has_option('paths', 'default-push'):
       match = moz_old_regex.match(config.get('paths', 'default-push'))
       # Do not update this property if not pushing to Mozilla trunk.
       if match:
         config.set('paths', 'default-push',
                    SWITCH_MOZILLA_REPO_REPLACE % match.group(1) )
 
+    hgcloneopts = []
+    if options.hgcloneopts:
+        hgcloneopts = options.hgcloneopts.split()
+
     hgopts = []
     if options.hgopts:
         hgopts = options.hgopts.split()
 
-    hgcloneopts = []
-    if options.hgcloneopts:
-        hgcloneopts = options.hgcloneopts.split()
-
     backup_mozilla_path = os.path.join(topsrcdir, SWITCH_MOZILLA_REPO_BACKUP_LOCATION)
     print "Moving mozilla to " + SWITCH_MOZILLA_REPO_BACKUP_LOCATION + "..."
     try:
         os.rename(mozilla_path, backup_mozilla_path)
     except:
         # Print the exception without its traceback.
         sys.excepthook(sys.exc_info()[0], sys.exc_info()[1], None)
         sys.exit("Error: Mozilla directory renaming failed!")
@@ -256,41 +256,46 @@ def backup_cvs_extension(extensionName, 
     try:
         os.rename(extensionPath, extensionBackupPath)
     except:
         # Print the exception without its traceback.
         sys.excepthook(sys.exc_info()[0], sys.exc_info()[1], None)
         sys.exit("Error: %s directory renaming failed!" % extensionName)
 
 def do_hg_pull(dir, repository, hg, rev):
+    """Clone if the dir doesn't exist, pull if it does.
+    """
+
     fulldir = os.path.join(topsrcdir, dir)
-    # clone if the dir doesn't exist, pull if it does
+
+    hgcloneopts = []
+    if options.hgcloneopts:
+        hgcloneopts = options.hgcloneopts.split()
+
     hgopts = []
     if options.hgopts:
         hgopts = options.hgopts.split()
     
-    hgcloneopts = []
-    if options.hgcloneopts:
-        hgcloneopts = options.hgcloneopts.split()
-
     if not os.path.exists(fulldir):
         fulldir = os.path.join(topsrcdir, dir)
         check_call_noisy([hg, 'clone'] + hgcloneopts + hgopts + [repository, fulldir],
                          retryMax=options.retries)
     else:
         cmd = [hg, 'pull', '-R', fulldir] + hgopts
         if repository is not None:
             cmd.append(repository)
         check_call_noisy(cmd, retryMax=options.retries)
+
     # update to specific revision
+    cmd = [hg, 'update', '-r', rev, '-R', fulldir ] + hgopts
     if options.verbose:
-        cmd = [hg, 'update', '-v', '-r', rev, '-R', fulldir ] + hgopts
-    else:
-        cmd = [hg, 'update', '-r', rev, '-R', fulldir ] + hgopts
-    check_call_noisy(cmd, retryMax=options.retries)
+        cmd.append('-v')
+    # Explicitly never retry 'hg update': otherwise any merge failures are ignored.
+    check_call_noisy(cmd, retryMax=0)
+
     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 checkoutdir subdirectory.
     modules is a list of directories to check out, e.g. ['extensions/irc']
     """
     for module in modules:
@@ -373,17 +378,17 @@ o.add_option("--venkman-rev", dest = "ve
 o.add_option("--hg", dest="hg", default=os.environ.get('HG', 'hg'),
              help="The location of the hg binary")
 o.add_option("-v", "--verbose", dest="verbose",
              action="store_true", default=False,
              help="Enable verbose output on hg updates")
 o.add_option("--hg-options", dest="hgopts",
              help="Pass arbitrary options to hg commands (i.e. --debug, --time)")
 o.add_option("--hg-clone-options", dest="hgcloneopts",
-             help="Pass arbitrary options to hg clone commands (i.e. --debug, --time)")
+             help="Pass arbitrary options to hg clone commands (i.e. --uncompressed)")
 
 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")
 
 o.add_option("--retries", dest="retries", type="int", metavar="NUM",