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

Side by Side Diff: scm.py

Issue 1622011: Changes GetSVNBranch to prefer the first ref over the last. The... (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 git_svn_re = re.compile(r'^\s*git-svn-id: (\S+)@', re.MULTILINE) 165 git_svn_re = re.compile(r'^\s*git-svn-id: (\S+)@', re.MULTILINE)
166 166
167 # Get the refname and svn url for all refs/remotes/*. 167 # Get the refname and svn url for all refs/remotes/*.
168 remotes = GIT.Capture( 168 remotes = GIT.Capture(
169 ['for-each-ref', '--format=%(refname)', 'refs/remotes'], 169 ['for-each-ref', '--format=%(refname)', 'refs/remotes'],
170 cwd)[0].splitlines() 170 cwd)[0].splitlines()
171 svn_refs = {} 171 svn_refs = {}
172 for ref in remotes: 172 for ref in remotes:
173 match = git_svn_re.search( 173 match = git_svn_re.search(
174 GIT.Capture(['cat-file', '-p', ref], cwd)[0]) 174 GIT.Capture(['cat-file', '-p', ref], cwd)[0])
175 if match: 175 if match and match.group(1) not in svn_refs:
M-A Ruel 2010/04/08 16:36:38 nit: you could do instead if match: # To prefer
176 # To prefer local refs over remote ones we only set the first occurence.
177 # The assumption being local refs are usually first.
176 svn_refs[match.group(1)] = ref 178 svn_refs[match.group(1)] = ref
177 179
178 svn_branch = '' 180 svn_branch = ''
179 if len(svn_refs) == 1: 181 if len(svn_refs) == 1:
180 # Only one svn branch exists -- seems like a good candidate. 182 # Only one svn branch exists -- seems like a good candidate.
181 svn_branch = svn_refs.values()[0] 183 svn_branch = svn_refs.values()[0]
182 elif len(svn_refs) > 1: 184 elif len(svn_refs) > 1:
183 # We have more than one remote branch available. We don't 185 # We have more than one remote branch available. We don't
184 # want to go through all of history, so read a line from the 186 # want to go through all of history, so read a line from the
185 # pipe at a time. 187 # pipe at a time.
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 if not cur_dir_repo_root: 758 if not cur_dir_repo_root:
757 return None 759 return None
758 760
759 while True: 761 while True:
760 parent = os.path.dirname(directory) 762 parent = os.path.dirname(directory)
761 if (SVN.CaptureInfo(parent, print_error=False).get( 763 if (SVN.CaptureInfo(parent, print_error=False).get(
762 "Repository Root") != cur_dir_repo_root): 764 "Repository Root") != cur_dir_repo_root):
763 break 765 break
764 directory = parent 766 directory = parent
765 return GetCasedPath(directory) 767 return GetCasedPath(directory)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698