diff options
Diffstat (limited to 'manifest_xml.py')
| -rw-r--r-- | manifest_xml.py | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 7e719600..3ac607ec 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 | ||
| 32 | import gitc_utils | ||
| 32 | from git_config import GitConfig | 33 | from git_config import GitConfig |
| 33 | from git_refs import R_HEADS, HEAD | 34 | from git_refs import R_HEADS, HEAD |
| 34 | from project import RemoteSpec, Project, MetaProject | 35 | from 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'), |
| @@ -165,12 +167,13 @@ class XmlManifest(object): | |||
| 165 | def _ParseGroups(self, groups): | 167 | def _ParseGroups(self, groups): |
| 166 | return [x for x in re.split(r'[,\s]+', groups) if x] | 168 | return [x for x in re.split(r'[,\s]+', groups) if x] |
| 167 | 169 | ||
| 168 | def Save(self, fd, peg_rev=False, peg_rev_upstream=True): | 170 | def Save(self, fd, peg_rev=False, peg_rev_upstream=True, groups=None): |
| 169 | """Write the current manifest out to the given file descriptor. | 171 | """Write the current manifest out to the given file descriptor. |
| 170 | """ | 172 | """ |
| 171 | mp = self.manifestProject | 173 | mp = self.manifestProject |
| 172 | 174 | ||
| 173 | groups = mp.config.GetString('manifest.groups') | 175 | if groups is None: |
| 176 | groups = mp.config.GetString('manifest.groups') | ||
| 174 | if groups: | 177 | if groups: |
| 175 | groups = self._ParseGroups(groups) | 178 | groups = self._ParseGroups(groups) |
| 176 | 179 | ||
| @@ -303,6 +306,11 @@ class XmlManifest(object): | |||
| 303 | if p.sync_s: | 306 | if p.sync_s: |
| 304 | e.setAttribute('sync-s', 'true') | 307 | e.setAttribute('sync-s', 'true') |
| 305 | 308 | ||
| 309 | if p.clone_depth: | ||
| 310 | e.setAttribute('clone-depth', str(p.clone_depth)) | ||
| 311 | |||
| 312 | self._output_manifest_project_extras(p, e) | ||
| 313 | |||
| 306 | if p.subprojects: | 314 | if p.subprojects: |
| 307 | subprojects = set(subp.name for subp in p.subprojects) | 315 | subprojects = set(subp.name for subp in p.subprojects) |
| 308 | output_projects(p, e, list(sorted(subprojects))) | 316 | output_projects(p, e, list(sorted(subprojects))) |
| @@ -320,6 +328,10 @@ class XmlManifest(object): | |||
| 320 | 328 | ||
| 321 | doc.writexml(fd, '', ' ', '\n', 'UTF-8') | 329 | doc.writexml(fd, '', ' ', '\n', 'UTF-8') |
| 322 | 330 | ||
| 331 | def _output_manifest_project_extras(self, p, e): | ||
| 332 | """Manifests can modify e if they support extra project attributes.""" | ||
| 333 | pass | ||
| 334 | |||
| 323 | @property | 335 | @property |
| 324 | def paths(self): | 336 | def paths(self): |
| 325 | self._Load() | 337 | self._Load() |
| @@ -709,7 +721,7 @@ class XmlManifest(object): | |||
| 709 | def _UnjoinName(self, parent_name, name): | 721 | def _UnjoinName(self, parent_name, name): |
| 710 | return os.path.relpath(name, parent_name) | 722 | return os.path.relpath(name, parent_name) |
| 711 | 723 | ||
| 712 | def _ParseProject(self, node, parent = None): | 724 | def _ParseProject(self, node, parent = None, **extra_proj_attrs): |
| 713 | """ | 725 | """ |
| 714 | reads a <project> element from the manifest file | 726 | reads a <project> element from the manifest file |
| 715 | """ | 727 | """ |
| @@ -804,7 +816,8 @@ class XmlManifest(object): | |||
| 804 | clone_depth = clone_depth, | 816 | clone_depth = clone_depth, |
| 805 | upstream = upstream, | 817 | upstream = upstream, |
| 806 | parent = parent, | 818 | parent = parent, |
| 807 | dest_branch = dest_branch) | 819 | dest_branch = dest_branch, |
| 820 | **extra_proj_attrs) | ||
| 808 | 821 | ||
| 809 | for n in node.childNodes: | 822 | for n in node.childNodes: |
| 810 | if n.nodeName == 'copyfile': | 823 | if n.nodeName == 'copyfile': |
| @@ -935,3 +948,26 @@ class XmlManifest(object): | |||
| 935 | diff['added'].append(toProjects[proj]) | 948 | diff['added'].append(toProjects[proj]) |
| 936 | 949 | ||
| 937 | return diff | 950 | return diff |
| 951 | |||
| 952 | |||
| 953 | class GitcManifest(XmlManifest): | ||
| 954 | |||
| 955 | def __init__(self, repodir, gitc_client_name): | ||
| 956 | """Initialize the GitcManifest object.""" | ||
| 957 | super(GitcManifest, self).__init__(repodir) | ||
| 958 | self.isGitcClient = True | ||
| 959 | self.gitc_client_name = gitc_client_name | ||
| 960 | self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(), | ||
| 961 | gitc_client_name) | ||
| 962 | self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest') | ||
| 963 | |||
| 964 | def _ParseProject(self, node, parent = None): | ||
| 965 | """Override _ParseProject and add support for GITC specific attributes.""" | ||
| 966 | return super(GitcManifest, self)._ParseProject( | ||
| 967 | node, parent=parent, old_revision=node.getAttribute('old-revision')) | ||
| 968 | |||
| 969 | def _output_manifest_project_extras(self, p, e): | ||
| 970 | """Output GITC Specific Project attributes""" | ||
| 971 | if p.old_revision: | ||
| 972 | e.setAttribute('old-revision', str(p.old_revision)) | ||
| 973 | |||
