diff options
author | Basil Gello <vasek.gello@gmail.com> | 2018-05-25 20:23:52 +0300 |
---|---|---|
committer | Basil Gello <vasek.gello@gmail.com> | 2019-06-06 07:36:10 +0000 |
commit | c745350ab93e9f0417b312d5509d16a7004485f4 (patch) | |
tree | a1f17d08bb991bb38aabe82c8cec8d5c4f0cf6b8 /manifest_xml.py | |
parent | 025704e946562cec18b587a2a54dbe30e20cfb44 (diff) | |
download | git-repo-c745350ab93e9f0417b312d5509d16a7004485f4.tar.gz |
diffmanifests: honor user-supplied manifest paths
The current implementation ignores the user-specified paths to
manifests. if the "repo diffmanifests" is invoked with absolute
file paths for one or both manifests, the command fails with message:
fatal: duplicate path ... in /tmp/manifest-old.xml
Also the current implementation fails to expand the absolute path to
manifest files if "repo diffmanifests" is invoked with relative
paths, i.e "repo diffmanifests manifest-old.xml manifest-new.xml".
fatal: manifest manifest-old.xml not found
This commit fixes the first issue by disabling the local manifest
discovery for diffmanifests command, and the second issue by
expanding paths to manifests within "diffmanifests" sub-command.
Test: repo manifest --revision-as-HEAD -o /tmp/manifest-old.xml
repo sync
repo manifest --revision-as-HEAD -o /tmp/manifest-new.xml
repo diffmanifests /tmp/manifest-old.xml /tmp/manifest-new.xml
Change-Id: Ia125d769bfbea75adb9aba81abbd8c636f2168d4
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
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) |