OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2014 Google Inc. | 2 # Copyright 2014 Google Inc. |
3 # | 3 # |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 | 7 |
8 """Parse a DEPS file and git checkout all of the dependencies. | 8 """Parse a DEPS file and git checkout all of the dependencies. |
9 | 9 |
10 Args: | 10 Args: |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 # if the directory exists, but isn't a git repo, you will modify | 126 # if the directory exists, but isn't a git repo, you will modify |
127 # the parent repostory, which isn't what you want. | 127 # the parent repostory, which isn't what you want. |
128 sys.stdout.write('%s\n IS NOT TOP-LEVEL GIT DIRECTORY.\n' % directory) | 128 sys.stdout.write('%s\n IS NOT TOP-LEVEL GIT DIRECTORY.\n' % directory) |
129 return | 129 return |
130 | 130 |
131 # Check to see if this repo is disabled. Quick return. | 131 # Check to see if this repo is disabled. Quick return. |
132 if git_repository_sync_is_disabled(git, directory): | 132 if git_repository_sync_is_disabled(git, directory): |
133 sys.stdout.write('%s\n SYNC IS DISABLED.\n' % directory) | 133 sys.stdout.write('%s\n SYNC IS DISABLED.\n' % directory) |
134 return | 134 return |
135 | 135 |
136 try: | |
137 # if this succeeds, skip slow `git fetch`. | |
138 subprocess.check_call( | |
mtklein
2015/11/03 17:29:29
if 0 == subprocess.call(...):
if verbose:
..
hal.canary
2015/11/03 17:35:15
done
| |
139 [git, 'checkout', '--quiet', checkoutable], cwd=directory) | |
140 if verbose: | |
141 sys.stdout.write('%s\n @ %s\n' % (directory, checkoutable)) | |
142 return | |
143 except subprocess.CalledProcessError: | |
144 pass | |
145 | |
136 subprocess.check_call([git, 'fetch', '--quiet'], cwd=directory) | 146 subprocess.check_call([git, 'fetch', '--quiet'], cwd=directory) |
137 | 147 |
138 subprocess.check_call( | 148 subprocess.check_call( |
139 [git, 'checkout', '--quiet', checkoutable], cwd=directory) | 149 [git, 'checkout', '--quiet', checkoutable], cwd=directory) |
140 | 150 |
141 if verbose: | 151 if verbose: |
142 sys.stdout.write('%s\n @ %s\n' % (directory, checkoutable)) # Success. | 152 sys.stdout.write('%s\n @ %s\n' % (directory, checkoutable)) # Success. |
143 | 153 |
144 | 154 |
145 def parse_file_to_dict(path): | 155 def parse_file_to_dict(path): |
(...skipping 23 matching lines...) Expand all Loading... | |
169 os_specific_dependencies = deps_file.get('deps_os', []) | 179 os_specific_dependencies = deps_file.get('deps_os', []) |
170 for os_name in command_line_os_requests: | 180 for os_name in command_line_os_requests: |
171 # Add OS-specific dependencies | 181 # Add OS-specific dependencies |
172 if os_name in os_specific_dependencies: | 182 if os_name in os_specific_dependencies: |
173 dependencies.update(os_specific_dependencies[os_name]) | 183 dependencies.update(os_specific_dependencies[os_name]) |
174 list_of_arg_lists = [] | 184 list_of_arg_lists = [] |
175 for directory in dependencies: | 185 for directory in dependencies: |
176 if '@' in dependencies[directory]: | 186 if '@' in dependencies[directory]: |
177 repo, checkoutable = dependencies[directory].split('@', 1) | 187 repo, checkoutable = dependencies[directory].split('@', 1) |
178 else: | 188 else: |
179 repo, checkoutable = dependencies[directory], 'origin/master' | 189 raise Exception("please specify commit or tag") |
180 | 190 |
181 relative_directory = os.path.join(deps_file_directory, directory) | 191 relative_directory = os.path.join(deps_file_directory, directory) |
182 | 192 |
183 list_of_arg_lists.append( | 193 list_of_arg_lists.append( |
184 (git, repo, checkoutable, relative_directory, verbose)) | 194 (git, repo, checkoutable, relative_directory, verbose)) |
185 | 195 |
186 multithread(git_checkout_to_directory, list_of_arg_lists) | 196 multithread(git_checkout_to_directory, list_of_arg_lists) |
187 | 197 |
188 for directory in deps_file.get('recursedeps', []): | 198 for directory in deps_file.get('recursedeps', []): |
189 recursive_path = os.path.join(deps_file_directory, directory, 'DEPS') | 199 recursive_path = os.path.join(deps_file_directory, directory, 'DEPS') |
(...skipping 20 matching lines...) Expand all Loading... | |
210 if '--help' in argv or '-h' in argv: | 220 if '--help' in argv or '-h' in argv: |
211 usage(deps_file_path) | 221 usage(deps_file_path) |
212 return 1 | 222 return 1 |
213 | 223 |
214 git_sync_deps(deps_file_path, argv, verbose) | 224 git_sync_deps(deps_file_path, argv, verbose) |
215 return 0 | 225 return 0 |
216 | 226 |
217 | 227 |
218 if __name__ == '__main__': | 228 if __name__ == '__main__': |
219 exit(main(sys.argv[1:])) | 229 exit(main(sys.argv[1:])) |
OLD | NEW |