Fix unpinned version to track upstream.

This is a serious bug, if a version is unpinned, it would become stuck at
whatever a local branch 'master' may point to. This is extremely bad when a
pinned dependency is unpinned on purpose, for example on a canary master. We
reproduced this problem on the chromium.swarm master by setting a custom_vars
swarming_revision to '', which then stopped syncing at the expected
origin/master commit but instead got stuck to what happened to be a local master
branch.

This happens on git dependencies if the main solution is using svn. This doesn't
happen on git checkouts using .DEPS.git due to bug 323233.

The issue looks like:
________ running 'git reset --hard HEAD' in '/path/src/tools/swarming_client'
HEAD is now at 4727bd5 Some commit
Checked out revision d908a546e28d1e9f85f5690cf6c3a080f06ba711

Note that HEAD and what is checked out do not match.

Also reduce the hardcoding of 'origin' by creating a variable named 'remote'.

R=petermayo@chromium.org
BUG=322961

Review URL: https://codereview.chromium.org/85473007

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@237332 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 65b4ba7..5607f85 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -800,12 +800,16 @@
     gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True)
 
   def tearDown(self):
-    StdoutCheck.tearDown(self)
-    TestCaseUtils.tearDown(self)
-    unittest.TestCase.tearDown(self)
-    rmtree(self.root_dir)
-    gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
-    gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
+    try:
+      rmtree(self.root_dir)
+      StdoutCheck.tearDown(self)
+      TestCaseUtils.tearDown(self)
+      unittest.TestCase.tearDown(self)
+    finally:
+      # TODO(maruel): Use auto_stub.TestCase.
+      gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
+      gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
+
 
 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
   def testDir(self):
@@ -824,6 +828,7 @@
         'pack',
         'UpdateSubmoduleConfig',
         'relpath',
+        'remote',
         'revert',
         'revinfo',
         'runhooks',
@@ -1039,7 +1044,7 @@
                  'Fix the conflict and run gclient again.\n'
                  'See \'man git-rebase\' for details.\n')
     self.assertRaisesError(exception, scm.update, options, (), [])
-    exception = ('\n____ . at refs/heads/master\n'
+    exception = ('\n____ . at refs/remotes/origin/master\n'
                  '\tYou have unstaged changes.\n'
                  '\tPlease commit, stash, or reset.\n')
     self.assertRaisesError(exception, scm.update, options, (), [])