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

Side by Side Diff: gclient_utils.py

Issue 2786013: Incremental changes towards more efficient refactoring of gclient.py (Closed)
Patch Set: Created 10 years, 6 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 2009 Google Inc. All Rights Reserved. 1 # Copyright 2009 Google Inc. All Rights Reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 295
296 def IsUsingGit(root, paths): 296 def IsUsingGit(root, paths):
297 """Returns True if we're using git to manage any of our checkouts. 297 """Returns True if we're using git to manage any of our checkouts.
298 |entries| is a list of paths to check.""" 298 |entries| is a list of paths to check."""
299 for path in paths: 299 for path in paths:
300 if os.path.exists(os.path.join(root, path, '.git')): 300 if os.path.exists(os.path.join(root, path, '.git')):
301 return True 301 return True
302 return False 302 return False
303 303
304 def FindGclientRoot(from_dir): 304 def FindGclientRoot(from_dir, filename='.gclient'):
305 """Tries to find the gclient root.""" 305 """Tries to find the gclient root."""
306 path = os.path.realpath(from_dir) 306 path = os.path.realpath(from_dir)
307 while not os.path.exists(os.path.join(path, '.gclient')): 307 while not os.path.exists(os.path.join(path, filename)):
308 next = os.path.split(path) 308 next = os.path.split(path)
309 if not next[1]: 309 if not next[1]:
310 return None 310 return None
311 path = next[0] 311 path = next[0]
312 logging.info('Found gclient root at ' + path) 312 logging.info('Found gclient root at ' + path)
313 return path 313 return path
314 314
315
315 def PathDifference(root, subpath): 316 def PathDifference(root, subpath):
316 """Returns the difference subpath minus root.""" 317 """Returns the difference subpath minus root."""
317 root = os.path.realpath(root) 318 root = os.path.realpath(root)
318 subpath = os.path.realpath(subpath) 319 subpath = os.path.realpath(subpath)
319 if not subpath.startswith(root): 320 if not subpath.startswith(root):
320 return None 321 return None
321 # If the root does not have a trailing \ or /, we add it so the returned 322 # If the root does not have a trailing \ or /, we add it so the returned
322 # path starts immediately after the seperator regardless of whether it is 323 # path starts immediately after the seperator regardless of whether it is
323 # provided. 324 # provided.
324 root = os.path.join(root, '') 325 root = os.path.join(root, '')
(...skipping 21 matching lines...) Expand all
346 config_path = FindFileUpwards(config_file, path) 347 config_path = FindFileUpwards(config_file, path)
347 348
348 if not config_path: 349 if not config_path:
349 print "Can't find %s" % config_file 350 print "Can't find %s" % config_file
350 return None 351 return None
351 352
352 env = {} 353 env = {}
353 execfile(config_path, env) 354 execfile(config_path, env)
354 config_dir = os.path.dirname(config_path) 355 config_dir = os.path.dirname(config_path)
355 return config_dir, env['entries'] 356 return config_dir, env['entries']
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