OLD | NEW |
---|---|
1 # Copyright 2009 Google Inc. All Rights Reserved. | 1 # Copyright 2009 Google Inc. All Rights Reserved. |
2 # | 2 # |
3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
6 # | 6 # |
7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
8 # | 8 # |
9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) | 126 raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) |
127 | 127 |
128 components = self.url.split("@") | 128 components = self.url.split("@") |
129 url = components[0] | 129 url = components[0] |
130 revision = None | 130 revision = None |
131 if options.revision: | 131 if options.revision: |
132 revision = options.revision | 132 revision = options.revision |
133 elif len(components) == 2: | 133 elif len(components) == 2: |
134 revision = components[1] | 134 revision = components[1] |
135 | 135 |
136 if options.verbose: | |
137 rev_str = "" | |
138 if revision: | |
139 rev_str = ' at %s' % revision | |
140 print("\n_____ %s%s" % (self.relpath, rev_str)) | |
141 | |
136 if not os.path.exists(self.checkout_path): | 142 if not os.path.exists(self.checkout_path): |
137 self._RunGit(['clone', url, self.checkout_path], | 143 self._RunGit(['clone', url, self.checkout_path], |
138 cwd=self._root_dir, redirect_stdout=False) | 144 cwd=self._root_dir, redirect_stdout=False) |
139 if revision: | 145 if revision: |
140 self._RunGit(['reset', '--hard', revision], redirect_stdout=False) | 146 self._RunGit(['reset', '--hard', revision], redirect_stdout=False) |
141 files = self._RunGit(['ls-files']).split() | 147 files = self._RunGit(['ls-files']).split() |
142 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 148 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
143 return | 149 return |
144 | 150 |
145 self._RunGit(['remote', 'update'], redirect_stdout=False) | 151 self._RunGit(['remote', 'update'], redirect_stdout=False) |
146 new_base = 'origin' | 152 new_base = 'origin' |
147 if revision: | 153 if revision: |
148 new_base = revision | 154 new_base = revision |
149 files = self._RunGit(['diff', new_base, '--name-only']).split() | 155 files = self._RunGit(['diff', new_base, '--name-only']).split() |
150 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) | 156 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) |
151 self._RunGit(['rebase', new_base], redirect_stdout=False) | 157 self._RunGit(['rebase', '-v', new_base], redirect_stdout=False) |
M-A Ruel
2009/11/06 22:56:14
Shouldn't -v only when options.verbose?
| |
158 print "Checked out revision %s." % self.revinfo(options, (), None) | |
152 | 159 |
153 def revert(self, options, args, file_list): | 160 def revert(self, options, args, file_list): |
154 """Reverts local modifications. | 161 """Reverts local modifications. |
155 | 162 |
156 All reverted files will be appended to file_list. | 163 All reverted files will be appended to file_list. |
157 """ | 164 """ |
158 path = os.path.join(self._root_dir, self.relpath) | 165 path = os.path.join(self._root_dir, self.relpath) |
159 if not os.path.isdir(path): | 166 if not os.path.isdir(path): |
160 # revert won't work if the directory doesn't exist. It needs to | 167 # revert won't work if the directory doesn't exist. It needs to |
161 # checkout instead. | 168 # checkout instead. |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 # Col 3 | 784 # Col 3 |
778 if wc_status[0].getAttribute('copied') == 'true': | 785 if wc_status[0].getAttribute('copied') == 'true': |
779 statuses[3] = '+' | 786 statuses[3] = '+' |
780 # Col 4 | 787 # Col 4 |
781 if wc_status[0].getAttribute('switched') == 'true': | 788 if wc_status[0].getAttribute('switched') == 'true': |
782 statuses[4] = 'S' | 789 statuses[4] = 'S' |
783 # TODO(maruel): Col 5 and 6 | 790 # TODO(maruel): Col 5 and 6 |
784 item = (''.join(statuses), file) | 791 item = (''.join(statuses), file) |
785 results.append(item) | 792 results.append(item) |
786 return results | 793 return results |
OLD | NEW |