diff options
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index d496337c..3c8fadd6 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -32,7 +32,7 @@ else: | |||
| 32 | from git_config import GitConfig | 32 | from git_config import GitConfig |
| 33 | from git_refs import R_HEADS, HEAD | 33 | from git_refs import R_HEADS, HEAD |
| 34 | from project import RemoteSpec, Project, MetaProject | 34 | from project import RemoteSpec, Project, MetaProject |
| 35 | from error import ManifestParseError | 35 | from error import ManifestParseError, ManifestInvalidRevisionError |
| 36 | 36 | ||
| 37 | MANIFEST_FILE_NAME = 'manifest.xml' | 37 | MANIFEST_FILE_NAME = 'manifest.xml' |
| 38 | LOCAL_MANIFEST_NAME = 'local_manifest.xml' | 38 | LOCAL_MANIFEST_NAME = 'local_manifest.xml' |
| @@ -568,10 +568,11 @@ class XmlManifest(object): | |||
| 568 | gitdir = gitdir, | 568 | gitdir = gitdir, |
| 569 | objdir = gitdir, | 569 | objdir = gitdir, |
| 570 | worktree = None, | 570 | worktree = None, |
| 571 | relpath = None, | 571 | relpath = name or None, |
| 572 | revisionExpr = m.revisionExpr, | 572 | revisionExpr = m.revisionExpr, |
| 573 | revisionId = None) | 573 | revisionId = None) |
| 574 | self._projects[project.name] = [project] | 574 | self._projects[project.name] = [project] |
| 575 | self._paths[project.relpath] = project | ||
| 575 | 576 | ||
| 576 | def _ParseRemote(self, node): | 577 | def _ParseRemote(self, node): |
| 577 | """ | 578 | """ |
| @@ -845,3 +846,40 @@ class XmlManifest(object): | |||
| 845 | raise ManifestParseError("no %s in <%s> within %s" % | 846 | raise ManifestParseError("no %s in <%s> within %s" % |
| 846 | (attname, node.nodeName, self.manifestFile)) | 847 | (attname, node.nodeName, self.manifestFile)) |
| 847 | return v | 848 | return v |
| 849 | |||
| 850 | def projectsDiff(self, manifest): | ||
| 851 | """return the projects differences between two manifests. | ||
| 852 | |||
| 853 | The diff will be from self to given manifest. | ||
| 854 | |||
| 855 | """ | ||
| 856 | fromProjects = self.paths | ||
| 857 | toProjects = manifest.paths | ||
| 858 | |||
| 859 | fromKeys = fromProjects.keys() | ||
| 860 | fromKeys.sort() | ||
| 861 | toKeys = toProjects.keys() | ||
| 862 | toKeys.sort() | ||
| 863 | |||
| 864 | diff = {'added': [], 'removed': [], 'changed': [], 'unreachable': []} | ||
| 865 | |||
| 866 | for proj in fromKeys: | ||
| 867 | if not proj in toKeys: | ||
| 868 | diff['removed'].append(fromProjects[proj]) | ||
| 869 | else: | ||
| 870 | fromProj = fromProjects[proj] | ||
| 871 | toProj = toProjects[proj] | ||
| 872 | try: | ||
| 873 | fromRevId = fromProj.GetCommitRevisionId() | ||
| 874 | toRevId = toProj.GetCommitRevisionId() | ||
| 875 | except ManifestInvalidRevisionError: | ||
| 876 | diff['unreachable'].append((fromProj, toProj)) | ||
| 877 | else: | ||
| 878 | if fromRevId != toRevId: | ||
| 879 | diff['changed'].append((fromProj, toProj)) | ||
| 880 | toKeys.remove(proj) | ||
| 881 | |||
| 882 | for proj in toKeys: | ||
| 883 | diff['added'].append(toProjects[proj]) | ||
| 884 | |||
| 885 | return diff | ||
