| Index: gclient_scm.py
|
| ===================================================================
|
| --- gclient_scm.py (revision 194365)
|
| +++ gclient_scm.py (working copy)
|
| @@ -316,6 +316,7 @@
|
| quiet = []
|
| if not options.verbose:
|
| quiet = ['--quiet']
|
| + self._UpdateBranchHeads(options, fetch=False)
|
| self._Run(['fetch', 'origin', '--prune'] + quiet, options)
|
| self._Run(['reset', '--hard', revision] + quiet, options)
|
| self.UpdateSubmoduleConfig()
|
| @@ -384,6 +385,8 @@
|
| if verbose:
|
| print(remote_output.strip())
|
|
|
| + self._UpdateBranchHeads(options, fetch=True)
|
| +
|
| # This is a big hammer, debatable if it should even be here...
|
| if options.force or options.reset:
|
| self._Run(['reset', '--hard', 'HEAD'], options)
|
| @@ -692,32 +695,10 @@
|
| continue
|
| raise e
|
|
|
| - for _ in range(3):
|
| - try:
|
| - # Add the "branch-heads" refspecs. Do this separately from the clone
|
| - # command since apparently some versions of git don't support 'clone
|
| - # --config'.
|
| - # Don't assume 'with_branch_heads' is added by 'gclient sync' setup,
|
| - # since _Clone() can by reached in roundabout ways (e.g. 'gclient
|
| - # revert').
|
| - if hasattr(options, 'with_branch_heads') and options.with_branch_heads:
|
| - config_cmd = ['config', 'remote.origin.fetch',
|
| - '+refs/branch-heads/*:refs/remotes/branch-heads/*',
|
| - '^\\+refs/branch-heads/\\*:.*$']
|
| - self._Run(config_cmd, options)
|
| + # Update the "branch-heads" remote-tracking branches, since we might need it
|
| + # to checkout a specific revision below.
|
| + self._UpdateBranchHeads(options, fetch=True)
|
|
|
| - # Update the "branch-heads" remote-tracking branches, since we might
|
| - # need it to checkout a specific revision below.
|
| - fetch_cmd = ['fetch', 'origin']
|
| - if options.verbose:
|
| - fetch_cmd.append('--verbose')
|
| - self._Run(fetch_cmd, options)
|
| - break
|
| - except subprocess2.CalledProcessError, e:
|
| - print(str(e))
|
| - print('Retrying...')
|
| - continue
|
| -
|
| if detach_head:
|
| # Squelch git's very verbose detached HEAD warning and use our own
|
| self._Capture(['checkout', '--quiet', '%s' % revision])
|
| @@ -870,6 +851,28 @@
|
| stderr=subprocess2.PIPE,
|
| cwd=self.checkout_path).strip()
|
|
|
| + def _UpdateBranchHeads(self, options, fetch=False):
|
| + """Adds, and optionally fetches, "branch-heads" refspecs if requested."""
|
| + if hasattr(options, 'with_branch_heads') and options.with_branch_heads:
|
| + backoff_time = 5
|
| + for _ in range(3):
|
| + try:
|
| + config_cmd = ['config', 'remote.origin.fetch',
|
| + '+refs/branch-heads/*:refs/remotes/branch-heads/*',
|
| + '^\\+refs/branch-heads/\\*:.*$']
|
| + self._Run(config_cmd, options)
|
| + if fetch:
|
| + fetch_cmd = ['fetch', 'origin']
|
| + if options.verbose:
|
| + fetch_cmd.append('--verbose')
|
| + self._Run(fetch_cmd, options)
|
| + break
|
| + except subprocess2.CalledProcessError, e:
|
| + print(str(e))
|
| + print('Retrying in %.1f seconds...' % backoff_time)
|
| + time.sleep(backoff_time)
|
| + backoff_time *= 1.3
|
| +
|
| def _Run(self, args, options, **kwargs):
|
| kwargs.setdefault('cwd', self.checkout_path)
|
| kwargs.setdefault('print_stdout', True)
|
|
|