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 if 0 == subprocess.call( |
| 137 [git, 'checkout', '--quiet', checkoutable], cwd=directory): |
| 138 # if this succeeds, skip slow `git fetch`. |
| 139 if verbose: |
| 140 sys.stdout.write('%s\n @ %s\n' % (directory, checkoutable)) |
| 141 return |
| 142 |
136 subprocess.check_call([git, 'fetch', '--quiet'], cwd=directory) | 143 subprocess.check_call([git, 'fetch', '--quiet'], cwd=directory) |
137 | 144 |
138 subprocess.check_call( | 145 subprocess.check_call( |
139 [git, 'checkout', '--quiet', checkoutable], cwd=directory) | 146 [git, 'checkout', '--quiet', checkoutable], cwd=directory) |
140 | 147 |
141 if verbose: | 148 if verbose: |
142 sys.stdout.write('%s\n @ %s\n' % (directory, checkoutable)) # Success. | 149 sys.stdout.write('%s\n @ %s\n' % (directory, checkoutable)) # Success. |
143 | 150 |
144 | 151 |
145 def parse_file_to_dict(path): | 152 def parse_file_to_dict(path): |
(...skipping 23 matching lines...) Expand all Loading... |
169 os_specific_dependencies = deps_file.get('deps_os', []) | 176 os_specific_dependencies = deps_file.get('deps_os', []) |
170 for os_name in command_line_os_requests: | 177 for os_name in command_line_os_requests: |
171 # Add OS-specific dependencies | 178 # Add OS-specific dependencies |
172 if os_name in os_specific_dependencies: | 179 if os_name in os_specific_dependencies: |
173 dependencies.update(os_specific_dependencies[os_name]) | 180 dependencies.update(os_specific_dependencies[os_name]) |
174 list_of_arg_lists = [] | 181 list_of_arg_lists = [] |
175 for directory in dependencies: | 182 for directory in dependencies: |
176 if '@' in dependencies[directory]: | 183 if '@' in dependencies[directory]: |
177 repo, checkoutable = dependencies[directory].split('@', 1) | 184 repo, checkoutable = dependencies[directory].split('@', 1) |
178 else: | 185 else: |
179 repo, checkoutable = dependencies[directory], 'origin/master' | 186 raise Exception("please specify commit or tag") |
180 | 187 |
181 relative_directory = os.path.join(deps_file_directory, directory) | 188 relative_directory = os.path.join(deps_file_directory, directory) |
182 | 189 |
183 list_of_arg_lists.append( | 190 list_of_arg_lists.append( |
184 (git, repo, checkoutable, relative_directory, verbose)) | 191 (git, repo, checkoutable, relative_directory, verbose)) |
185 | 192 |
186 multithread(git_checkout_to_directory, list_of_arg_lists) | 193 multithread(git_checkout_to_directory, list_of_arg_lists) |
187 | 194 |
188 for directory in deps_file.get('recursedeps', []): | 195 for directory in deps_file.get('recursedeps', []): |
189 recursive_path = os.path.join(deps_file_directory, directory, 'DEPS') | 196 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: | 217 if '--help' in argv or '-h' in argv: |
211 usage(deps_file_path) | 218 usage(deps_file_path) |
212 return 1 | 219 return 1 |
213 | 220 |
214 git_sync_deps(deps_file_path, argv, verbose) | 221 git_sync_deps(deps_file_path, argv, verbose) |
215 return 0 | 222 return 0 |
216 | 223 |
217 | 224 |
218 if __name__ == '__main__': | 225 if __name__ == '__main__': |
219 exit(main(sys.argv[1:])) | 226 exit(main(sys.argv[1:])) |
OLD | NEW |