summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
Diffstat (limited to 'manifest_xml.py')
-rw-r--r--manifest_xml.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 6dc01a47..b33ec627 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -29,6 +29,7 @@ else:
29 urllib = imp.new_module('urllib') 29 urllib = imp.new_module('urllib')
30 urllib.parse = urlparse 30 urllib.parse = urlparse
31 31
32import gitc_utils
32from git_config import GitConfig 33from git_config import GitConfig
33from git_refs import R_HEADS, HEAD 34from git_refs import R_HEADS, HEAD
34from project import RemoteSpec, Project, MetaProject 35from project import RemoteSpec, Project, MetaProject
@@ -112,6 +113,7 @@ class XmlManifest(object):
112 self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME) 113 self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME)
113 self.globalConfig = GitConfig.ForUser() 114 self.globalConfig = GitConfig.ForUser()
114 self.localManifestWarning = False 115 self.localManifestWarning = False
116 self.isGitcClient = False
115 117
116 self.repoProject = MetaProject(self, 'repo', 118 self.repoProject = MetaProject(self, 'repo',
117 gitdir = os.path.join(repodir, 'repo/.git'), 119 gitdir = os.path.join(repodir, 'repo/.git'),
@@ -306,6 +308,8 @@ class XmlManifest(object):
306 if p.clone_depth: 308 if p.clone_depth:
307 e.setAttribute('clone-depth', str(p.clone_depth)) 309 e.setAttribute('clone-depth', str(p.clone_depth))
308 310
311 self._output_manifest_project_extras(p, e)
312
309 if p.subprojects: 313 if p.subprojects:
310 subprojects = set(subp.name for subp in p.subprojects) 314 subprojects = set(subp.name for subp in p.subprojects)
311 output_projects(p, e, list(sorted(subprojects))) 315 output_projects(p, e, list(sorted(subprojects)))
@@ -323,6 +327,10 @@ class XmlManifest(object):
323 327
324 doc.writexml(fd, '', ' ', '\n', 'UTF-8') 328 doc.writexml(fd, '', ' ', '\n', 'UTF-8')
325 329
330 def _output_manifest_project_extras(self, p, e):
331 """Manifests can modify e if they support extra project attributes."""
332 pass
333
326 @property 334 @property
327 def paths(self): 335 def paths(self):
328 self._Load() 336 self._Load()
@@ -712,7 +720,7 @@ class XmlManifest(object):
712 def _UnjoinName(self, parent_name, name): 720 def _UnjoinName(self, parent_name, name):
713 return os.path.relpath(name, parent_name) 721 return os.path.relpath(name, parent_name)
714 722
715 def _ParseProject(self, node, parent = None): 723 def _ParseProject(self, node, parent = None, **extra_proj_attrs):
716 """ 724 """
717 reads a <project> element from the manifest file 725 reads a <project> element from the manifest file
718 """ 726 """
@@ -807,7 +815,8 @@ class XmlManifest(object):
807 clone_depth = clone_depth, 815 clone_depth = clone_depth,
808 upstream = upstream, 816 upstream = upstream,
809 parent = parent, 817 parent = parent,
810 dest_branch = dest_branch) 818 dest_branch = dest_branch,
819 **extra_proj_attrs)
811 820
812 for n in node.childNodes: 821 for n in node.childNodes:
813 if n.nodeName == 'copyfile': 822 if n.nodeName == 'copyfile':
@@ -938,3 +947,26 @@ class XmlManifest(object):
938 diff['added'].append(toProjects[proj]) 947 diff['added'].append(toProjects[proj])
939 948
940 return diff 949 return diff
950
951
952class GitcManifest(XmlManifest):
953
954 def __init__(self, repodir, gitc_client_name):
955 """Initialize the GitcManifest object."""
956 super(GitcManifest, self).__init__(repodir)
957 self.isGitcClient = True
958 self.gitc_client_name = gitc_client_name
959 self.gitc_client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR,
960 gitc_client_name)
961 self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest')
962
963 def _ParseProject(self, node, parent = None):
964 """Override _ParseProject and add support for GITC specific attributes."""
965 return super(GitcManifest, self)._ParseProject(
966 node, parent=parent, old_revision=node.getAttribute('old-revision'))
967
968 def _output_manifest_project_extras(self, p, e):
969 """Output GITC Specific Project attributes"""
970 if p.old_revision:
971 e.setAttribute('old-revision', str(p.old_revision))
972