mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Add sync-c option to manifest
There are use-cases when fetching all branch is impractical and we really need to fetch only one branch/tag. e.g. there is a large project with binaries and every update of a binary file is put to a separate branch. The whole project history might be too large to allow users fetch it. Add 'sync-c' option to 'project' and 'default' tags to make it possible to configure 'sync-c' behavior at per-project and per-manifest level. Note that currently there is no possibility to revert boolean flag from command line. If 'sync-c' is set in manifest then you cannot make full fetch by providing a repo tool argument. Change-Id: Ie36fe5737304930493740370239403986590f593
This commit is contained in:
parent
c39864f5e1
commit
79770d269e
@ -39,6 +39,7 @@ following DTD:
|
|||||||
<!ATTLIST default remote IDREF #IMPLIED>
|
<!ATTLIST default remote IDREF #IMPLIED>
|
||||||
<!ATTLIST default revision CDATA #IMPLIED>
|
<!ATTLIST default revision CDATA #IMPLIED>
|
||||||
<!ATTLIST default sync-j CDATA #IMPLIED>
|
<!ATTLIST default sync-j CDATA #IMPLIED>
|
||||||
|
<!ATTLIST default sync-c CDATA #IMPLIED>
|
||||||
|
|
||||||
<!ELEMENT manifest-server (EMPTY)>
|
<!ELEMENT manifest-server (EMPTY)>
|
||||||
<!ATTLIST url CDATA #REQUIRED>
|
<!ATTLIST url CDATA #REQUIRED>
|
||||||
@ -49,6 +50,7 @@ following DTD:
|
|||||||
<!ATTLIST project remote IDREF #IMPLIED>
|
<!ATTLIST project remote IDREF #IMPLIED>
|
||||||
<!ATTLIST project revision CDATA #IMPLIED>
|
<!ATTLIST project revision CDATA #IMPLIED>
|
||||||
<!ATTLIST project groups CDATA #IMPLIED>
|
<!ATTLIST project groups CDATA #IMPLIED>
|
||||||
|
<!ATTLIST project sync-c CDATA #IMPLIED>
|
||||||
|
|
||||||
<!ELEMENT annotation (EMPTY)>
|
<!ELEMENT annotation (EMPTY)>
|
||||||
<!ATTLIST annotation name CDATA #REQUIRED>
|
<!ATTLIST annotation name CDATA #REQUIRED>
|
||||||
|
@ -35,6 +35,7 @@ class _Default(object):
|
|||||||
revisionExpr = None
|
revisionExpr = None
|
||||||
remote = None
|
remote = None
|
||||||
sync_j = 1
|
sync_j = 1
|
||||||
|
sync_c = False
|
||||||
|
|
||||||
class _XmlRemote(object):
|
class _XmlRemote(object):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
@ -159,6 +160,9 @@ class XmlManifest(object):
|
|||||||
if d.sync_j > 1:
|
if d.sync_j > 1:
|
||||||
have_default = True
|
have_default = True
|
||||||
e.setAttribute('sync-j', '%d' % d.sync_j)
|
e.setAttribute('sync-j', '%d' % d.sync_j)
|
||||||
|
if d.sync_c:
|
||||||
|
have_default = True
|
||||||
|
e.setAttribute('sync-c', 'true')
|
||||||
if have_default:
|
if have_default:
|
||||||
root.appendChild(e)
|
root.appendChild(e)
|
||||||
root.appendChild(doc.createTextNode(''))
|
root.appendChild(doc.createTextNode(''))
|
||||||
@ -212,6 +216,9 @@ class XmlManifest(object):
|
|||||||
ae.setAttribute('value', a.value)
|
ae.setAttribute('value', a.value)
|
||||||
e.appendChild(ae)
|
e.appendChild(ae)
|
||||||
|
|
||||||
|
if p.sync_c:
|
||||||
|
e.setAttribute('sync-c', 'true')
|
||||||
|
|
||||||
if self._repo_hooks_project:
|
if self._repo_hooks_project:
|
||||||
root.appendChild(doc.createTextNode(''))
|
root.appendChild(doc.createTextNode(''))
|
||||||
e = doc.createElement('repo-hooks')
|
e = doc.createElement('repo-hooks')
|
||||||
@ -444,11 +451,18 @@ class XmlManifest(object):
|
|||||||
d.revisionExpr = node.getAttribute('revision')
|
d.revisionExpr = node.getAttribute('revision')
|
||||||
if d.revisionExpr == '':
|
if d.revisionExpr == '':
|
||||||
d.revisionExpr = None
|
d.revisionExpr = None
|
||||||
|
|
||||||
sync_j = node.getAttribute('sync-j')
|
sync_j = node.getAttribute('sync-j')
|
||||||
if sync_j == '' or sync_j is None:
|
if sync_j == '' or sync_j is None:
|
||||||
d.sync_j = 1
|
d.sync_j = 1
|
||||||
else:
|
else:
|
||||||
d.sync_j = int(sync_j)
|
d.sync_j = int(sync_j)
|
||||||
|
|
||||||
|
sync_c = node.getAttribute('sync-c')
|
||||||
|
if not sync_c:
|
||||||
|
d.sync_c = False
|
||||||
|
else:
|
||||||
|
d.sync_c = sync_c.lower() in ("yes", "true", "1")
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _ParseNotice(self, node):
|
def _ParseNotice(self, node):
|
||||||
@ -526,6 +540,12 @@ class XmlManifest(object):
|
|||||||
else:
|
else:
|
||||||
rebase = rebase.lower() in ("yes", "true", "1")
|
rebase = rebase.lower() in ("yes", "true", "1")
|
||||||
|
|
||||||
|
sync_c = node.getAttribute('sync-c')
|
||||||
|
if not sync_c:
|
||||||
|
sync_c = False
|
||||||
|
else:
|
||||||
|
sync_c = sync_c.lower() in ("yes", "true", "1")
|
||||||
|
|
||||||
groups = ''
|
groups = ''
|
||||||
if node.hasAttribute('groups'):
|
if node.hasAttribute('groups'):
|
||||||
groups = node.getAttribute('groups')
|
groups = node.getAttribute('groups')
|
||||||
@ -550,7 +570,8 @@ class XmlManifest(object):
|
|||||||
revisionExpr = revisionExpr,
|
revisionExpr = revisionExpr,
|
||||||
revisionId = None,
|
revisionId = None,
|
||||||
rebase = rebase,
|
rebase = rebase,
|
||||||
groups = groups)
|
groups = groups,
|
||||||
|
sync_c = sync_c)
|
||||||
|
|
||||||
for n in node.childNodes:
|
for n in node.childNodes:
|
||||||
if n.nodeName == 'copyfile':
|
if n.nodeName == 'copyfile':
|
||||||
|
@ -510,7 +510,8 @@ class Project(object):
|
|||||||
revisionExpr,
|
revisionExpr,
|
||||||
revisionId,
|
revisionId,
|
||||||
rebase = True,
|
rebase = True,
|
||||||
groups = None):
|
groups = None,
|
||||||
|
sync_c = False):
|
||||||
self.manifest = manifest
|
self.manifest = manifest
|
||||||
self.name = name
|
self.name = name
|
||||||
self.remote = remote
|
self.remote = remote
|
||||||
@ -531,6 +532,7 @@ class Project(object):
|
|||||||
|
|
||||||
self.rebase = rebase
|
self.rebase = rebase
|
||||||
self.groups = groups
|
self.groups = groups
|
||||||
|
self.sync_c = sync_c
|
||||||
|
|
||||||
self.snapshots = {}
|
self.snapshots = {}
|
||||||
self.copyfiles = []
|
self.copyfiles = []
|
||||||
@ -964,6 +966,7 @@ class Project(object):
|
|||||||
and self._ApplyCloneBundle(initial=is_new, quiet=quiet):
|
and self._ApplyCloneBundle(initial=is_new, quiet=quiet):
|
||||||
is_new = False
|
is_new = False
|
||||||
|
|
||||||
|
current_branch_only = current_branch_only or self.sync_c or self.manifest.default.sync_c
|
||||||
if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
|
if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir,
|
||||||
current_branch_only=current_branch_only):
|
current_branch_only=current_branch_only):
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user