diff options
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index f37732cd..23b4fb74 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -135,6 +135,7 @@ class XmlManifest(object): | |||
| 135 | self.globalConfig = GitConfig.ForUser() | 135 | self.globalConfig = GitConfig.ForUser() |
| 136 | self.localManifestWarning = False | 136 | self.localManifestWarning = False |
| 137 | self.isGitcClient = False | 137 | self.isGitcClient = False |
| 138 | self._load_local_manifests = True | ||
| 138 | 139 | ||
| 139 | self.repoProject = MetaProject(self, 'repo', | 140 | self.repoProject = MetaProject(self, 'repo', |
| 140 | gitdir = os.path.join(repodir, 'repo/.git'), | 141 | gitdir = os.path.join(repodir, 'repo/.git'), |
| @@ -146,15 +147,26 @@ class XmlManifest(object): | |||
| 146 | 147 | ||
| 147 | self._Unload() | 148 | self._Unload() |
| 148 | 149 | ||
| 149 | def Override(self, name): | 150 | def Override(self, name, load_local_manifests=True): |
| 150 | """Use a different manifest, just for the current instantiation. | 151 | """Use a different manifest, just for the current instantiation. |
| 151 | """ | 152 | """ |
| 152 | path = os.path.join(self.manifestProject.worktree, name) | 153 | path = None |
| 153 | if not os.path.isfile(path): | 154 | |
| 154 | raise ManifestParseError('manifest %s not found' % name) | 155 | # Look for a manifest by path in the filesystem (including the cwd). |
| 156 | if not load_local_manifests: | ||
| 157 | local_path = os.path.abspath(name) | ||
| 158 | if os.path.isfile(local_path): | ||
| 159 | path = local_path | ||
| 160 | |||
| 161 | # Look for manifests by name from the manifests repo. | ||
| 162 | if path is None: | ||
| 163 | path = os.path.join(self.manifestProject.worktree, name) | ||
| 164 | if not os.path.isfile(path): | ||
| 165 | raise ManifestParseError('manifest %s not found' % name) | ||
| 155 | 166 | ||
| 156 | old = self.manifestFile | 167 | old = self.manifestFile |
| 157 | try: | 168 | try: |
| 169 | self._load_local_manifests = load_local_manifests | ||
| 158 | self.manifestFile = path | 170 | self.manifestFile = path |
| 159 | self._Unload() | 171 | self._Unload() |
| 160 | self._Load() | 172 | self._Load() |
| @@ -435,23 +447,26 @@ class XmlManifest(object): | |||
| 435 | nodes.append(self._ParseManifestXml(self.manifestFile, | 447 | nodes.append(self._ParseManifestXml(self.manifestFile, |
| 436 | self.manifestProject.worktree)) | 448 | self.manifestProject.worktree)) |
| 437 | 449 | ||
| 438 | local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) | 450 | if self._load_local_manifests: |
| 439 | if os.path.exists(local): | 451 | local = os.path.join(self.repodir, LOCAL_MANIFEST_NAME) |
| 440 | if not self.localManifestWarning: | 452 | if os.path.exists(local): |
| 441 | self.localManifestWarning = True | 453 | if not self.localManifestWarning: |
| 442 | print('warning: %s is deprecated; put local manifests in `%s` instead' | 454 | self.localManifestWarning = True |
| 443 | % (LOCAL_MANIFEST_NAME, os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)), | 455 | print('warning: %s is deprecated; put local manifests ' |
| 444 | file=sys.stderr) | 456 | 'in `%s` instead' % (LOCAL_MANIFEST_NAME, |
| 445 | nodes.append(self._ParseManifestXml(local, self.repodir)) | 457 | os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)), |
| 446 | 458 | file=sys.stderr) | |
| 447 | local_dir = os.path.abspath(os.path.join(self.repodir, LOCAL_MANIFESTS_DIR_NAME)) | 459 | nodes.append(self._ParseManifestXml(local, self.repodir)) |
| 448 | try: | 460 | |
| 449 | for local_file in sorted(platform_utils.listdir(local_dir)): | 461 | local_dir = os.path.abspath(os.path.join(self.repodir, |
| 450 | if local_file.endswith('.xml'): | 462 | LOCAL_MANIFESTS_DIR_NAME)) |
| 451 | local = os.path.join(local_dir, local_file) | 463 | try: |
| 452 | nodes.append(self._ParseManifestXml(local, self.repodir)) | 464 | for local_file in sorted(platform_utils.listdir(local_dir)): |
| 453 | except OSError: | 465 | if local_file.endswith('.xml'): |
| 454 | pass | 466 | local = os.path.join(local_dir, local_file) |
| 467 | nodes.append(self._ParseManifestXml(local, self.repodir)) | ||
| 468 | except OSError: | ||
| 469 | pass | ||
| 455 | 470 | ||
| 456 | try: | 471 | try: |
| 457 | self._ParseManifest(nodes) | 472 | self._ParseManifest(nodes) |
