OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if self.relpath: | 90 if self.relpath: |
91 self.relpath = self.relpath.replace('/', os.sep) | 91 self.relpath = self.relpath.replace('/', os.sep) |
92 if self.relpath and self._root_dir: | 92 if self.relpath and self._root_dir: |
93 self.checkout_path = os.path.join(self._root_dir, self.relpath) | 93 self.checkout_path = os.path.join(self._root_dir, self.relpath) |
94 | 94 |
95 def RunCommand(self, command, options, args, file_list=None): | 95 def RunCommand(self, command, options, args, file_list=None): |
96 # file_list will have all files that are modified appended to it. | 96 # file_list will have all files that are modified appended to it. |
97 if file_list is None: | 97 if file_list is None: |
98 file_list = [] | 98 file_list = [] |
99 | 99 |
100 commands = ['cleanup', 'export', 'update', 'revert', 'revinfo', | 100 commands = ['cleanup', 'export', 'update', 'updatesingle', 'revert', |
101 'status', 'diff', 'pack', 'runhooks'] | 101 'revinfo', 'status', 'diff', 'pack', 'runhooks'] |
102 | 102 |
103 if not command in commands: | 103 if not command in commands: |
104 raise gclient_utils.Error('Unknown command %s' % command) | 104 raise gclient_utils.Error('Unknown command %s' % command) |
105 | 105 |
106 if not command in dir(self): | 106 if not command in dir(self): |
107 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( | 107 raise gclient_utils.Error('Command %s not implemented in %s wrapper' % ( |
108 command, self.scm_name)) | 108 command, self.scm_name)) |
109 | 109 |
110 return getattr(self, command)(options, args, file_list) | 110 return getattr(self, command)(options, args, file_list) |
111 | 111 |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 if not options.force and str(from_info['Revision']) == revision: | 739 if not options.force and str(from_info['Revision']) == revision: |
740 if options.verbose or not forced_revision: | 740 if options.verbose or not forced_revision: |
741 print("\n_____ %s%s" % (self.relpath, rev_str)) | 741 print("\n_____ %s%s" % (self.relpath, rev_str)) |
742 return | 742 return |
743 | 743 |
744 command = ["update", checkout_path] | 744 command = ["update", checkout_path] |
745 if revision: | 745 if revision: |
746 command.extend(['--revision', str(revision)]) | 746 command.extend(['--revision', str(revision)]) |
747 scm.SVN.RunAndGetFileList(options, command, self._root_dir, file_list) | 747 scm.SVN.RunAndGetFileList(options, command, self._root_dir, file_list) |
748 | 748 |
| 749 def updatesingle(self, options, args, file_list): |
| 750 checkout_path = os.path.join(self._root_dir, self.relpath) |
| 751 filename = args.pop() |
| 752 if not os.path.exists(checkout_path): |
| 753 # Create an empty checkout and then update the one file we want. Future |
| 754 # operations will only apply to the one file we checked out. |
| 755 command = ["checkout", "--depth", "empty", self.url, checkout_path] |
| 756 scm.SVN.Run(command, self._root_dir) |
| 757 command = ["update", filename] |
| 758 scm.SVN.RunAndGetFileList(options, command, checkout_path, file_list) |
| 759 # After the initial checkout, we can use update as if it were any other |
| 760 # dep. |
| 761 self.update(options, args, file_list) |
| 762 |
749 def revert(self, options, args, file_list): | 763 def revert(self, options, args, file_list): |
750 """Reverts local modifications. Subversion specific. | 764 """Reverts local modifications. Subversion specific. |
751 | 765 |
752 All reverted files will be appended to file_list, even if Subversion | 766 All reverted files will be appended to file_list, even if Subversion |
753 doesn't know about them. | 767 doesn't know about them. |
754 """ | 768 """ |
755 __pychecker__ = 'unusednames=args' | 769 __pychecker__ = 'unusednames=args' |
756 path = os.path.join(self._root_dir, self.relpath) | 770 path = os.path.join(self._root_dir, self.relpath) |
757 if not os.path.isdir(path): | 771 if not os.path.isdir(path): |
758 # svn revert won't work if the directory doesn't exist. It needs to | 772 # svn revert won't work if the directory doesn't exist. It needs to |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 835 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
822 "does not exist." | 836 "does not exist." |
823 % (' '.join(command), path)) | 837 % (' '.join(command), path)) |
824 # There's no file list to retrieve. | 838 # There's no file list to retrieve. |
825 else: | 839 else: |
826 scm.SVN.RunAndGetFileList(options, command, path, file_list) | 840 scm.SVN.RunAndGetFileList(options, command, path, file_list) |
827 | 841 |
828 def FullUrlForRelativeUrl(self, url): | 842 def FullUrlForRelativeUrl(self, url): |
829 # Find the forth '/' and strip from there. A bit hackish. | 843 # Find the forth '/' and strip from there. A bit hackish. |
830 return '/'.join(self.url.split('/')[:4]) + url | 844 return '/'.join(self.url.split('/')[:4]) + url |
OLD | NEW |