Chromium Code Reviews| Index: gclient_scm.py |
| =================================================================== |
| --- gclient_scm.py (revision 193951) |
| +++ 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,25 @@ |
| stderr=subprocess2.PIPE, |
| cwd=self.checkout_path).strip() |
| + def _UpdateBranchHeads(self, options, fetch=False): |
| + """Add, and optionally fetch, the "branch-heads" refspecs if requested.""" |
|
M-A Ruel
2013/04/12 20:28:12
Adds
Michael Moss
2013/04/12 20:58:36
Done.
|
| + if hasattr(options, 'with_branch_heads') and options.with_branch_heads: |
| + for _ in range(3): |
| + try: |
| + config_cmd = ['config', 'remote.origin.fetch', |
| + '+refs/branch-heads/*:refs/remotes/branch-heads/*', |
|
M-A Ruel
2013/04/12 20:28:12
I still don't know what branch-heads is supposed t
Michael Moss
2013/04/12 20:58:36
branch-heads is specifically the heads of branches
M-A Ruel
2013/04/16 14:44:09
What you are describing is kinda what lightweight
|
| + '^\\+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...') |
| + |
| def _Run(self, args, options, **kwargs): |
| kwargs.setdefault('cwd', self.checkout_path) |
| kwargs.setdefault('print_stdout', True) |