OLD | NEW |
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 clone_cmd = ['clone'] | 486 clone_cmd = ['clone'] |
487 if revision.startswith('refs/heads/'): | 487 if revision.startswith('refs/heads/'): |
488 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) | 488 clone_cmd.extend(['-b', revision.replace('refs/heads/', '')]) |
489 detach_head = False | 489 detach_head = False |
490 else: | 490 else: |
491 detach_head = True | 491 detach_head = True |
492 if options.verbose: | 492 if options.verbose: |
493 clone_cmd.append('--verbose') | 493 clone_cmd.append('--verbose') |
494 clone_cmd.extend([url, self.checkout_path]) | 494 clone_cmd.extend([url, self.checkout_path]) |
495 | 495 |
| 496 # If the parent directory does not exist, Git clone on Windows will not |
| 497 # create it, so we need to do it manually. |
| 498 parent_dir = os.path.dirname(self.checkout_path) |
| 499 if not os.path.exists(parent_dir): |
| 500 os.makedirs(parent_dir) |
| 501 |
496 for _ in range(3): | 502 for _ in range(3): |
497 try: | 503 try: |
498 self._Run(clone_cmd, options, cwd=self._root_dir) | 504 self._Run(clone_cmd, options, cwd=self._root_dir) |
499 break | 505 break |
500 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 506 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
501 # TODO(maruel): Hackish, should be fixed by moving _Run() to | 507 # TODO(maruel): Hackish, should be fixed by moving _Run() to |
502 # CheckCall(). | 508 # CheckCall(). |
503 # Too bad we don't have access to the actual output. | 509 # Too bad we don't have access to the actual output. |
504 # We should check for "transfer closed with NNN bytes remaining to | 510 # We should check for "transfer closed with NNN bytes remaining to |
505 # read". In the meantime, just make sure .git exists. | 511 # read". In the meantime, just make sure .git exists. |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 937 |
932 This method returns a new list to be used as a command.""" | 938 This method returns a new list to be used as a command.""" |
933 new_command = command[:] | 939 new_command = command[:] |
934 if revision: | 940 if revision: |
935 new_command.extend(['--revision', str(revision).strip()]) | 941 new_command.extend(['--revision', str(revision).strip()]) |
936 # --force was added to 'svn update' in svn 1.5. | 942 # --force was added to 'svn update' in svn 1.5. |
937 if ((options.force or options.manually_grab_svn_rev) and | 943 if ((options.force or options.manually_grab_svn_rev) and |
938 scm.SVN.AssertVersion("1.5")[0]): | 944 scm.SVN.AssertVersion("1.5")[0]): |
939 new_command.append('--force') | 945 new_command.append('--force') |
940 return new_command | 946 return new_command |
OLD | NEW |