diff options
| author | Julien Campergue <julien.campergue@parrot.com> | 2014-01-09 16:21:37 +0100 |
|---|---|---|
| committer | Julien Campergue <julien.campergue@parrot.com> | 2014-02-17 11:20:11 +0000 |
| commit | dd6542268a59834ecff573de974d788f11af775d (patch) | |
| tree | e014028b17f04c230bb8de690d701c2b10a1d93e /manifest_xml.py | |
| parent | baca5f7e88e07c86f402ae7423bb3171a33688e3 (diff) | |
| download | git-repo-dd6542268a59834ecff573de974d788f11af775d.tar.gz | |
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 <julien.campergue@parrot.com>
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 | ||
