diff options
author | Anatol Pomazau <anatol@google.com> | 2012-04-20 14:41:59 -0700 |
---|---|---|
committer | Anatol Pomazau <anatol@google.com> | 2012-04-23 14:10:52 -0700 |
commit | 79770d269e319dee578beed682669703d4c764ba (patch) | |
tree | 23e733be2bf80454de9352225366b92ef5cc9139 | |
parent | c39864f5e12fa4a6d3f2cdb4921afc021406d106 (diff) | |
download | git-repo-79770d269e319dee578beed682669703d4c764ba.tar.gz |
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
-rw-r--r-- | docs/manifest-format.txt | 2 | ||||
-rw-r--r-- | manifest_xml.py | 23 | ||||
-rw-r--r-- | project.py | 5 |
3 files changed, 28 insertions, 2 deletions
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index 764e41eb..53789651 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt | |||
@@ -39,6 +39,7 @@ following DTD: | |||
39 | <!ATTLIST default remote IDREF #IMPLIED> | 39 | <!ATTLIST default remote IDREF #IMPLIED> |
40 | <!ATTLIST default revision CDATA #IMPLIED> | 40 | <!ATTLIST default revision CDATA #IMPLIED> |
41 | <!ATTLIST default sync-j CDATA #IMPLIED> | 41 | <!ATTLIST default sync-j CDATA #IMPLIED> |
42 | <!ATTLIST default sync-c CDATA #IMPLIED> | ||
42 | 43 | ||
43 | <!ELEMENT manifest-server (EMPTY)> | 44 | <!ELEMENT manifest-server (EMPTY)> |
44 | <!ATTLIST url CDATA #REQUIRED> | 45 | <!ATTLIST url CDATA #REQUIRED> |
@@ -49,6 +50,7 @@ following DTD: | |||
49 | <!ATTLIST project remote IDREF #IMPLIED> | 50 | <!ATTLIST project remote IDREF #IMPLIED> |
50 | <!ATTLIST project revision CDATA #IMPLIED> | 51 | <!ATTLIST project revision CDATA #IMPLIED> |
51 | <!ATTLIST project groups CDATA #IMPLIED> | 52 | <!ATTLIST project groups CDATA #IMPLIED> |
53 | <!ATTLIST project sync-c CDATA #IMPLIED> | ||
52 | 54 | ||
53 | <!ELEMENT annotation (EMPTY)> | 55 | <!ELEMENT annotation (EMPTY)> |
54 | <!ATTLIST annotation name CDATA #REQUIRED> | 56 | <!ATTLIST annotation name CDATA #REQUIRED> |
diff --git a/manifest_xml.py b/manifest_xml.py index d20eac2a..ca65e33f 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -35,6 +35,7 @@ class _Default(object): | |||
35 | revisionExpr = None | 35 | revisionExpr = None |
36 | remote = None | 36 | remote = None |
37 | sync_j = 1 | 37 | sync_j = 1 |
38 | sync_c = False | ||
38 | 39 | ||
39 | class _XmlRemote(object): | 40 | class _XmlRemote(object): |
40 | def __init__(self, | 41 | def __init__(self, |
@@ -159,6 +160,9 @@ class XmlManifest(object): | |||
159 | if d.sync_j > 1: | 160 | if d.sync_j > 1: |
160 | have_default = True | 161 | have_default = True |
161 | e.setAttribute('sync-j', '%d' % d.sync_j) | 162 | e.setAttribute('sync-j', '%d' % d.sync_j) |
163 | if d.sync_c: | ||
164 | have_default = True | ||
165 | e.setAttribute('sync-c', 'true') | ||
162 | if have_default: | 166 | if have_default: |
163 | root.appendChild(e) | 167 | root.appendChild(e) |
164 | root.appendChild(doc.createTextNode('')) | 168 | root.appendChild(doc.createTextNode('')) |
@@ -212,6 +216,9 @@ class XmlManifest(object): | |||
212 | ae.setAttribute('value', a.value) | 216 | ae.setAttribute('value', a.value) |
213 | e.appendChild(ae) | 217 | e.appendChild(ae) |
214 | 218 | ||
219 | if p.sync_c: | ||
220 | e.setAttribute('sync-c', 'true') | ||
221 | |||
215 | if self._repo_hooks_project: | 222 | if self._repo_hooks_project: |
216 | root.appendChild(doc.createTextNode('')) | 223 | root.appendChild(doc.createTextNode('')) |
217 | e = doc.createElement('repo-hooks') | 224 | e = doc.createElement('repo-hooks') |
@@ -444,11 +451,18 @@ class XmlManifest(object): | |||
444 | d.revisionExpr = node.getAttribute('revision') | 451 | d.revisionExpr = node.getAttribute('revision') |
445 | if d.revisionExpr == '': | 452 | if d.revisionExpr == '': |
446 | d.revisionExpr = None | 453 | d.revisionExpr = None |
454 | |||
447 | sync_j = node.getAttribute('sync-j') | 455 | sync_j = node.getAttribute('sync-j') |
448 | if sync_j == '' or sync_j is None: | 456 | if sync_j == '' or sync_j is None: |
449 | d.sync_j = 1 | 457 | d.sync_j = 1 |
450 | else: | 458 | else: |
451 | d.sync_j = int(sync_j) | 459 | d.sync_j = int(sync_j) |
460 | |||
461 | sync_c = node.getAttribute('sync-c') | ||
462 | if not sync_c: | ||
463 | d.sync_c = False | ||
464 | else: | ||
465 | d.sync_c = sync_c.lower() in ("yes", "true", "1") | ||
452 | return d | 466 | return d |
453 | 467 | ||
454 | def _ParseNotice(self, node): | 468 | def _ParseNotice(self, node): |
@@ -526,6 +540,12 @@ class XmlManifest(object): | |||
526 | else: | 540 | else: |
527 | rebase = rebase.lower() in ("yes", "true", "1") | 541 | rebase = rebase.lower() in ("yes", "true", "1") |
528 | 542 | ||
543 | sync_c = node.getAttribute('sync-c') | ||
544 | if not sync_c: | ||
545 | sync_c = False | ||
546 | else: | ||
547 | sync_c = sync_c.lower() in ("yes", "true", "1") | ||
548 | |||
529 | groups = '' | 549 | groups = '' |
530 | if node.hasAttribute('groups'): | 550 | if node.hasAttribute('groups'): |
531 | groups = node.getAttribute('groups') | 551 | groups = node.getAttribute('groups') |
@@ -550,7 +570,8 @@ class XmlManifest(object): | |||
550 | revisionExpr = revisionExpr, | 570 | revisionExpr = revisionExpr, |
551 | revisionId = None, | 571 | revisionId = None, |
552 | rebase = rebase, | 572 | rebase = rebase, |
553 | groups = groups) | 573 | groups = groups, |
574 | sync_c = sync_c) | ||
554 | 575 | ||
555 | for n in node.childNodes: | 576 | for n in node.childNodes: |
556 | if n.nodeName == 'copyfile': | 577 | if n.nodeName == 'copyfile': |
@@ -510,7 +510,8 @@ class Project(object): | |||
510 | revisionExpr, | 510 | revisionExpr, |
511 | revisionId, | 511 | revisionId, |
512 | rebase = True, | 512 | rebase = True, |
513 | groups = None): | 513 | groups = None, |
514 | sync_c = False): | ||
514 | self.manifest = manifest | 515 | self.manifest = manifest |
515 | self.name = name | 516 | self.name = name |
516 | self.remote = remote | 517 | self.remote = remote |
@@ -531,6 +532,7 @@ class Project(object): | |||
531 | 532 | ||
532 | self.rebase = rebase | 533 | self.rebase = rebase |
533 | self.groups = groups | 534 | self.groups = groups |
535 | self.sync_c = sync_c | ||
534 | 536 | ||
535 | self.snapshots = {} | 537 | self.snapshots = {} |
536 | self.copyfiles = [] | 538 | self.copyfiles = [] |
@@ -964,6 +966,7 @@ class Project(object): | |||
964 | and self._ApplyCloneBundle(initial=is_new, quiet=quiet): | 966 | and self._ApplyCloneBundle(initial=is_new, quiet=quiet): |
965 | is_new = False | 967 | is_new = False |
966 | 968 | ||
969 | current_branch_only = current_branch_only or self.sync_c or self.manifest.default.sync_c | ||
967 | if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, | 970 | if not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, |
968 | current_branch_only=current_branch_only): | 971 | current_branch_only=current_branch_only): |
969 | return False | 972 | return False |