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 cStringIO | 7 import cStringIO |
8 import glob | 8 import glob |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 svn_branch = '' | 208 svn_branch = '' |
209 if len(svn_refs) == 1: | 209 if len(svn_refs) == 1: |
210 # Only one svn branch exists -- seems like a good candidate. | 210 # Only one svn branch exists -- seems like a good candidate. |
211 svn_branch = svn_refs.values()[0] | 211 svn_branch = svn_refs.values()[0] |
212 elif len(svn_refs) > 1: | 212 elif len(svn_refs) > 1: |
213 # We have more than one remote branch available. We don't | 213 # We have more than one remote branch available. We don't |
214 # want to go through all of history, so read a line from the | 214 # want to go through all of history, so read a line from the |
215 # pipe at a time. | 215 # pipe at a time. |
216 # The -100 is an arbitrary limit so we don't search forever. | 216 # The -100 is an arbitrary limit so we don't search forever. |
217 cmd = ['git', 'log', '-100', '--pretty=medium'] | 217 cmd = ['git', 'log', '-100', '--pretty=medium'] |
218 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, cwd=cwd) | 218 proc = gclient_utils.Popen(cmd, stdout=subprocess.PIPE, cwd=cwd) |
219 for line in proc.stdout: | 219 for line in proc.stdout: |
220 match = git_svn_re.match(line) | 220 match = git_svn_re.match(line) |
221 if match: | 221 if match: |
222 url = match.group(1) | 222 url = match.group(1) |
223 if url in svn_refs: | 223 if url in svn_refs: |
224 svn_branch = svn_refs[url] | 224 svn_branch = svn_refs[url] |
225 proc.stdout.close() # Cut pipe. | 225 proc.stdout.close() # Cut pipe. |
226 break | 226 break |
227 return svn_branch | 227 return svn_branch |
228 | 228 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 Args: | 365 Args: |
366 args: A sequence of command line parameters to be passed to svn. | 366 args: A sequence of command line parameters to be passed to svn. |
367 in_directory: The directory where svn is to be run. | 367 in_directory: The directory where svn is to be run. |
368 | 368 |
369 Returns: | 369 Returns: |
370 The output sent to stdout as a string. | 370 The output sent to stdout as a string. |
371 """ | 371 """ |
372 c = [SVN.COMMAND] | 372 c = [SVN.COMMAND] |
373 c.extend(args) | 373 c.extend(args) |
374 | |
375 # *Sigh*: Windows needs shell=True, or else it won't search %PATH% for | |
376 # the svn.exe executable, but shell=True makes subprocess on Linux fail | |
377 # when it's called with a list because it only tries to execute the | |
378 # first string ("svn"). | |
379 stderr = None | 374 stderr = None |
380 if not print_error: | 375 if not print_error: |
381 stderr = subprocess.PIPE | 376 stderr = subprocess.PIPE |
382 return subprocess.Popen(c, | 377 return gclient_utils.Popen(c, cwd=in_directory, stdout=subprocess.PIPE, |
383 cwd=in_directory, | 378 stderr=stderr).communicate()[0] |
384 shell=(sys.platform == 'win32'), | |
385 stdout=subprocess.PIPE, | |
386 stderr=stderr).communicate()[0] | |
387 | 379 |
388 @staticmethod | 380 @staticmethod |
389 def RunAndGetFileList(verbose, args, in_directory, file_list): | 381 def RunAndGetFileList(verbose, args, in_directory, file_list): |
390 """Runs svn checkout, update, or status, output to stdout. | 382 """Runs svn checkout, update, or status, output to stdout. |
391 | 383 |
392 The first item in args must be either "checkout", "update", or "status". | 384 The first item in args must be either "checkout", "update", or "status". |
393 | 385 |
394 svn's stdout is parsed to collect a list of files checked out or updated. | 386 svn's stdout is parsed to collect a list of files checked out or updated. |
395 These files are appended to file_list. svn's stdout is also printed to | 387 These files are appended to file_list. svn's stdout is also printed to |
396 sys.stdout as in Run. | 388 sys.stdout as in Run. |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 if not SVN.current_version: | 929 if not SVN.current_version: |
938 SVN.current_version = SVN.Capture(['--version']).split()[2] | 930 SVN.current_version = SVN.Capture(['--version']).split()[2] |
939 current_version_list = map(only_int, SVN.current_version.split('.')) | 931 current_version_list = map(only_int, SVN.current_version.split('.')) |
940 for min_ver in map(int, min_version.split('.')): | 932 for min_ver in map(int, min_version.split('.')): |
941 ver = current_version_list.pop(0) | 933 ver = current_version_list.pop(0) |
942 if ver < min_ver: | 934 if ver < min_ver: |
943 return (False, SVN.current_version) | 935 return (False, SVN.current_version) |
944 elif ver > min_ver: | 936 elif ver > min_ver: |
945 return (True, SVN.current_version) | 937 return (True, SVN.current_version) |
946 return (True, SVN.current_version) | 938 return (True, SVN.current_version) |
OLD | NEW |