From dd6542268a59834ecff573de974d788f11af775d Mon Sep 17 00:00:00 2001 From: Julien Campergue Date: Thu, 9 Jan 2014 16:21:37 +0100 Subject: Add the "diffmanifests" command This command allows a deeper diff between two manifest projects. In addition to changed projects, it displays the logs of the commits between both revisions for each project. Change-Id: I86d30602cfbc654f8c84db2be5d8a30cb90f1398 Signed-off-by: Julien Campergue --- manifest_xml.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'manifest_xml.py') 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: from git_config import GitConfig from git_refs import R_HEADS, HEAD from project import RemoteSpec, Project, MetaProject -from error import ManifestParseError +from error import ManifestParseError, ManifestInvalidRevisionError MANIFEST_FILE_NAME = 'manifest.xml' LOCAL_MANIFEST_NAME = 'local_manifest.xml' @@ -845,3 +845,40 @@ class XmlManifest(object): raise ManifestParseError("no %s in <%s> within %s" % (attname, node.nodeName, self.manifestFile)) return v + + def projectsDiff(self, manifest): + """return the projects differences between two manifests. + + The diff will be from self to given manifest. + + """ + fromProjects = self.paths + toProjects = manifest.paths + + fromKeys = fromProjects.keys() + fromKeys.sort() + toKeys = toProjects.keys() + toKeys.sort() + + diff = {'added': [], 'removed': [], 'changed': [], 'unreachable': []} + + for proj in fromKeys: + if not proj in toKeys: + diff['removed'].append(fromProjects[proj]) + else: + fromProj = fromProjects[proj] + toProj = toProjects[proj] + try: + fromRevId = fromProj.GetCommitRevisionId() + toRevId = toProj.GetCommitRevisionId() + except ManifestInvalidRevisionError: + diff['unreachable'].append((fromProj, toProj)) + else: + if fromRevId != toRevId: + diff['changed'].append((fromProj, toProj)) + toKeys.remove(proj) + + for proj in toKeys: + diff['added'].append(toProjects[proj]) + + return diff -- cgit v1.2.3-54-g00ecf