OLD | NEW |
1 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2006-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 """SCM-specific utility classes.""" | 5 """SCM-specific utility classes.""" |
6 | 6 |
7 import os | 7 import os |
8 import re | 8 import re |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 # args[0] must be a supported command. This will blow up if it's something | 159 # args[0] must be a supported command. This will blow up if it's something |
160 # else, which is good. Note that the patterns are only effective when | 160 # else, which is good. Note that the patterns are only effective when |
161 # these commands are used in their ordinary forms, the patterns are invalid | 161 # these commands are used in their ordinary forms, the patterns are invalid |
162 # for "svn status --show-updates", for example. | 162 # for "svn status --show-updates", for example. |
163 pattern = { | 163 pattern = { |
164 'checkout': update_pattern, | 164 'checkout': update_pattern, |
165 'status': status_pattern, | 165 'status': status_pattern, |
166 'update': update_pattern, | 166 'update': update_pattern, |
167 }[args[0]] | 167 }[args[0]] |
168 | |
169 compiled_pattern = re.compile(pattern) | 168 compiled_pattern = re.compile(pattern) |
170 | 169 # Place an upper limit. |
171 def CaptureMatchingLines(line): | 170 for i in range(1, 10): |
172 match = compiled_pattern.search(line) | 171 previous_list_len = len(file_list) |
173 if match: | 172 failure = [] |
174 file_list.append(match.group(1)) | 173 def CaptureMatchingLines(line): |
175 | 174 match = compiled_pattern.search(line) |
176 SVN.RunAndFilterOutput(args, | 175 if match: |
177 in_directory, | 176 file_list.append(match.group(1)) |
178 options.verbose, | 177 if line.startswith('svn: '): |
179 True, | 178 # We can't raise an exception. We can't alias a variable. Use a cheap |
180 CaptureMatchingLines) | 179 # way. |
| 180 failure.append(True) |
| 181 try: |
| 182 SVN.RunAndFilterOutput(args, |
| 183 in_directory, |
| 184 options.verbose, |
| 185 True, |
| 186 CaptureMatchingLines) |
| 187 except gclient_utils.Error: |
| 188 # We enforce that some progress has been made. |
| 189 if len(failure) and len(file_list) > previous_list_len: |
| 190 if args[0] == 'checkout': |
| 191 args = args[:] |
| 192 # An aborted checkout is now an update. |
| 193 args[0] = 'update' |
| 194 continue |
| 195 break |
181 | 196 |
182 @staticmethod | 197 @staticmethod |
183 def RunAndFilterOutput(args, | 198 def RunAndFilterOutput(args, |
184 in_directory, | 199 in_directory, |
185 print_messages, | 200 print_messages, |
186 print_stdout, | 201 print_stdout, |
187 filter): | 202 filter): |
188 """Runs svn checkout, update, status, or diff, optionally outputting | 203 """Runs svn checkout, update, status, or diff, optionally outputting |
189 to stdout. | 204 to stdout. |
190 | 205 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 483 |
469 while True: | 484 while True: |
470 key = ReadOneItem('K') | 485 key = ReadOneItem('K') |
471 if not key: | 486 if not key: |
472 break | 487 break |
473 value = ReadOneItem('V') | 488 value = ReadOneItem('V') |
474 if not value: | 489 if not value: |
475 break | 490 break |
476 values[key] = value | 491 values[key] = value |
477 return values | 492 return values |
OLD | NEW |