|
26 | 26 | import sys
|
27 | 27 | import tempfile
|
28 | 28 | import time
|
29 |
| -from typing import List, NamedTuple, Optional, Set, Union |
| 29 | +from typing import List, NamedTuple, Optional, Set, Tuple, Union |
30 | 30 | import urllib.error
|
31 | 31 | import urllib.parse
|
32 | 32 | import urllib.request
|
@@ -2006,6 +2006,54 @@ def _monitor_loop():
|
2006 | 2006 |
|
2007 | 2007 | return _threading.Thread(target=_monitor_loop, daemon=True)
|
2008 | 2008 |
|
| 2009 | + def _UpdateManifestLists( |
| 2010 | + self, |
| 2011 | + opt: optparse.Values, |
| 2012 | + err_event: multiprocessing.Event, |
| 2013 | + errors: List[Exception], |
| 2014 | + ) -> Tuple[bool, bool]: |
| 2015 | + """Updates project lists and copy/link files for all manifests. |
| 2016 | +
|
| 2017 | + Args: |
| 2018 | + opt: Program options from optparse. |
| 2019 | + err_event: An event to set if any error occurs. |
| 2020 | + errors: A list to append any encountered exceptions to. |
| 2021 | +
|
| 2022 | + Returns: |
| 2023 | + A tuple (err_update_projects, err_update_linkfiles) indicating |
| 2024 | + an error for each task. |
| 2025 | + """ |
| 2026 | + err_update_projects = False |
| 2027 | + err_update_linkfiles = False |
| 2028 | + for m in self.ManifestList(opt): |
| 2029 | + if m.IsMirror or m.IsArchive: |
| 2030 | + continue |
| 2031 | + |
| 2032 | + try: |
| 2033 | + self.UpdateProjectList(opt, m) |
| 2034 | + except Exception as e: |
| 2035 | + err_event.set() |
| 2036 | + err_update_projects = True |
| 2037 | + errors.append(e) |
| 2038 | + if isinstance(e, DeleteWorktreeError): |
| 2039 | + errors.extend(e.aggregate_errors) |
| 2040 | + if opt.fail_fast: |
| 2041 | + logger.error("error: Local checkouts *not* updated.") |
| 2042 | + raise SyncFailFastError(aggregate_errors=errors) |
| 2043 | + |
| 2044 | + try: |
| 2045 | + self.UpdateCopyLinkfileList(m) |
| 2046 | + except Exception as e: |
| 2047 | + err_event.set() |
| 2048 | + err_update_linkfiles = True |
| 2049 | + errors.append(e) |
| 2050 | + if opt.fail_fast: |
| 2051 | + logger.error( |
| 2052 | + "error: Local update copyfile or linkfile failed." |
| 2053 | + ) |
| 2054 | + raise SyncFailFastError(aggregate_errors=errors) |
| 2055 | + return err_update_projects, err_update_linkfiles |
| 2056 | + |
2009 | 2057 | def _SyncPhased(
|
2010 | 2058 | self,
|
2011 | 2059 | opt,
|
@@ -2064,34 +2112,11 @@ def _SyncPhased(
|
2064 | 2112 | )
|
2065 | 2113 | raise SyncFailFastError(aggregate_errors=errors)
|
2066 | 2114 |
|
2067 |
| - for m in self.ManifestList(opt): |
2068 |
| - if m.IsMirror or m.IsArchive: |
2069 |
| - # Bail out now, we have no working tree. |
2070 |
| - continue |
2071 |
| - |
2072 |
| - try: |
2073 |
| - self.UpdateProjectList(opt, m) |
2074 |
| - except Exception as e: |
2075 |
| - err_event.set() |
2076 |
| - err_update_projects = True |
2077 |
| - errors.append(e) |
2078 |
| - if isinstance(e, DeleteWorktreeError): |
2079 |
| - errors.extend(e.aggregate_errors) |
2080 |
| - if opt.fail_fast: |
2081 |
| - logger.error("error: Local checkouts *not* updated.") |
2082 |
| - raise SyncFailFastError(aggregate_errors=errors) |
2083 |
| - |
2084 |
| - try: |
2085 |
| - self.UpdateCopyLinkfileList(m) |
2086 |
| - except Exception as e: |
2087 |
| - err_update_linkfiles = True |
2088 |
| - errors.append(e) |
2089 |
| - err_event.set() |
2090 |
| - if opt.fail_fast: |
2091 |
| - logger.error( |
2092 |
| - "error: Local update copyfile or linkfile failed." |
2093 |
| - ) |
2094 |
| - raise SyncFailFastError(aggregate_errors=errors) |
| 2115 | + err_update_projects, err_update_linkfiles = self._UpdateManifestLists( |
| 2116 | + opt, |
| 2117 | + err_event, |
| 2118 | + errors, |
| 2119 | + ) |
2095 | 2120 |
|
2096 | 2121 | err_results = []
|
2097 | 2122 | # NB: We don't exit here because this is the last step.
|
@@ -2495,7 +2520,7 @@ def _SyncInterleaved(
|
2495 | 2520 |
|
2496 | 2521 | pm.end()
|
2497 | 2522 |
|
2498 |
| - # TODO(b/421935613): Add the manifest loop block from PhasedSync. |
| 2523 | + self._UpdateManifestLists(opt, err_event, errors) |
2499 | 2524 | if not self.outer_client.manifest.IsArchive:
|
2500 | 2525 | self._GCProjects(project_list, opt, err_event)
|
2501 | 2526 |
|
|
0 commit comments