OLD | NEW |
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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 run('config', '--' + scope, option, value) | 749 run('config', '--' + scope, option, value) |
750 | 750 |
751 | 751 |
752 def get_dirty_files(): | 752 def get_dirty_files(): |
753 # Make sure index is up-to-date before running diff-index. | 753 # Make sure index is up-to-date before running diff-index. |
754 run_with_retcode('update-index', '--refresh', '-q') | 754 run_with_retcode('update-index', '--refresh', '-q') |
755 return run('diff-index', '--name-status', 'HEAD') | 755 return run('diff-index', '--name-status', 'HEAD') |
756 | 756 |
757 | 757 |
758 def is_dirty_git_tree(cmd): | 758 def is_dirty_git_tree(cmd): |
| 759 w = lambda s: sys.stderr.write(s+"\n") |
| 760 |
759 dirty = get_dirty_files() | 761 dirty = get_dirty_files() |
760 if dirty: | 762 if dirty: |
761 print 'Cannot %s with a dirty tree. '\ | 763 w('Cannot %s with a dirty tree. Commit, freeze or stash your changes first.' |
762 'Commit, freeze or stash your changes first.' % cmd | 764 % cmd) |
763 print 'Uncommitted files: (git diff-index --name-status HEAD)' | 765 w('Uncommitted files: (git diff-index --name-status HEAD)') |
764 print dirty[:4096] | 766 w(dirty[:4096]) |
765 if len(dirty) > 4096: # pragma: no cover | 767 if len(dirty) > 4096: # pragma: no cover |
766 print '... (run "git diff-index --name-status HEAD" to see full output).' | 768 w('... (run "git diff-index --name-status HEAD" to see full output).') |
767 return True | 769 return True |
768 return False | 770 return False |
769 | 771 |
770 | 772 |
771 def status(): | 773 def status(): |
772 """Returns a parsed version of git-status. | 774 """Returns a parsed version of git-status. |
773 | 775 |
774 Returns a generator of (current_name, (lstat, rstat, src)) pairs where: | 776 Returns a generator of (current_name, (lstat, rstat, src)) pairs where: |
775 * current_name is the name of the file | 777 * current_name is the name of the file |
776 * lstat is the left status code letter from git-status | 778 * lstat is the left status code letter from git-status |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 ['HEAD']) | 1013 ['HEAD']) |
1012 | 1014 |
1013 | 1015 |
1014 def clone_file(repository, new_workdir, link, operation): | 1016 def clone_file(repository, new_workdir, link, operation): |
1015 if not os.path.exists(os.path.join(repository, link)): | 1017 if not os.path.exists(os.path.join(repository, link)): |
1016 return | 1018 return |
1017 link_dir = os.path.dirname(os.path.join(new_workdir, link)) | 1019 link_dir = os.path.dirname(os.path.join(new_workdir, link)) |
1018 if not os.path.exists(link_dir): | 1020 if not os.path.exists(link_dir): |
1019 os.makedirs(link_dir) | 1021 os.makedirs(link_dir) |
1020 operation(os.path.join(repository, link), os.path.join(new_workdir, link)) | 1022 operation(os.path.join(repository, link), os.path.join(new_workdir, link)) |
OLD | NEW |