| OLD | NEW |
| 1 # Copyright 2014 Google Inc. All Rights Reserved. | 1 # Copyright 2014 Google Inc. All Rights Reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 # so that the new checkout can start immediately. | 522 # so that the new checkout can start immediately. |
| 523 _LOGGER.info('Erasing stale checkout directory: %s', repo.checkout_dir) | 523 _LOGGER.info('Erasing stale checkout directory: %s', repo.checkout_dir) |
| 524 | 524 |
| 525 # Any existing junctions to this repo must be removed otherwise the | 525 # Any existing junctions to this repo must be removed otherwise the |
| 526 # rename may fail. | 526 # rename may fail. |
| 527 for d in repo.remote_dirs: | 527 for d in repo.remote_dirs: |
| 528 j = os.path.abspath(os.path.join(repo.output_dir, d)) | 528 j = os.path.abspath(os.path.join(repo.output_dir, d)) |
| 529 _RemoveOrphanedJunction(options, j) | 529 _RemoveOrphanedJunction(options, j) |
| 530 | 530 |
| 531 newpath = _RenameCheckout(repo.checkout_dir, options.dry_run) | 531 newpath = _RenameCheckout(repo.checkout_dir, options.dry_run) |
| 532 body = lambda: _DeleteCheckout(newpath, options.dry_run) | 532 thread = threading.Thread(target=_DeleteCheckout, |
| 533 thread = threading.Thread(target=body) | 533 args=(newpath, options.dry_run)) |
| 534 threads.append(thread) | 534 threads.append(thread) |
| 535 thread.start() | 535 thread.start() |
| 536 | 536 |
| 537 # Create and update the checkout as necessary. | 537 # Create and update the checkout as necessary. |
| 538 if create_checkout: | 538 if create_checkout: |
| 539 _CreateCheckout(repo.checkout_dir, repo, options.dry_run) | 539 _CreateCheckout(repo.checkout_dir, repo, options.dry_run) |
| 540 else: | 540 else: |
| 541 _LOGGER.debug('Reusing checkout directory: %s', repo.checkout_dir) | 541 _LOGGER.debug('Reusing checkout directory: %s', repo.checkout_dir) |
| 542 if update_checkout: | 542 if update_checkout: |
| 543 _UpdateCheckout(repo.checkout_dir, repo, options.dry_run) | 543 _UpdateCheckout(repo.checkout_dir, repo, options.dry_run) |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 io.write(j) | 895 io.write(j) |
| 896 io.write('\n') | 896 io.write('\n') |
| 897 | 897 |
| 898 # Iterate all directories in the cache directory. Any that we didn't | 898 # Iterate all directories in the cache directory. Any that we didn't |
| 899 # specifically create or update should be cleaned up. Do this in parallel | 899 # specifically create or update should be cleaned up. Do this in parallel |
| 900 # so things are cleaned up as soon as possible. | 900 # so things are cleaned up as soon as possible. |
| 901 threads = [] | 901 threads = [] |
| 902 for path in glob.glob(os.path.join(options.cache_dir, '*')): | 902 for path in glob.glob(os.path.join(options.cache_dir, '*')): |
| 903 if os.path.join(path, 'src') not in checkout_dirs: | 903 if os.path.join(path, 'src') not in checkout_dirs: |
| 904 _LOGGER.debug('Erasing orphaned checkout directory: %s', path) | 904 _LOGGER.debug('Erasing orphaned checkout directory: %s', path) |
| 905 body = lambda: _DeleteCheckout(path, options.dry_run) | 905 thread = threading.Thread(target=_DeleteCheckout, |
| 906 thread = threading.Thread(target=body) | 906 args=(path, options.dry_run)) |
| 907 threads.append(thread) | 907 threads.append(thread) |
| 908 thread.start() | 908 thread.start() |
| 909 for thread in threads: | 909 for thread in threads: |
| 910 thread.join() | 910 thread.join() |
| 911 | 911 |
| 912 # Recursively process other dependencies. | 912 # Recursively process other dependencies. |
| 913 for repo in all_deps: | 913 for repo in all_deps: |
| 914 if not repo.recurse: | 914 if not repo.recurse: |
| 915 continue | 915 continue |
| 916 if not checkout_dirs[repo.checkout_dir] and not options.force: | 916 if not checkout_dirs[repo.checkout_dir] and not options.force: |
| 917 continue | 917 continue |
| 918 _RecurseRepository(options, repo) | 918 _RecurseRepository(options, repo) |
| 919 | 919 |
| 920 return | 920 return |
| 921 | 921 |
| 922 | 922 |
| 923 if __name__ == '__main__': | 923 if __name__ == '__main__': |
| 924 main() | 924 main() |
| OLD | NEW |