Chromium Code Reviews

Side by Side Diff: git_common.py

Issue 2204423002: Fix freeze when running from a non-root directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly. 5 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly.
6 # Derived from https://gist.github.com/aljungberg/626518 6 # Derived from https://gist.github.com/aljungberg/626518
7 import multiprocessing.pool 7 import multiprocessing.pool
8 from multiprocessing.pool import IMapIterator 8 from multiprocessing.pool import IMapIterator
9 def wrapper(func): 9 def wrapper(func):
10 def wrap(self, timeout=None): 10 def wrap(self, timeout=None):
(...skipping 387 matching lines...)
398 return run('diff', oldrev, newrev, *args) 398 return run('diff', oldrev, newrev, *args)
399 399
400 400
401 def freeze(): 401 def freeze():
402 took_action = False 402 took_action = False
403 key = 'depot-tools.freeze-size-limit' 403 key = 'depot-tools.freeze-size-limit'
404 MB = 2**20 404 MB = 2**20
405 limit_mb = get_config_int(key, 100) 405 limit_mb = get_config_int(key, 100)
406 untracked_bytes = 0 406 untracked_bytes = 0
407 407
408 root_path = repo_root()
409
408 for f, s in status(): 410 for f, s in status():
409 if is_unmerged(s): 411 if is_unmerged(s):
410 die("Cannot freeze unmerged changes!") 412 die("Cannot freeze unmerged changes!")
411 if limit_mb > 0: 413 if limit_mb > 0:
412 if s.lstat == '?': 414 if s.lstat == '?':
413 untracked_bytes += os.stat(f).st_size 415 untracked_bytes += os.stat(os.path.join(root_path, f)).st_size
414 if untracked_bytes > limit_mb * MB: 416 if untracked_bytes > limit_mb * MB:
415 die("""\ 417 die("""\
416 You appear to have too much untracked+unignored data in your git 418 You appear to have too much untracked+unignored data in your git
417 checkout: %.1f / %d MB. 419 checkout: %.1f / %d MB.
418 420
419 Run `git status` to see what it is. 421 Run `git status` to see what it is.
420 422
421 In addition to making many git commands slower, this will prevent 423 In addition to making many git commands slower, this will prevent
422 depot_tools from freezing your in-progress changes. 424 depot_tools from freezing your in-progress changes.
423 425
(...skipping 585 matching lines...)
1009 ['HEAD']) 1011 ['HEAD'])
1010 1012
1011 1013
1012 def clone_file(repository, new_workdir, link, operation): 1014 def clone_file(repository, new_workdir, link, operation):
1013 if not os.path.exists(os.path.join(repository, link)): 1015 if not os.path.exists(os.path.join(repository, link)):
1014 return 1016 return
1015 link_dir = os.path.dirname(os.path.join(new_workdir, link)) 1017 link_dir = os.path.dirname(os.path.join(new_workdir, link))
1016 if not os.path.exists(link_dir): 1018 if not os.path.exists(link_dir):
1017 os.makedirs(link_dir) 1019 os.makedirs(link_dir)
1018 operation(os.path.join(repository, link), os.path.join(new_workdir, link)) 1020 operation(os.path.join(repository, link), os.path.join(new_workdir, link))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine