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 | |
borenet
2013/11/12 19:33:37
This may not be in the right place. Any alternati
iannucci
2013/11/13 06:26:30
the 'force' flag would probably be sufficient
borenet
2013/11/13 19:12:24
Done.
| |
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) | |
651 if actual_remote_url != url: | |
652 dest_dir = os.path.join(self.root.root_dir, self.name) | |
653 logging.debug('%s does not contain a checkout of %s. Removing.' % | |
iannucci
2013/11/13 06:26:30
I think this should actually be at least a warn, s
borenet
2013/11/13 19:12:24
Done.
| |
654 dest_dir) | |
655 gclient_utils.rmtree(dest_dir) | |
borenet
2013/11/12 19:33:37
Alternatively, we could move into a temporary dire
iannucci
2013/11/13 06:26:30
This sounds like a lot of complexity to me with ve
borenet
2013/11/13 19:12:24
Agreed. I think the most I'd want to do is move i
Isaac (away)
2013/12/03 18:25:05
Other than bots, I don't think it's OK for gclient
Isaac (away)
2013/12/03 18:25:49
Ignore this comment, it's stale.
borenet
2013/12/03 21:12:02
Confirming that you're okay with the deletion appr
Isaac (away)
2013/12/04 03:29:19
Yes. With a prompt this is fine.
| |
656 | |
644 self._got_revision = self._used_scm.RunCommand(command, options, args, | 657 self._got_revision = self._used_scm.RunCommand(command, options, args, |
645 file_list) | 658 file_list) |
646 if file_list: | 659 if file_list: |
647 file_list = [os.path.join(self.name, f.strip()) for f in file_list] | 660 file_list = [os.path.join(self.name, f.strip()) for f in file_list] |
648 | 661 |
649 # TODO(phajdan.jr): We should know exactly when the paths are absolute. | 662 # TODO(phajdan.jr): We should know exactly when the paths are absolute. |
650 # Convert all absolute paths to relative. | 663 # Convert all absolute paths to relative. |
651 for i in range(len(file_list or [])): | 664 for i in range(len(file_list or [])): |
652 # It depends on the command being executed (like runhooks vs sync). | 665 # It depends on the command being executed (like runhooks vs sync). |
653 if not os.path.isabs(file_list[i]): | 666 if not os.path.isabs(file_list[i]): |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 raise | 1902 raise |
1890 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1903 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1891 print >> sys.stderr, 'Error: %s' % str(e) | 1904 print >> sys.stderr, 'Error: %s' % str(e) |
1892 return 1 | 1905 return 1 |
1893 | 1906 |
1894 | 1907 |
1895 if '__main__' == __name__: | 1908 if '__main__' == __name__: |
1896 sys.exit(Main(sys.argv[1:])) | 1909 sys.exit(Main(sys.argv[1:])) |
1897 | 1910 |
1898 # vim: ts=2:sw=2:tw=80:et: | 1911 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |