| 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 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 Loading... |
| 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 and match.group(1) not in svn_refs: | 175 # Prefer origin/HEAD over all others. |
| 176 # To prefer local refs over remote ones we only set the first occurence. | 176 if match and (match.group(1) not in svn_refs or |
| 177 # The assumption being local refs are usually first. | 177 ref == "refs/remotes/origin/HEAD"): |
| 178 svn_refs[match.group(1)] = ref | 178 svn_refs[match.group(1)] = ref |
| 179 | 179 |
| 180 svn_branch = '' | 180 svn_branch = '' |
| 181 if len(svn_refs) == 1: | 181 if len(svn_refs) == 1: |
| 182 # Only one svn branch exists -- seems like a good candidate. | 182 # Only one svn branch exists -- seems like a good candidate. |
| 183 svn_branch = svn_refs.values()[0] | 183 svn_branch = svn_refs.values()[0] |
| 184 elif len(svn_refs) > 1: | 184 elif len(svn_refs) > 1: |
| 185 # We have more than one remote branch available. We don't | 185 # We have more than one remote branch available. We don't |
| 186 # 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 |
| 187 # pipe at a time. | 187 # pipe at a time. |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 if not SVN.current_version: | 778 if not SVN.current_version: |
| 779 SVN.current_version = SVN.Capture(['--version']).split()[2] | 779 SVN.current_version = SVN.Capture(['--version']).split()[2] |
| 780 current_version_list = map(only_int, SVN.current_version.split('.')) | 780 current_version_list = map(only_int, SVN.current_version.split('.')) |
| 781 for min_ver in map(int, min_version.split('.')): | 781 for min_ver in map(int, min_version.split('.')): |
| 782 ver = current_version_list.pop(0) | 782 ver = current_version_list.pop(0) |
| 783 if ver < min_ver: | 783 if ver < min_ver: |
| 784 return (False, SVN.current_version) | 784 return (False, SVN.current_version) |
| 785 elif ver > min_ver: | 785 elif ver > min_ver: |
| 786 return (True, SVN.current_version) | 786 return (True, SVN.current_version) |
| 787 return (True, SVN.current_version) | 787 return (True, SVN.current_version) |
| OLD | NEW |