diff options
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index d496337c..3c80d3ce 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' |
@@ -845,3 +845,40 @@ class XmlManifest(object): | |||
845 | raise ManifestParseError("no %s in <%s> within %s" % | 845 | raise ManifestParseError("no %s in <%s> within %s" % |
846 | (attname, node.nodeName, self.manifestFile)) | 846 | (attname, node.nodeName, self.manifestFile)) |
847 | return v | 847 | return v |
848 | |||
849 | def projectsDiff(self, manifest): | ||
850 | """return the projects differences between two manifests. | ||
851 | |||
852 | The diff will be from self to given manifest. | ||
853 | |||
854 | """ | ||
855 | fromProjects = self.paths | ||
856 | toProjects = manifest.paths | ||
857 | |||
858 | fromKeys = fromProjects.keys() | ||
859 | fromKeys.sort() | ||
860 | toKeys = toProjects.keys() | ||
861 | toKeys.sort() | ||
862 | |||
863 | diff = {'added': [], 'removed': [], 'changed': [], 'unreachable': []} | ||
864 | |||
865 | for proj in fromKeys: | ||
866 | if not proj in toKeys: | ||
867 | diff['removed'].append(fromProjects[proj]) | ||
868 | else: | ||
869 | fromProj = fromProjects[proj] | ||
870 | toProj = toProjects[proj] | ||
871 | try: | ||
872 | fromRevId = fromProj.GetCommitRevisionId() | ||
873 | toRevId = toProj.GetCommitRevisionId() | ||
874 | except ManifestInvalidRevisionError: | ||
875 | diff['unreachable'].append((fromProj, toProj)) | ||
876 | else: | ||
877 | if fromRevId != toRevId: | ||
878 | diff['changed'].append((fromProj, toProj)) | ||
879 | toKeys.remove(proj) | ||
880 | |||
881 | for proj in toKeys: | ||
882 | diff['added'].append(toProjects[proj]) | ||
883 | |||
884 | return diff | ||