Bug 1287439 - Update robustcheckout extension with upstream; r=Callek FENNEC_48_0b9_BUILD1 FENNEC_48_0b9_RELEASE
authorGregory Szorc <gps@mozilla.com>
Mon, 18 Jul 2016 10:29:29 -0700
changeset 7023 d3820907e7712ad59d2e07c7c47dcfc9c2a7b696
parent 7021 2c012bef149a86a32f375346da8636c7fd586add
child 7024 92e6e5d32dde32365fb9ccc18b05271753fe4f09
child 7025 e4c4c8f0e430fd4ed940747fae85973837d29cd6
push id93
push userbmo:rail@mozilla.com
push dateMon, 18 Jul 2016 19:00:06 +0000
reviewersCallek
bugs1287439
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: 2rczw0BNL99
hgext/robustcheckout.py
--- a/hgext/robustcheckout.py
+++ b/hgext/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)