Backed out changeset f4b12d9682b3 (bug 1317594) for breaking compat with Mercurial 3.7.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 11 Apr 2017 16:41:19 -0400
changeset 395815 8af03a505cf5f7dd942883f2cfb9eb1b68707788
parent 395814 af42f039717e4b4ffe43d5a131b1daf1e00ef9e4
child 395816 1c79bcfea67971696983deeadb0bc22f7158dd1e
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1317594
milestone54.0a2
backs outf4b12d9682b348fc77255aa21d75ccddcf2533d7
Backed out changeset f4b12d9682b3 (bug 1317594) for breaking compat with Mercurial 3.7.
testing/mozharness/external_tools/robustcheckout.py
--- a/testing/mozharness/external_tools/robustcheckout.py
+++ b/testing/mozharness/external_tools/robustcheckout.py
@@ -12,35 +12,33 @@ times and storage efficiency.
 from __future__ import absolute_import
 
 import contextlib
 import errno
 import functools
 import os
 import random
 import re
-import socket
 import time
 
 from mercurial.i18n import _
 from mercurial.node import hex
 from mercurial import (
     commands,
     error,
     exchange,
     extensions,
     cmdutil,
     hg,
-    pycompat,
     scmutil,
     util,
 )
 
-testedwith = '3.8 3.9 4.0 4.1'
-minimumhgversion = '3.8'
+testedwith = '3.7 3.8 3.9 4.0'
+minimumhgversion = '3.7'
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 
 
 if os.name == 'nt':
     import ctypes
 
@@ -223,60 +221,51 @@ def _docheckout(ui, url, dest, upstream,
             ui.warn('(attempting checkout from beginning)\n')
             return callself()
 
         raise
 
     # At this point we either have an existing working directory using
     # shared, pooled storage or we have nothing.
 
-    def handlenetworkfailure():
-        if networkattempts[0] >= networkattemptlimit:
-            raise error.Abort('reached maximum number of network attempts; '
-                              'giving up\n')
-
-        ui.warn('(retrying after network failure on attempt %d of %d)\n' %
-                (networkattempts[0], networkattemptlimit))
-
-        # Do a backoff on retries to mitigate the thundering herd
-        # problem. This is an exponential backoff with a multipler
-        # plus random jitter thrown in for good measure.
-        # With the default settings, backoffs will be:
-        # 1) 2.5 - 6.5
-        # 2) 5.5 - 9.5
-        # 3) 11.5 - 15.5
-        backoff = (2 ** networkattempts[0] - 1) * 1.5
-        jittermin = ui.configint('robustcheckout', 'retryjittermin', 1000)
-        jittermax = ui.configint('robustcheckout', 'retryjittermax', 5000)
-        backoff += float(random.randint(jittermin, jittermax)) / 1000.0
-        ui.warn('(waiting %.2fs before retry)\n' % backoff)
-        time.sleep(backoff)
-
-        networkattempts[0] += 1
-
-    def handlepullerror(e):
-        """Handle an exception raised during a pull.
+    def handlepullabort(e):
+        """Handle an error.Abort raised during a pull.
 
         Returns True if caller should call ``callself()`` to retry.
         """
-        if isinstance(e, error.Abort):
-            if e.args[0] == _('repository is unrelated'):
-                ui.warn('(repository is unrelated; deleting)\n')
-                destvfs.rmtree(forcibly=True)
+        if e.args[0] == _('repository is unrelated'):
+            ui.warn('(repository is unrelated; deleting)\n')
+            destvfs.rmtree(forcibly=True)
+            return True
+        elif e.args[0].startswith(_('stream ended unexpectedly')):
+            ui.warn('%s\n' % e.args[0])
+            if networkattempts[0] < networkattemptlimit:
+                ui.warn('(retrying after network failure on attempt %d of %d)\n' %
+                        (networkattempts[0], networkattemptlimit))
+
+                # Do a backoff on retries to mitigate the thundering herd
+                # problem. This is an exponential backoff with a multipler
+                # plus random jitter thrown in for good measure.
+                # With the default settings, backoffs will be:
+                # 1) 2.5 - 6.5
+                # 2) 5.5 - 9.5
+                # 3) 11.5 - 15.5
+                backoff = (2 ** networkattempts[0] - 1) * 1.5
+                jittermin = ui.configint('robustcheckout', 'retryjittermin', 1000)
+                jittermax = ui.configint('robustcheckout', 'retryjittermax', 5000)
+                backoff += float(random.randint(jittermin, jittermax)) / 1000.0
+                ui.warn('(waiting %.2fs before retry)\n' % backoff)
+                time.sleep(backoff)
+
+                networkattempts[0] += 1
+
                 return True
-            elif e.args[0].startswith(_('stream ended unexpectedly')):
-                ui.warn('%s\n' % e.args[0])
-                # Will raise if failure limit reached.
-                handlenetworkfailure()
-                return True
-        elif isinstance(e, pycompat.urlerr.urlerror):
-            if isinstance(e.reason, socket.error):
-                ui.warn('socket error: %s\n' % e.reason)
-                handlenetworkfailure()
-                return True
+            else:
+                raise error.Abort('reached maximum number of network attempts; '
+                                  'giving up\n')
 
         return False
 
     created = False
 
     if not destvfs.exists():
         # Ensure parent directories of destination exist.
         # Mercurial 3.8 removed ensuredirs and made makedirs race safe.
@@ -290,18 +279,18 @@ def _docheckout(ui, url, dest, upstream,
 
         if upstream:
             ui.write('(cloning from upstream repo %s)\n' % upstream)
         cloneurl = upstream or url
 
         try:
             res = hg.clone(ui, {}, cloneurl, dest=dest, update=False,
                            shareopts={'pool': sharebase, 'mode': 'identity'})
-        except (error.Abort, pycompat.urlerr.urlerror) as e:
-            if handlepullerror(e):
+        except error.Abort as e:
+            if handlepullabort(e):
                 return callself()
             raise
         except error.RepoError as e:
             return handlerepoerror(e)
         except error.RevlogError as e:
             ui.warn('(repo corruption: %s; deleting shared store)\n' % e.message)
             deletesharedstore()
             return callself()
@@ -349,18 +338,18 @@ def _docheckout(ui, url, dest, upstream,
                         (branch, checkoutrevision))
 
             if checkoutrevision in repo:
                 ui.warn('(revision already present locally; not pulling)\n')
             else:
                 pullop = exchange.pull(repo, remote, heads=pullrevs)
                 if not pullop.rheads:
                     raise error.Abort('unable to pull requested revision')
-        except (error.Abort, pycompat.urlerr.urlerror) as e:
-            if handlepullerror(e):
+        except error.Abort as e:
+            if handlepullabort(e):
                 return callself()
             raise
         except error.RepoError as e:
             return handlerepoerror(e)
         except error.RevlogError as e:
             ui.warn('(repo corruption: %s; deleting shared store)\n' % e.message)
             deletesharedstore()
             return callself()