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

Side by Side Diff: gclient_scm.py

Issue 546022: gclient: git relative url implementation (Closed)
Patch Set: Created 10 years, 11 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.py ('k') | gclient_utils.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) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 __pychecker__ = 'unusednames=args,options' 242 __pychecker__ = 'unusednames=args,options'
243 if not os.path.isdir(self.checkout_path): 243 if not os.path.isdir(self.checkout_path):
244 print('\n________ couldn\'t run status in %s:\nThe directory ' 244 print('\n________ couldn\'t run status in %s:\nThe directory '
245 'does not exist.' % self.checkout_path) 245 'does not exist.' % self.checkout_path)
246 else: 246 else:
247 merge_base = self._Run(['merge-base', 'HEAD', 'origin']) 247 merge_base = self._Run(['merge-base', 'HEAD', 'origin'])
248 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) 248 self._Run(['diff', '--name-status', merge_base], redirect_stdout=False)
249 files = self._Run(['diff', '--name-only', merge_base]).split() 249 files = self._Run(['diff', '--name-only', merge_base]).split()
250 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 250 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
251 251
252 def FullUrlForRelativeUrl(self, url):
253 # Strip from last '/'
254 # Equivalent to unix basename
255 base_url = self.url
256 return base_url[:base_url.rfind('/')] + url
257
252 def _CheckMinVersion(self, min_version): 258 def _CheckMinVersion(self, min_version):
253 def only_int(val): 259 def only_int(val):
254 if val.isdigit(): 260 if val.isdigit():
255 return int(val) 261 return int(val)
256 else: 262 else:
257 return 0 263 return 0
258 version = self._Run(['--version'], cwd='.').split()[-1] 264 version = self._Run(['--version'], cwd='.').split()[-1]
259 version_list = map(only_int, version.split('.')) 265 version_list = map(only_int, version.split('.'))
260 min_version_list = map(int, min_version.split('.')) 266 min_version_list = map(int, min_version.split('.'))
261 for min_ver in min_version_list: 267 for min_ver in min_version_list:
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 command = ['status'] 527 command = ['status']
522 command.extend(args) 528 command.extend(args)
523 if not os.path.isdir(path): 529 if not os.path.isdir(path):
524 # svn status won't work if the directory doesn't exist. 530 # svn status won't work if the directory doesn't exist.
525 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " 531 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory "
526 "does not exist." 532 "does not exist."
527 % (' '.join(command), path)) 533 % (' '.join(command), path))
528 # There's no file list to retrieve. 534 # There's no file list to retrieve.
529 else: 535 else:
530 self.RunAndGetFileList(options, command, path, file_list) 536 self.RunAndGetFileList(options, command, path, file_list)
537
538 def FullUrlForRelativeUrl(self, url):
539 # Find the forth '/' and strip from there. A bit hackish.
540 return '/'.join(self.url.split('/')[:4]) + url
OLDNEW
« no previous file with comments | « gclient.py ('k') | gclient_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698