Merge "implement optional 'sync-tags' in the manifest file"

This commit is contained in:
David Pursehouse
2018-02-26 06:50:53 +00:00
committed by Gerrit Code Review
3 changed files with 34 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ following DTD:
<!ATTLIST default sync-j CDATA #IMPLIED> <!ATTLIST default sync-j CDATA #IMPLIED>
<!ATTLIST default sync-c CDATA #IMPLIED> <!ATTLIST default sync-c CDATA #IMPLIED>
<!ATTLIST default sync-s CDATA #IMPLIED> <!ATTLIST default sync-s CDATA #IMPLIED>
<!ATTLIST default sync-tags CDATA #IMPLIED>
<!ELEMENT manifest-server EMPTY> <!ELEMENT manifest-server EMPTY>
<!ATTLIST manifest-server url CDATA #REQUIRED> <!ATTLIST manifest-server url CDATA #REQUIRED>
@@ -63,6 +64,7 @@ following DTD:
<!ATTLIST project groups CDATA #IMPLIED> <!ATTLIST project groups CDATA #IMPLIED>
<!ATTLIST project sync-c CDATA #IMPLIED> <!ATTLIST project sync-c CDATA #IMPLIED>
<!ATTLIST project sync-s CDATA #IMPLIED> <!ATTLIST project sync-s CDATA #IMPLIED>
<!ATTLIST default sync-tags CDATA #IMPLIED>
<!ATTLIST project upstream CDATA #IMPLIED> <!ATTLIST project upstream CDATA #IMPLIED>
<!ATTLIST project clone-depth CDATA #IMPLIED> <!ATTLIST project clone-depth CDATA #IMPLIED>
<!ATTLIST project force-path CDATA #IMPLIED> <!ATTLIST project force-path CDATA #IMPLIED>
@@ -170,6 +172,10 @@ their own will use this value.
Attribute `sync-s`: Set to true to also sync sub-projects. Attribute `sync-s`: Set to true to also sync sub-projects.
Attribute `sync-tags`: Set to false to only sync the given Git
branch (specified in the `revision` attribute) rather than
the other ref tags.
Element manifest-server Element manifest-server
----------------------- -----------------------

View File

@@ -63,6 +63,7 @@ class _Default(object):
sync_j = 1 sync_j = 1
sync_c = False sync_c = False
sync_s = False sync_s = False
sync_tags = True
def __eq__(self, other): def __eq__(self, other):
return self.__dict__ == other.__dict__ return self.__dict__ == other.__dict__
@@ -238,6 +239,9 @@ class XmlManifest(object):
if d.sync_s: if d.sync_s:
have_default = True have_default = True
e.setAttribute('sync-s', 'true') e.setAttribute('sync-s', 'true')
if not d.sync_tags:
have_default = True
e.setAttribute('sync-tags', 'false')
if have_default: if have_default:
root.appendChild(e) root.appendChild(e)
root.appendChild(doc.createTextNode('')) root.appendChild(doc.createTextNode(''))
@@ -327,6 +331,9 @@ class XmlManifest(object):
if p.sync_s: if p.sync_s:
e.setAttribute('sync-s', 'true') e.setAttribute('sync-s', 'true')
if not p.sync_tags:
e.setAttribute('sync-tags', 'false')
if p.clone_depth: if p.clone_depth:
e.setAttribute('clone-depth', str(p.clone_depth)) e.setAttribute('clone-depth', str(p.clone_depth))
@@ -702,6 +709,12 @@ class XmlManifest(object):
d.sync_s = False d.sync_s = False
else: else:
d.sync_s = sync_s.lower() in ("yes", "true", "1") d.sync_s = sync_s.lower() in ("yes", "true", "1")
sync_tags = node.getAttribute('sync-tags')
if not sync_tags:
d.sync_tags = True
else:
d.sync_tags = sync_tags.lower() in ("yes", "true", "1")
return d return d
def _ParseNotice(self, node): def _ParseNotice(self, node):
@@ -796,6 +809,12 @@ class XmlManifest(object):
else: else:
sync_s = sync_s.lower() in ("yes", "true", "1") sync_s = sync_s.lower() in ("yes", "true", "1")
sync_tags = node.getAttribute('sync-tags')
if not sync_tags:
sync_tags = self._default.sync_tags
else:
sync_tags = sync_tags.lower() in ("yes", "true", "1")
clone_depth = node.getAttribute('clone-depth') clone_depth = node.getAttribute('clone-depth')
if clone_depth: if clone_depth:
try: try:
@@ -841,6 +860,7 @@ class XmlManifest(object):
groups = groups, groups = groups,
sync_c = sync_c, sync_c = sync_c,
sync_s = sync_s, sync_s = sync_s,
sync_tags = sync_tags,
clone_depth = clone_depth, clone_depth = clone_depth,
upstream = upstream, upstream = upstream,
parent = parent, parent = parent,

View File

@@ -660,6 +660,7 @@ class Project(object):
groups=None, groups=None,
sync_c=False, sync_c=False,
sync_s=False, sync_s=False,
sync_tags=True,
clone_depth=None, clone_depth=None,
upstream=None, upstream=None,
parent=None, parent=None,
@@ -683,6 +684,7 @@ class Project(object):
groups: The `groups` attribute of manifest.xml's project element. groups: The `groups` attribute of manifest.xml's project element.
sync_c: The `sync-c` attribute of manifest.xml's project element. sync_c: The `sync-c` attribute of manifest.xml's project element.
sync_s: The `sync-s` attribute of manifest.xml's project element. sync_s: The `sync-s` attribute of manifest.xml's project element.
sync_tags: The `sync-tags` attribute of manifest.xml's project element.
upstream: The `upstream` attribute of manifest.xml's project element. upstream: The `upstream` attribute of manifest.xml's project element.
parent: The parent Project object. parent: The parent Project object.
is_derived: False if the project was explicitly defined in the manifest; is_derived: False if the project was explicitly defined in the manifest;
@@ -715,6 +717,7 @@ class Project(object):
self.groups = groups self.groups = groups
self.sync_c = sync_c self.sync_c = sync_c
self.sync_s = sync_s self.sync_s = sync_s
self.sync_tags = sync_tags
self.clone_depth = clone_depth self.clone_depth = clone_depth
self.upstream = upstream self.upstream = upstream
self.parent = parent self.parent = parent
@@ -1289,6 +1292,10 @@ class Project(object):
elif self.manifest.default.sync_c: elif self.manifest.default.sync_c:
current_branch_only = True current_branch_only = True
if not no_tags:
if not self.sync_tags:
no_tags = True
if self.clone_depth: if self.clone_depth:
depth = self.clone_depth depth = self.clone_depth
else: else:
@@ -1900,6 +1907,7 @@ class Project(object):
groups=self.groups, groups=self.groups,
sync_c=self.sync_c, sync_c=self.sync_c,
sync_s=self.sync_s, sync_s=self.sync_s,
sync_tags=self.sync_tags,
parent=self, parent=self,
is_derived=True) is_derived=True)
result.append(subproject) result.append(subproject)