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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 yield branch, parent | 893 yield branch, parent |
894 parent_to_branches[parent].discard(branch) | 894 parent_to_branches[parent].discard(branch) |
895 del branch_tree[branch] | 895 del branch_tree[branch] |
896 | 896 |
897 | 897 |
898 def tree(treeref, recurse=False): | 898 def tree(treeref, recurse=False): |
899 """Returns a dict representation of a git tree object. | 899 """Returns a dict representation of a git tree object. |
900 | 900 |
901 Args: | 901 Args: |
902 treeref (str) - a git ref which resolves to a tree (commits count as trees). | 902 treeref (str) - a git ref which resolves to a tree (commits count as trees). |
903 recurse (bool) - include all of the tree's decendants too. File names will | 903 recurse (bool) - include all of the tree's descendants too. File names will |
904 take the form of 'some/path/to/file'. | 904 take the form of 'some/path/to/file'. |
905 | 905 |
906 Return format: | 906 Return format: |
907 { 'file_name': (mode, type, ref) } | 907 { 'file_name': (mode, type, ref) } |
908 | 908 |
909 mode is an integer where: | 909 mode is an integer where: |
910 * 0040000 - Directory | 910 * 0040000 - Directory |
911 * 0100644 - Regular non-executable file | 911 * 0100644 - Regular non-executable file |
912 * 0100664 - Regular non-executable group-writeable file | 912 * 0100664 - Regular non-executable group-writeable file |
913 * 0100755 - Regular executable file | 913 * 0100755 - Regular executable file |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 ['HEAD']) | 1013 ['HEAD']) |
1014 | 1014 |
1015 | 1015 |
1016 def clone_file(repository, new_workdir, link, operation): | 1016 def clone_file(repository, new_workdir, link, operation): |
1017 if not os.path.exists(os.path.join(repository, link)): | 1017 if not os.path.exists(os.path.join(repository, link)): |
1018 return | 1018 return |
1019 link_dir = os.path.dirname(os.path.join(new_workdir, link)) | 1019 link_dir = os.path.dirname(os.path.join(new_workdir, link)) |
1020 if not os.path.exists(link_dir): | 1020 if not os.path.exists(link_dir): |
1021 os.makedirs(link_dir) | 1021 os.makedirs(link_dir) |
1022 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 |