diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 225e565a..c0f605a8 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -56,7 +56,7 @@ import gitc_utils | |||
| 56 | from project import Project | 56 | from project import Project |
| 57 | from project import RemoteSpec | 57 | from project import RemoteSpec |
| 58 | from command import Command, MirrorSafeCommand | 58 | from command import Command, MirrorSafeCommand |
| 59 | from error import BUG_REPORT_URL, RepoChangedException, GitError, ManifestParseError | 59 | from error import RepoChangedException, GitError, ManifestParseError |
| 60 | import platform_utils | 60 | import platform_utils |
| 61 | from project import SyncBuffer | 61 | from project import SyncBuffer |
| 62 | from progress import Progress | 62 | from progress import Progress |
| @@ -271,6 +271,47 @@ later is required to fix a server side protocol bug. | |||
| 271 | dest='repo_upgraded', action='store_true', | 271 | dest='repo_upgraded', action='store_true', |
| 272 | help=SUPPRESS_HELP) | 272 | help=SUPPRESS_HELP) |
| 273 | 273 | ||
| 274 | def _UpdateProjectsRevisionId(self, opt, args): | ||
| 275 | """Update revisionId of every project with the SHA from superproject. | ||
| 276 | |||
| 277 | This function updates each project's revisionId with SHA from superproject. | ||
| 278 | It writes the updated manifest into a file and reloads the manifest from it. | ||
| 279 | |||
| 280 | Args: | ||
| 281 | opt: Program options returned from optparse. See _Options(). | ||
| 282 | args: Arguments to pass to GetProjects. See the GetProjects | ||
| 283 | docstring for details. | ||
| 284 | |||
| 285 | Returns: | ||
| 286 | Returns path to the overriding manifest file. | ||
| 287 | """ | ||
| 288 | if not self.manifest.superproject: | ||
| 289 | print('error: superproject tag is not defined in manifest.xml', | ||
| 290 | file=sys.stderr) | ||
| 291 | sys.exit(1) | ||
| 292 | print('WARNING: --use-superproject is experimental and not ' | ||
| 293 | 'for general use', file=sys.stderr) | ||
| 294 | |||
| 295 | superproject_url = self.manifest.superproject['remote'].url | ||
| 296 | if not superproject_url: | ||
| 297 | print('error: superproject URL is not defined in manifest.xml', | ||
| 298 | file=sys.stderr) | ||
| 299 | sys.exit(1) | ||
| 300 | |||
| 301 | superproject = git_superproject.Superproject(self.manifest.repodir) | ||
| 302 | all_projects = self.GetProjects(args, | ||
| 303 | missing_ok=True, | ||
| 304 | submodules_ok=opt.fetch_submodules) | ||
| 305 | manifest_path = superproject.UpdateProjectsRevisionId(self.manifest, | ||
| 306 | all_projects, | ||
| 307 | url=superproject_url) | ||
| 308 | if not manifest_path: | ||
| 309 | print('error: Update of revsionId from superproject has failed', | ||
| 310 | file=sys.stderr) | ||
| 311 | sys.exit(1) | ||
| 312 | self._ReloadManifest(manifest_path) | ||
| 313 | return manifest_path | ||
| 314 | |||
| 274 | def _FetchProjectList(self, opt, projects, sem, *args, **kwargs): | 315 | def _FetchProjectList(self, opt, projects, sem, *args, **kwargs): |
| 275 | """Main function of the fetch threads. | 316 | """Main function of the fetch threads. |
| 276 | 317 | ||
| @@ -859,6 +900,9 @@ later is required to fix a server side protocol bug. | |||
| 859 | else: | 900 | else: |
| 860 | self._UpdateManifestProject(opt, mp, manifest_name) | 901 | self._UpdateManifestProject(opt, mp, manifest_name) |
| 861 | 902 | ||
| 903 | if opt.use_superproject: | ||
| 904 | manifest_name = self._UpdateProjectsRevisionId(opt, args) | ||
| 905 | |||
| 862 | if self.gitc_manifest: | 906 | if self.gitc_manifest: |
| 863 | gitc_manifest_projects = self.GetProjects(args, | 907 | gitc_manifest_projects = self.GetProjects(args, |
| 864 | missing_ok=True) | 908 | missing_ok=True) |
| @@ -898,41 +942,6 @@ later is required to fix a server side protocol bug. | |||
| 898 | missing_ok=True, | 942 | missing_ok=True, |
| 899 | submodules_ok=opt.fetch_submodules) | 943 | submodules_ok=opt.fetch_submodules) |
| 900 | 944 | ||
| 901 | if opt.use_superproject: | ||
| 902 | if not self.manifest.superproject: | ||
| 903 | print('error: superproject tag is not defined in manifest.xml', | ||
| 904 | file=sys.stderr) | ||
| 905 | sys.exit(1) | ||
| 906 | print('WARNING: --use-superproject is experimental and not ' | ||
| 907 | 'for general use', file=sys.stderr) | ||
| 908 | superproject_url = self.manifest.superproject['remote'].url | ||
| 909 | if not superproject_url: | ||
| 910 | print('error: superproject URL is not defined in manifest.xml', | ||
| 911 | file=sys.stderr) | ||
| 912 | sys.exit(1) | ||
| 913 | superproject = git_superproject.Superproject(self.manifest.repodir) | ||
| 914 | try: | ||
| 915 | superproject_shas = superproject.GetAllProjectsSHAs(url=superproject_url) | ||
| 916 | except Exception as e: | ||
| 917 | print('error: Cannot get project SHAs for %s: %s: %s' % | ||
| 918 | (superproject_url, type(e).__name__, str(e)), | ||
| 919 | file=sys.stderr) | ||
| 920 | sys.exit(1) | ||
| 921 | projects_missing_shas = [] | ||
| 922 | for project in all_projects: | ||
| 923 | path = project.relpath | ||
| 924 | if not path: | ||
| 925 | continue | ||
| 926 | sha = superproject_shas.get(path) | ||
| 927 | if sha: | ||
| 928 | project.SetRevisionId(sha) | ||
| 929 | else: | ||
| 930 | projects_missing_shas.append(path) | ||
| 931 | if projects_missing_shas: | ||
| 932 | print('error: please file a bug using %s to report missing shas for: %s' % | ||
| 933 | (BUG_REPORT_URL, projects_missing_shas), file=sys.stderr) | ||
| 934 | sys.exit(1) | ||
| 935 | |||
| 936 | err_network_sync = False | 945 | err_network_sync = False |
| 937 | err_update_projects = False | 946 | err_update_projects = False |
| 938 | err_checkout = False | 947 | err_checkout = False |
