OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Meta checkout manager supporting both Subversion and GIT.""" | 6 """Meta checkout manager supporting both Subversion and GIT.""" |
7 # Files | 7 # Files |
8 # .gclient : Current client configuration, written by 'config' command. | 8 # .gclient : Current client configuration, written by 'config' command. |
9 # Format is a Python script defining 'solutions', a list whose | 9 # Format is a Python script defining 'solutions', a list whose |
10 # entries each are maps binding the strings "name" and "url" | 10 # entries each are maps binding the strings "name" and "url" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 self._used_scm.RunCommand('updatesingle', | 634 self._used_scm.RunCommand('updatesingle', |
635 options, args + [parsed_url.GetFilename()], file_list) | 635 options, args + [parsed_url.GetFilename()], file_list) |
636 else: | 636 else: |
637 # Create a shallow copy to mutate revision. | 637 # Create a shallow copy to mutate revision. |
638 options = copy.copy(options) | 638 options = copy.copy(options) |
639 options.revision = revision_overrides.get(self.name) | 639 options.revision = revision_overrides.get(self.name) |
640 self.maybeGetParentRevision( | 640 self.maybeGetParentRevision( |
641 command, options, parsed_url, self.parent.name, revision_overrides) | 641 command, options, parsed_url, self.parent.name, revision_overrides) |
642 self._used_scm = gclient_scm.CreateSCM( | 642 self._used_scm = gclient_scm.CreateSCM( |
643 parsed_url, self.root.root_dir, self.name) | 643 parsed_url, self.root.root_dir, self.name) |
644 | |
645 # When updating, determine whether the destination directory contains a | |
646 # checkout of the desired repository. If not, avoid conflicts by | |
647 # deleting the directory before running the update. | |
648 if command == 'update': | |
649 actual_remote_url = self._used_scm.GetRemoteURL(options) | |
650 url, _ = gclient_utils.SplitUrlRevision(parsed_url) | |
Isaac (away)
2013/12/09 21:45:59
make sure this has substitions applied and is norm
borenet
2013/12/10 18:48:27
I tried overriding googlecode_url in the .gclient
| |
651 dest_dir = os.path.join(self.root.root_dir, self.name) | |
652 if os.path.isdir(dest_dir) and actual_remote_url != url: | |
653 should_delete = options.force | |
Isaac (away)
2013/12/09 21:45:59
Let's also use if env contains 'CHROME_HEADLESS'
borenet
2013/12/10 18:48:27
Done.
| |
654 if sys.__stdout__.isatty() and not should_delete: | |
655 usr_input = '' | |
656 while usr_input not in ('y', 'n'): | |
657 usr_input = raw_input('%s does not contain a checkout of %s. ' | |
658 'Do you want to delete the directory? ' | |
659 'If not, the update will be canceled ' | |
660 '(y/n): ' % (dest_dir, url)).lower() | |
661 should_delete = (usr_input == 'y') | |
662 if should_delete: | |
663 logging.warning('%s does not contain a checkout of %s. Removing ' | |
664 ' %s' % (dest_dir, url, dest_dir)) | |
665 gclient_utils.rmtree(dest_dir) | |
666 else: | |
667 raise gclient_utils.Error('%s does not contain a checkout of %s. ' | |
668 'Please fix the solution manually or ' | |
669 'run with --force to delete ' | |
670 'automatically.' % (dest_dir, url)) | |
671 | |
644 self._got_revision = self._used_scm.RunCommand(command, options, args, | 672 self._got_revision = self._used_scm.RunCommand(command, options, args, |
645 file_list) | 673 file_list) |
646 if file_list: | 674 if file_list: |
647 file_list = [os.path.join(self.name, f.strip()) for f in file_list] | 675 file_list = [os.path.join(self.name, f.strip()) for f in file_list] |
648 | 676 |
649 # TODO(phajdan.jr): We should know exactly when the paths are absolute. | 677 # TODO(phajdan.jr): We should know exactly when the paths are absolute. |
650 # Convert all absolute paths to relative. | 678 # Convert all absolute paths to relative. |
651 for i in range(len(file_list or [])): | 679 for i in range(len(file_list or [])): |
652 # It depends on the command being executed (like runhooks vs sync). | 680 # It depends on the command being executed (like runhooks vs sync). |
653 if not os.path.isabs(file_list[i]): | 681 if not os.path.isabs(file_list[i]): |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 raise | 1917 raise |
1890 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1918 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1891 print >> sys.stderr, 'Error: %s' % str(e) | 1919 print >> sys.stderr, 'Error: %s' % str(e) |
1892 return 1 | 1920 return 1 |
1893 | 1921 |
1894 | 1922 |
1895 if '__main__' == __name__: | 1923 if '__main__' == __name__: |
1896 sys.exit(Main(sys.argv[1:])) | 1924 sys.exit(Main(sys.argv[1:])) |
1897 | 1925 |
1898 # vim: ts=2:sw=2:tw=80:et: | 1926 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |