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

Side by Side Diff: depot_tools/gclient_utils.py

Issue 3342020: Do not blindly assume that a .gclient file in a parent directory belongs to t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: '' Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | depot_tools/tests/gclient_smoketest.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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if len(in_line): 329 if len(in_line):
330 filter_fn(in_line) 330 filter_fn(in_line)
331 rv = kid.wait() 331 rv = kid.wait()
332 if rv: 332 if rv:
333 raise Error('failed to run command: %s' % ' '.join(args)) 333 raise Error('failed to run command: %s' % ' '.join(args))
334 return 0 334 return 0
335 335
336 336
337 def FindGclientRoot(from_dir, filename='.gclient'): 337 def FindGclientRoot(from_dir, filename='.gclient'):
338 """Tries to find the gclient root.""" 338 """Tries to find the gclient root."""
339 path = os.path.realpath(from_dir) 339 real_from_dir = os.path.realpath(from_dir)
340 path = real_from_dir
340 while not os.path.exists(os.path.join(path, filename)): 341 while not os.path.exists(os.path.join(path, filename)):
341 split_path = os.path.split(path) 342 split_path = os.path.split(path)
342 if not split_path[1]: 343 if not split_path[1]:
343 return None 344 return None
344 path = split_path[0] 345 path = split_path[0]
346
347 # If we did not find the file in the current directory, make sure we are in a
348 # sub directory that is controlled by this configuration.
349 if path != real_from_dir:
350 entries_filename = os.path.join(path, filename + '_entries')
351 if not os.path.exists(entries_filename):
352 # If .gclient_entries does not exist, a previous call to gclient sync
353 # might have failed. In that case, we cannot verify that the .gclient
354 # is the one we want to use. In order to not to cause too much trouble,
355 # just issue a warning and return the path anyway.
356 print >>sys.stderr, ("%s file in parent directory %s might not be the "
357 "file you want to use" % (filename, path))
358 return path
359 scope = {}
360 try:
361 exec(FileRead(entries_filename), scope)
362 except SyntaxError, e:
363 SyntaxErrorToError(filename, e)
364 all_directories = scope['entries'].keys()
365 path_to_check = real_from_dir[len(path)+1:]
366 while path_to_check:
367 if path_to_check in all_directories:
368 return path
369 path_to_check = os.path.dirname(path_to_check)
370 return None
371
345 logging.info('Found gclient root at ' + path) 372 logging.info('Found gclient root at ' + path)
346 return path 373 return path
347 374
348 375
349 def PathDifference(root, subpath): 376 def PathDifference(root, subpath):
350 """Returns the difference subpath minus root.""" 377 """Returns the difference subpath minus root."""
351 root = os.path.realpath(root) 378 root = os.path.realpath(root)
352 subpath = os.path.realpath(subpath) 379 subpath = os.path.realpath(subpath)
353 if not subpath.startswith(root): 380 if not subpath.startswith(root):
354 return None 381 return None
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if exception: 552 if exception:
526 self.parent.exceptions.append(exception) 553 self.parent.exceptions.append(exception)
527 if self.parent.progress: 554 if self.parent.progress:
528 self.parent.progress.update(1) 555 self.parent.progress.update(1)
529 assert not self.item.name in self.parent.ran 556 assert not self.item.name in self.parent.ran
530 if not self.item.name in self.parent.ran: 557 if not self.item.name in self.parent.ran:
531 self.parent.ran.append(self.item.name) 558 self.parent.ran.append(self.item.name)
532 finally: 559 finally:
533 self.parent.ready_cond.notifyAll() 560 self.parent.ready_cond.notifyAll()
534 self.parent.ready_cond.release() 561 self.parent.ready_cond.release()
OLDNEW
« no previous file with comments | « no previous file | depot_tools/tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698