diff options
Diffstat (limited to 'subcmds/sync.py')
| -rw-r--r-- | subcmds/sync.py | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 5b3dca78..228a279a 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -51,7 +51,7 @@ from main import WrapperModule | |||
| 51 | from project import Project | 51 | from project import Project |
| 52 | from project import RemoteSpec | 52 | from project import RemoteSpec |
| 53 | from command import Command, MirrorSafeCommand | 53 | from command import Command, MirrorSafeCommand |
| 54 | from error import RepoChangedException, GitError | 54 | from error import RepoChangedException, GitError, ManifestParseError |
| 55 | from project import SyncBuffer | 55 | from project import SyncBuffer |
| 56 | from progress import Progress | 56 | from progress import Progress |
| 57 | 57 | ||
| @@ -114,6 +114,9 @@ resumeable bundle file on a content delivery network. This | |||
| 114 | may be necessary if there are problems with the local Python | 114 | may be necessary if there are problems with the local Python |
| 115 | HTTP client or proxy configuration, but the Git binary works. | 115 | HTTP client or proxy configuration, but the Git binary works. |
| 116 | 116 | ||
| 117 | The --fetch-submodules option enables fetching Git submodules | ||
| 118 | of a project from server. | ||
| 119 | |||
| 117 | SSH Connections | 120 | SSH Connections |
| 118 | --------------- | 121 | --------------- |
| 119 | 122 | ||
| @@ -145,7 +148,10 @@ later is required to fix a server side protocol bug. | |||
| 145 | """ | 148 | """ |
| 146 | 149 | ||
| 147 | def _Options(self, p, show_smart=True): | 150 | def _Options(self, p, show_smart=True): |
| 148 | self.jobs = self.manifest.default.sync_j | 151 | try: |
| 152 | self.jobs = self.manifest.default.sync_j | ||
| 153 | except ManifestParseError: | ||
| 154 | self.jobs = 1 | ||
| 149 | 155 | ||
| 150 | p.add_option('-f', '--force-broken', | 156 | p.add_option('-f', '--force-broken', |
| 151 | dest='force_broken', action='store_true', | 157 | dest='force_broken', action='store_true', |
| @@ -180,6 +186,9 @@ later is required to fix a server side protocol bug. | |||
| 180 | p.add_option('-p', '--manifest-server-password', action='store', | 186 | p.add_option('-p', '--manifest-server-password', action='store', |
| 181 | dest='manifest_server_password', | 187 | dest='manifest_server_password', |
| 182 | help='password to authenticate with the manifest server') | 188 | help='password to authenticate with the manifest server') |
| 189 | p.add_option('--fetch-submodules', | ||
| 190 | dest='fetch_submodules', action='store_true', | ||
| 191 | help='fetch submodules from server') | ||
| 183 | if show_smart: | 192 | if show_smart: |
| 184 | p.add_option('-s', '--smart-sync', | 193 | p.add_option('-s', '--smart-sync', |
| 185 | dest='smart_sync', action='store_true', | 194 | dest='smart_sync', action='store_true', |
| @@ -559,7 +568,9 @@ later is required to fix a server side protocol bug. | |||
| 559 | self.manifest._Unload() | 568 | self.manifest._Unload() |
| 560 | if opt.jobs is None: | 569 | if opt.jobs is None: |
| 561 | self.jobs = self.manifest.default.sync_j | 570 | self.jobs = self.manifest.default.sync_j |
| 562 | all_projects = self.GetProjects(args, missing_ok=True) | 571 | all_projects = self.GetProjects(args, |
| 572 | missing_ok=True, | ||
| 573 | submodules_ok=opt.fetch_submodules) | ||
| 563 | 574 | ||
| 564 | self._fetch_times = _FetchTimes(self.manifest) | 575 | self._fetch_times = _FetchTimes(self.manifest) |
| 565 | if not opt.local_only: | 576 | if not opt.local_only: |
| @@ -570,12 +581,33 @@ later is required to fix a server side protocol bug. | |||
| 570 | to_fetch.extend(all_projects) | 581 | to_fetch.extend(all_projects) |
| 571 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) | 582 | to_fetch.sort(key=self._fetch_times.Get, reverse=True) |
| 572 | 583 | ||
| 573 | self._Fetch(to_fetch, opt) | 584 | fetched = self._Fetch(to_fetch, opt) |
| 574 | _PostRepoFetch(rp, opt.no_repo_verify) | 585 | _PostRepoFetch(rp, opt.no_repo_verify) |
| 575 | if opt.network_only: | 586 | if opt.network_only: |
| 576 | # bail out now; the rest touches the working tree | 587 | # bail out now; the rest touches the working tree |
| 577 | return | 588 | return |
| 578 | 589 | ||
| 590 | # Iteratively fetch missing and/or nested unregistered submodules | ||
| 591 | previously_missing_set = set() | ||
| 592 | while True: | ||
| 593 | self.manifest._Unload() | ||
| 594 | all_projects = self.GetProjects(args, | ||
| 595 | missing_ok=True, | ||
| 596 | submodules_ok=opt.fetch_submodules) | ||
| 597 | missing = [] | ||
| 598 | for project in all_projects: | ||
| 599 | if project.gitdir not in fetched: | ||
| 600 | missing.append(project) | ||
| 601 | if not missing: | ||
| 602 | break | ||
| 603 | # Stop us from non-stopped fetching actually-missing repos: If set of | ||
| 604 | # missing repos has not been changed from last fetch, we break. | ||
| 605 | missing_set = set(p.name for p in missing) | ||
| 606 | if previously_missing_set == missing_set: | ||
| 607 | break | ||
| 608 | previously_missing_set = missing_set | ||
| 609 | fetched.update(self._Fetch(missing, opt)) | ||
| 610 | |||
| 579 | if self.manifest.IsMirror: | 611 | if self.manifest.IsMirror: |
| 580 | # bail out now, we have no working tree | 612 | # bail out now, we have no working tree |
| 581 | return | 613 | return |
