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

Side by Side Diff: scm.py

Issue 878001: Extract git version check code from gclient_scm.py into scm.py where it belongs. (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
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd)[0].strip() 263 short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd)[0].strip()
264 return "%s-%s" % (GIT.GetBranch(cwd), short_sha) 264 return "%s-%s" % (GIT.GetBranch(cwd), short_sha)
265 265
266 @staticmethod 266 @staticmethod
267 def GetCheckoutRoot(path): 267 def GetCheckoutRoot(path):
268 """Returns the top level directory of a git checkout as an absolute path. 268 """Returns the top level directory of a git checkout as an absolute path.
269 """ 269 """
270 root = GIT.Capture(['rev-parse', '--show-cdup'], path)[0].strip() 270 root = GIT.Capture(['rev-parse', '--show-cdup'], path)[0].strip()
271 return os.path.abspath(os.path.join(path, root)) 271 return os.path.abspath(os.path.join(path, root))
272 272
273 @staticmethod
274 def AssertVersion(min_version):
275 """Asserts git's version is at least min_version."""
276 def only_int(val):
277 if val.isdigit():
278 return int(val)
279 else:
280 return 0
281 current_version = GIT.Capture(['--version'])[0].split()[-1]
282 current_version_list = map(only_int, current_version.split('.'))
283 for min_ver in map(int, min_version.split('.')):
284 ver = current_version_list.pop(0)
285 if ver < min_ver:
286 return (False, current_version)
287 elif ver > min_ver:
288 return (True, current_version)
289 return (True, current_version)
290
273 291
274 class SVN(object): 292 class SVN(object):
275 COMMAND = "svn" 293 COMMAND = "svn"
276 294
277 @staticmethod 295 @staticmethod
278 def Run(args, in_directory): 296 def Run(args, in_directory):
279 """Runs svn, sending output to stdout. 297 """Runs svn, sending output to stdout.
280 298
281 Args: 299 Args:
282 args: A sequence of command line parameters to be passed to svn. 300 args: A sequence of command line parameters to be passed to svn.
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 if not cur_dir_repo_root: 745 if not cur_dir_repo_root:
728 return None 746 return None
729 747
730 while True: 748 while True:
731 parent = os.path.dirname(directory) 749 parent = os.path.dirname(directory)
732 if (SVN.CaptureInfo(parent, print_error=False).get( 750 if (SVN.CaptureInfo(parent, print_error=False).get(
733 "Repository Root") != cur_dir_repo_root): 751 "Repository Root") != cur_dir_repo_root):
734 break 752 break
735 directory = parent 753 directory = parent
736 return GetCasedPath(directory) 754 return GetCasedPath(directory)
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698