Bug 1287439 - Update robustcheckout extension with upstream; r=Callek
authorGregory Szorc <gps@mozilla.com>
Mon, 18 Jul 2016 10:24:27 -0700
changeset 330499 f89771c94b4ab6dc18a76d14433ae52dc219d4ae
parent 330498 895873ee9b11fdb024fc133cdc6558d97038e0d0
child 330500 2a69345f4f4eeb804e6a96c70f086f10e9849724
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCallek
bugs1287439
milestone50.0a1
Bug 1287439 - Update robustcheckout extension with upstream; r=Callek Synchronized with hgext/robustcheckout/__init.py from https://hg.mozilla.org/hgcustom/version-control-tools at revision d2140637eaf3f91fefa7c2f44cbaabf4c19faeb3. MozReview-Commit-ID: 676o5IVE536
testing/mozharness/external_tools/robustcheckout.py
--- a/testing/mozharness/external_tools/robustcheckout.py
+++ b/testing/mozharness/external_tools/robustcheckout.py
@@ -13,16 +13,17 @@ from __future__ import absolute_import
 
 import contextlib
 import errno
 import functools
 import os
 import re
 
 from mercurial.i18n import _
+from mercurial.node import hex
 from mercurial import (
     commands,
     error,
     exchange,
     extensions,
     cmdutil,
     hg,
     scmutil,
@@ -254,27 +255,37 @@ def _docheckout(ui, url, dest, upstream,
     if revision and revision in repo:
         ctx = repo[revision]
 
         if not ctx.hex().startswith(revision):
             raise error.Abort('--revision argument is ambiguous',
                               hint='must be the first 12+ characters of a '
                                    'SHA-1 fragment')
 
+        checkoutrevision = ctx.hex()
         havewantedrev = True
 
     if not havewantedrev:
         ui.write('(pulling to obtain %s)\n' % (revision or branch,))
 
         try:
             remote = hg.peer(repo, {}, url)
             pullrevs = [remote.lookup(revision or branch)]
-            pullop = exchange.pull(repo, remote, heads=pullrevs)
-            if not pullop.rheads:
-                raise error.Abort('unable to pull requested revision')
+            checkoutrevision = hex(pullrevs[0])
+            if branch:
+                ui.warn('(remote resolved %s to %s; '
+                        'result is not deterministic)\n' %
+                        (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 as e:
             if e.message == _('repository is unrelated'):
                 ui.warn('(repository is unrelated; deleting)\n')
                 destvfs.rmtree(forcibly=True)
                 return callself()
 
             raise
         except error.RepoError as e:
@@ -298,21 +309,20 @@ def _docheckout(ui, url, dest, upstream,
         if purgeext.purge(ui, repo, all=True, abort_on_err=True,
                           # The function expects all arguments to be
                           # defined.
                           **{'print': None, 'print0': None, 'dirs': None,
                              'files': None}):
             raise error.Abort('error purging')
 
     # Update the working directory.
-    if commands.update(ui, repo, rev=revision or branch, clean=True):
+    if commands.update(ui, repo, rev=checkoutrevision, clean=True):
         raise error.Abort('error updating')
 
-    ctx = repo[revision or branch]
-    ui.write('updated to %s\n' % ctx.hex())
+    ui.write('updated to %s\n' % checkoutrevision)
     return None
 
 
 def extsetup(ui):
     # Ensure required extensions are loaded.
     for ext in ('purge', 'share'):
         try:
             extensions.find(ext)