Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: tools/git-sync-deps

Issue 1431713002: tools/git-sync-deps: speed up common case by skipping fetch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-11-03 (Tuesday) 12:37:42 EST Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« 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 #!/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
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
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
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:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698