Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: scm.py

Issue 874002: Stop SVNWrapper and GitWrapper from inheriting from scm.SVN and scm.GIT. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 glob 7 import glob
8 import os 8 import os
9 import re 9 import re
10 import shutil 10 import shutil
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 else: 214 else:
215 # Fall back on trying a git-svn upstream branch. 215 # Fall back on trying a git-svn upstream branch.
216 if GIT.IsGitSvn(cwd): 216 if GIT.IsGitSvn(cwd):
217 upstream_branch = GIT.GetSVNBranch(cwd) 217 upstream_branch = GIT.GetSVNBranch(cwd)
218 return remote, upstream_branch 218 return remote, upstream_branch
219 219
220 @staticmethod 220 @staticmethod
221 def GetUpstream(cwd): 221 def GetUpstream(cwd):
222 """Gets the current branch's upstream branch.""" 222 """Gets the current branch's upstream branch."""
223 remote, upstream_branch = GIT.FetchUpstreamTuple(cwd) 223 remote, upstream_branch = GIT.FetchUpstreamTuple(cwd)
224 if remote is not '.': 224 if remote != '.':
225 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote) 225 upstream_branch = upstream_branch.replace('heads', 'remotes/' + remote)
226 return upstream_branch 226 return upstream_branch
227 227
228 @staticmethod 228 @staticmethod
229 def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False, 229 def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False,
230 files=None): 230 files=None):
231 """Diffs against the upstream branch or optionally another branch. 231 """Diffs against the upstream branch or optionally another branch.
232 232
233 full_move means that move or copy operations should completely recreate the 233 full_move means that move or copy operations should completely recreate the
234 files, usually in the prospect to apply the patch for a try job.""" 234 files, usually in the prospect to apply the patch for a try job."""
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 # else, which is good. Note that the patterns are only effective when 371 # else, which is good. Note that the patterns are only effective when
372 # these commands are used in their ordinary forms, the patterns are invalid 372 # these commands are used in their ordinary forms, the patterns are invalid
373 # for "svn status --show-updates", for example. 373 # for "svn status --show-updates", for example.
374 pattern = { 374 pattern = {
375 'checkout': update_pattern, 375 'checkout': update_pattern,
376 'status': status_pattern, 376 'status': status_pattern,
377 'update': update_pattern, 377 'update': update_pattern,
378 }[args[0]] 378 }[args[0]]
379 compiled_pattern = re.compile(pattern) 379 compiled_pattern = re.compile(pattern)
380 # Place an upper limit. 380 # Place an upper limit.
381 for i in range(1, 10): 381 for _ in range(1, 10):
382 previous_list_len = len(file_list) 382 previous_list_len = len(file_list)
383 failure = [] 383 failure = []
384 384
385 def CaptureMatchingLines(line): 385 def CaptureMatchingLines(line):
386 match = compiled_pattern.search(line) 386 match = compiled_pattern.search(line)
387 if match: 387 if match:
388 file_list.append(match.group(1)) 388 file_list.append(match.group(1))
389 if line.startswith('svn: '): 389 if line.startswith('svn: '):
390 failure.append(line) 390 failure.append(line)
391 391
392 try: 392 try:
393 SVN.RunAndFilterOutput(args, 393 SVN.RunAndFilterOutput(args,
394 in_directory, 394 in_directory,
395 options.verbose, 395 options.verbose,
396 True, 396 True,
397 CaptureMatchingLines) 397 CaptureMatchingLines)
398 except gclient_utils.Error: 398 except gclient_utils.Error:
399 # We enforce that some progress has been made or HTTP 502. 399 # We enforce that some progress has been made or HTTP 502.
400 if ([True for f in failure if '502 Bad Gateway' in f] or 400 if (filter(lambda x: '502 Bad Gateway' in x, failure) or
401 (len(failure) and len(file_list) > previous_list_len)): 401 (len(failure) and len(file_list) > previous_list_len)):
402 if args[0] == 'checkout': 402 if args[0] == 'checkout':
403 # An aborted checkout is now an update. 403 # An aborted checkout is now an update.
404 args = ['update'] + args[1:] 404 args = ['update'] + args[1:]
405 continue 405 continue
406 # No progress was made or an unknown error we aren't sure, bail out. 406 # No progress was made or an unknown error we aren't sure, bail out.
407 raise 407 raise
408 break 408 break
409 409
410 @staticmethod 410 @staticmethod
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 if not cur_dir_repo_root: 745 if not cur_dir_repo_root:
746 return None 746 return None
747 747
748 while True: 748 while True:
749 parent = os.path.dirname(directory) 749 parent = os.path.dirname(directory)
750 if (SVN.CaptureInfo(parent, print_error=False).get( 750 if (SVN.CaptureInfo(parent, print_error=False).get(
751 "Repository Root") != cur_dir_repo_root): 751 "Repository Root") != cur_dir_repo_root):
752 break 752 break
753 directory = parent 753 directory = parent
754 return GetCasedPath(directory) 754 return GetCasedPath(directory)
OLDNEW
« gclient.py ('K') | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698