Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Meta checkout manager supporting both Subversion and GIT. | 6 """Meta checkout manager supporting both Subversion and GIT. |
| 7 | 7 |
| 8 Files | 8 Files |
| 9 .gclient : Current client configuration, written by 'config' command. | 9 .gclient : Current client configuration, written by 'config' command. |
| 10 Format is a Python script defining 'solutions', a list whose | 10 Format is a Python script defining 'solutions', a list whose |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 (name, tree[name].hierarchy(), self.hierarchy())) | 332 (name, tree[name].hierarchy(), self.hierarchy())) |
| 333 self.dependencies.append(Dependency(self, name, url, None, None, None, | 333 self.dependencies.append(Dependency(self, name, url, None, None, None, |
| 334 None, should_process)) | 334 None, should_process)) |
| 335 logging.debug('Loaded: %s' % str(self)) | 335 logging.debug('Loaded: %s' % str(self)) |
| 336 | 336 |
| 337 # Arguments number differs from overridden method | 337 # Arguments number differs from overridden method |
| 338 # pylint: disable=W0221 | 338 # pylint: disable=W0221 |
| 339 def run(self, revision_overrides, command, args, work_queue, options): | 339 def run(self, revision_overrides, command, args, work_queue, options): |
| 340 """Runs 'command' before parsing the DEPS in case it's a initial checkout | 340 """Runs 'command' before parsing the DEPS in case it's a initial checkout |
| 341 or a revert.""" | 341 or a revert.""" |
| 342 | |
| 343 def maybeGetParentRevision(options): | |
| 344 """If we are performing an update and --transitive is set, set the | |
| 345 revision to the parent's revision. If we have an explicit revision | |
| 346 do nothing.""" | |
| 347 _, revision = gclient_utils.SplitUrlRevision(self.parsed_url) | |
| 348 if (command == 'update' and | |
|
M-A Ruel
2011/04/26 18:38:49
style nit: (optional) What about?
if (command ==
Florian Loitsch
2011/04/27 10:58:23
Done.
| |
| 349 options.transitive and | |
| 350 not revision and | |
| 351 not options.revision): | |
| 352 options.revision = revision_overrides.get(self.parent.name) | |
| 353 if options.verbose and options.revision: | |
| 354 print("Using parent's revision date: %s" % options.revision) | |
| 355 # If the parent has a revision override, then it must have been | |
| 356 # converted to date format. | |
| 357 assert (not options.revision or | |
| 358 gclient_utils.IsDateRevision(options.revision)) | |
| 359 | |
| 360 def maybeConvertToDateRevision(options): | |
| 361 """If we are performing an update and --transitive is set, convert the | |
| 362 revision to a date-revision (if necessary). Instead of having | |
| 363 -r 101 replace the revision with the time stamp of 101 (e.g. | |
| 364 "{2011-18-04}"). | |
| 365 This way dependencies are upgraded to the revision they had at the | |
| 366 check-in of revision 101.""" | |
| 367 if (command == 'update' and | |
| 368 options.transitive and | |
| 369 options.revision and | |
| 370 not gclient_utils.IsDateRevision(options.revision)): | |
| 371 revision_date = scm.GetRevisionDate(options.revision) | |
| 372 revision = gclient_utils.MakeDateRevision(revision_date) | |
| 373 if options.verbose: | |
| 374 print("Updating revision override from %s to %s." % | |
| 375 (options.revision, revision)) | |
| 376 revision_overrides[self.name] = revision | |
| 377 | |
| 342 assert self._file_list == [] | 378 assert self._file_list == [] |
| 343 if not self.should_process: | 379 if not self.should_process: |
| 344 return | 380 return |
| 345 # When running runhooks, there's no need to consult the SCM. | 381 # When running runhooks, there's no need to consult the SCM. |
| 346 # All known hooks are expected to run unconditionally regardless of working | 382 # All known hooks are expected to run unconditionally regardless of working |
| 347 # copy state, so skip the SCM status check. | 383 # copy state, so skip the SCM status check. |
| 348 run_scm = command not in ('runhooks', None) | 384 run_scm = command not in ('runhooks', None) |
| 349 self.parsed_url = self.LateOverride(self.url) | 385 self.parsed_url = self.LateOverride(self.url) |
| 350 if run_scm and self.parsed_url: | 386 if run_scm and self.parsed_url: |
| 351 if isinstance(self.parsed_url, self.FileImpl): | 387 if isinstance(self.parsed_url, self.FileImpl): |
| 352 # Special support for single-file checkout. | 388 # Special support for single-file checkout. |
| 353 if not command in (None, 'cleanup', 'diff', 'pack', 'status'): | 389 if not command in (None, 'cleanup', 'diff', 'pack', 'status'): |
| 354 options.revision = self.parsed_url.GetRevision() | 390 options.revision = self.parsed_url.GetRevision() |
| 355 scm = gclient_scm.SVNWrapper(self.parsed_url.GetPath(), | 391 scm = gclient_scm.SVNWrapper(self.parsed_url.GetPath(), |
| 356 self.root_dir(), | 392 self.root_dir(), |
| 357 self.name) | 393 self.name) |
| 358 scm.RunCommand('updatesingle', options, | 394 scm.RunCommand('updatesingle', options, |
| 359 args + [self.parsed_url.GetFilename()], | 395 args + [self.parsed_url.GetFilename()], |
| 360 self._file_list) | 396 self._file_list) |
| 361 else: | 397 else: |
| 362 # Create a shallow copy to mutate revision. | 398 # Create a shallow copy to mutate revision. |
| 363 options = copy.copy(options) | 399 options = copy.copy(options) |
| 364 options.revision = revision_overrides.get(self.name) | 400 options.revision = revision_overrides.get(self.name) |
| 401 maybeGetParentRevision(options) | |
| 365 scm = gclient_scm.CreateSCM(self.parsed_url, self.root_dir(), self.name) | 402 scm = gclient_scm.CreateSCM(self.parsed_url, self.root_dir(), self.name) |
| 366 scm.RunCommand(command, options, args, self._file_list) | 403 scm.RunCommand(command, options, args, self._file_list) |
| 404 maybeConvertToDateRevision(options) | |
| 367 self._file_list = [os.path.join(self.name, f.strip()) | 405 self._file_list = [os.path.join(self.name, f.strip()) |
| 368 for f in self._file_list] | 406 for f in self._file_list] |
| 369 self.processed = True | 407 self.processed = True |
| 370 if self.recursion_limit() > 0: | 408 if self.recursion_limit() > 0: |
| 371 # Then we can parse the DEPS file. | 409 # Then we can parse the DEPS file. |
| 372 self.ParseDepsFile() | 410 self.ParseDepsFile() |
| 373 # Adjust the implicit dependency requirement; e.g. if a DEPS file contains | 411 # Adjust the implicit dependency requirement; e.g. if a DEPS file contains |
| 374 # both src/foo and src/foo/bar, src/foo/bar is implicitly dependent of | 412 # both src/foo and src/foo/bar, src/foo/bar is implicitly dependent of |
| 375 # src/foo. Yes, it's O(n^2)... It's important to do that before | 413 # src/foo. Yes, it's O(n^2)... It's important to do that before |
| 376 # enqueueing them. | 414 # enqueueing them. |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1036 parser.add_option('-n', '--nohooks', action='store_true', | 1074 parser.add_option('-n', '--nohooks', action='store_true', |
| 1037 help='don\'t run hooks after the update is complete') | 1075 help='don\'t run hooks after the update is complete') |
| 1038 parser.add_option('-r', '--revision', action='append', | 1076 parser.add_option('-r', '--revision', action='append', |
| 1039 dest='revisions', metavar='REV', default=[], | 1077 dest='revisions', metavar='REV', default=[], |
| 1040 help='Enforces revision/hash for the solutions with the ' | 1078 help='Enforces revision/hash for the solutions with the ' |
| 1041 'format src@rev. The src@ part is optional and can be ' | 1079 'format src@rev. The src@ part is optional and can be ' |
| 1042 'skipped. -r can be used multiple times when .gclient ' | 1080 'skipped. -r can be used multiple times when .gclient ' |
| 1043 'has multiple solutions configured and will work even ' | 1081 'has multiple solutions configured and will work even ' |
| 1044 'if the src@ part is skipped. Note that specifying ' | 1082 'if the src@ part is skipped. Note that specifying ' |
| 1045 '--revision means your safesync_url gets ignored.') | 1083 '--revision means your safesync_url gets ignored.') |
| 1084 parser.add_option('-t', '--transitive', action='store_true', | |
| 1085 help='When a revision is specified (in the DEPS file or ' | |
| 1086 'with the command-line flag), transitively update ' | |
| 1087 'the dependencies to the date of the given revision.') | |
|
M-A Ruel
2011/04/26 18:38:49
Can you note it's supported only for svn at the mo
Florian Loitsch
2011/04/27 10:58:23
Done.
| |
| 1046 parser.add_option('-H', '--head', action='store_true', | 1088 parser.add_option('-H', '--head', action='store_true', |
| 1047 help='skips any safesync_urls specified in ' | 1089 help='skips any safesync_urls specified in ' |
| 1048 'configured solutions and sync to head instead') | 1090 'configured solutions and sync to head instead') |
| 1049 parser.add_option('-D', '--delete_unversioned_trees', action='store_true', | 1091 parser.add_option('-D', '--delete_unversioned_trees', action='store_true', |
| 1050 help='delete any dependency that have been removed from ' | 1092 help='delete any dependency that have been removed from ' |
| 1051 'last sync as long as there is no local modification. ' | 1093 'last sync as long as there is no local modification. ' |
| 1052 'Coupled with --force, it will remove them even with ' | 1094 'Coupled with --force, it will remove them even with ' |
| 1053 'local modifications') | 1095 'local modifications') |
| 1054 parser.add_option('-R', '--reset', action='store_true', | 1096 parser.add_option('-R', '--reset', action='store_true', |
| 1055 help='resets any local changes before updating (git only)') | 1097 help='resets any local changes before updating (git only)') |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1307 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1266 print >> sys.stderr, 'Error: %s' % str(e) | 1308 print >> sys.stderr, 'Error: %s' % str(e) |
| 1267 return 1 | 1309 return 1 |
| 1268 | 1310 |
| 1269 | 1311 |
| 1270 if '__main__' == __name__: | 1312 if '__main__' == __name__: |
| 1271 fix_encoding.fix_encoding() | 1313 fix_encoding.fix_encoding() |
| 1272 sys.exit(Main(sys.argv[1:])) | 1314 sys.exit(Main(sys.argv[1:])) |
| 1273 | 1315 |
| 1274 # vim: ts=2:sw=2:tw=80:et: | 1316 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |