| Index: gclient_scm.py
|
| diff --git a/gclient_scm.py b/gclient_scm.py
|
| index f5a434b1edaada44cfcc93e64cf897f2d3ca5ae7..7b644a1962b55c5758c33914c5d6473a954ed73c 100644
|
| --- a/gclient_scm.py
|
| +++ b/gclient_scm.py
|
| @@ -215,6 +215,13 @@ class GitWrapper(SCMWrapper):
|
| def GetCheckoutRoot(self):
|
| return scm.GIT.GetCheckoutRoot(self.checkout_path)
|
|
|
| + def GetRemoteURL(self, options, cwd=None):
|
| + try:
|
| + return self._Capture(['config', 'remote.origin.url'],
|
| + cwd=cwd or self.checkout_path).rstrip()
|
| + except (OSError, subprocess2.CalledProcessError):
|
| + return None
|
| +
|
| def GetRevisionDate(self, _revision):
|
| """Returns the given revision's date in ISO-8601 format (which contains the
|
| time zone)."""
|
| @@ -272,22 +279,6 @@ class GitWrapper(SCMWrapper):
|
|
|
| gclient_utils.CheckCallAndFilter(cmd4, **kwargs)
|
|
|
| - def _FetchAndReset(self, revision, file_list, options):
|
| - """Equivalent to git fetch; git reset."""
|
| - quiet = []
|
| - if not options.verbose:
|
| - quiet = ['--quiet']
|
| - self._UpdateBranchHeads(options, fetch=False)
|
| -
|
| - fetch_cmd = [
|
| - '-c', 'core.deltaBaseCacheLimit=2g', 'fetch', 'origin', '--prune']
|
| - self._Run(fetch_cmd + quiet, options, retry=True)
|
| - self._Run(['reset', '--hard', revision] + quiet, options)
|
| - self.UpdateSubmoduleConfig()
|
| - if file_list is not None:
|
| - files = self._Capture(['ls-files']).splitlines()
|
| - file_list.extend([os.path.join(self.checkout_path, f) for f in files])
|
| -
|
| def update(self, options, args, file_list):
|
| """Runs git to update or transparently checkout the working copy.
|
|
|
| @@ -373,35 +364,10 @@ class GitWrapper(SCMWrapper):
|
| '\tAnd run gclient sync again\n'
|
| % (self.relpath, rev_str, self.relpath))
|
|
|
| - # See if the url has changed (the unittests use git://foo for the url, let
|
| - # that through).
|
| - current_url = self._Capture(['config', 'remote.origin.url'])
|
| - return_early = False
|
| - # TODO(maruel): Delete url != 'git://foo' since it's just to make the
|
| - # unit test pass. (and update the comment above)
|
| - # Skip url auto-correction if remote.origin.gclient-auto-fix-url is set.
|
| - # This allows devs to use experimental repos which have a different url
|
| - # but whose branch(s) are the same as official repos.
|
| - if (current_url != url and
|
| - url != 'git://foo' and
|
| - subprocess2.capture(
|
| - ['git', 'config', 'remote.origin.gclient-auto-fix-url'],
|
| - cwd=self.checkout_path).strip() != 'False'):
|
| - print('_____ switching %s to a new upstream' % self.relpath)
|
| - # Make sure it's clean
|
| - self._CheckClean(rev_str)
|
| - # Switch over to the new upstream
|
| - self._Run(['remote', 'set-url', 'origin', url], options)
|
| - self._FetchAndReset(revision, file_list, options)
|
| - return_early = True
|
| -
|
| # Need to do this in the normal path as well as in the post-remote-switch
|
| # path.
|
| self._PossiblySwitchCache(url, options)
|
|
|
| - if return_early:
|
| - return self._Capture(['rev-parse', '--verify', 'HEAD'])
|
| -
|
| cur_branch = self._GetCurrentBranch()
|
|
|
| # Cases:
|
| @@ -807,8 +773,7 @@ class GitWrapper(SCMWrapper):
|
| # to relax this restriction in the future to allow for smarter cache
|
| # repo update schemes (such as pulling the same repo, but from a
|
| # different host).
|
| - existing_url = self._Capture(['config', 'remote.origin.url'],
|
| - cwd=folder)
|
| + existing_url = self.GetRemoteURL(options, cwd=folder)
|
| assert self._NormalizeGitURL(existing_url) == self._NormalizeGitURL(url)
|
|
|
| if use_reference:
|
| @@ -1077,6 +1042,13 @@ class SVNWrapper(SCMWrapper):
|
| def GetCheckoutRoot(self):
|
| return scm.SVN.GetCheckoutRoot(self.checkout_path)
|
|
|
| + def GetRemoteURL(self, options):
|
| + try:
|
| + local_info = scm.SVN.CaptureLocalInfo([os.curdir], self.checkout_path)
|
| + except (OSError, subprocess2.CalledProcessError):
|
| + return None
|
| + return local_info.get('URL')
|
| +
|
| def GetRevisionDate(self, revision):
|
| """Returns the given revision's date in ISO-8601 format (which contains the
|
| time zone)."""
|
|
|