diff options
author | Shawn O. Pearce <sop@google.com> | 2011-09-22 17:44:31 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-09-22 18:08:27 -0700 |
commit | 6392c879454bd4fa0e770195ee8424e383d17df2 (patch) | |
tree | bfbfedb0a1d7f3fbe648deaf09e570ba347feeb0 | |
parent | 97d2b2f7a087bfc695536ae9be962406d82152f2 (diff) | |
download | git-repo-6392c879454bd4fa0e770195ee8424e383d17df2.tar.gz |
sync: Allow -j to have a default in manifestv1.7.6
This permits manifest authors to suggest a number of parallel
fetch operations against a remote server. For example, Gerrit
Code Review servers support queuing of requests and processes
them in first-in, first-out order. Running concurrent fetches
can utilize multiple CPUs on the Gerrit server, but will also
decrease overall operation latency by having the request put
into the queue ready to execute as soon as a CPU is free.
Change-Id: I3d3904acb6f63516bae4b071c510ad57a2afab18
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r-- | docs/manifest-format.txt | 1 | ||||
-rw-r--r-- | manifest_xml.py | 9 | ||||
-rw-r--r-- | subcmds/sync.py | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/docs/manifest-format.txt b/docs/manifest-format.txt index c76df801..21f19db6 100644 --- a/docs/manifest-format.txt +++ b/docs/manifest-format.txt | |||
@@ -38,6 +38,7 @@ following DTD: | |||
38 | <!ELEMENT default (EMPTY)> | 38 | <!ELEMENT default (EMPTY)> |
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 | 42 | ||
42 | <!ELEMENT manifest-server (EMPTY)> | 43 | <!ELEMENT manifest-server (EMPTY)> |
43 | <!ATTLIST url CDATA #REQUIRED> | 44 | <!ATTLIST url CDATA #REQUIRED> |
diff --git a/manifest_xml.py b/manifest_xml.py index 0e6421f1..a0252057 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -29,6 +29,7 @@ class _Default(object): | |||
29 | 29 | ||
30 | revisionExpr = None | 30 | revisionExpr = None |
31 | remote = None | 31 | remote = None |
32 | sync_j = 1 | ||
32 | 33 | ||
33 | class _XmlRemote(object): | 34 | class _XmlRemote(object): |
34 | def __init__(self, | 35 | def __init__(self, |
@@ -133,6 +134,9 @@ class XmlManifest(object): | |||
133 | if d.revisionExpr: | 134 | if d.revisionExpr: |
134 | have_default = True | 135 | have_default = True |
135 | e.setAttribute('revision', d.revisionExpr) | 136 | e.setAttribute('revision', d.revisionExpr) |
137 | if d.sync_j > 1: | ||
138 | have_default = True | ||
139 | e.setAttribute('sync-j', '%d' % d.sync_j) | ||
136 | if have_default: | 140 | if have_default: |
137 | root.appendChild(e) | 141 | root.appendChild(e) |
138 | root.appendChild(doc.createTextNode('')) | 142 | root.appendChild(doc.createTextNode('')) |
@@ -401,6 +405,11 @@ class XmlManifest(object): | |||
401 | d.revisionExpr = node.getAttribute('revision') | 405 | d.revisionExpr = node.getAttribute('revision') |
402 | if d.revisionExpr == '': | 406 | if d.revisionExpr == '': |
403 | d.revisionExpr = None | 407 | d.revisionExpr = None |
408 | sync_j = node.getAttribute('sync-j') | ||
409 | if sync_j == '' or sync_j is None: | ||
410 | d.sync_j = 1 | ||
411 | else: | ||
412 | d.sync_j = int(sync_j) | ||
404 | return d | 413 | return d |
405 | 414 | ||
406 | def _ParseNotice(self, node): | 415 | def _ParseNotice(self, node): |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 93010c51..7ab0b1fb 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -117,6 +117,8 @@ later is required to fix a server side protocol bug. | |||
117 | """ | 117 | """ |
118 | 118 | ||
119 | def _Options(self, p, show_smart=True): | 119 | def _Options(self, p, show_smart=True): |
120 | self.jobs = self.manifest.default.sync_j | ||
121 | |||
120 | p.add_option('-f', '--force-broken', | 122 | p.add_option('-f', '--force-broken', |
121 | dest='force_broken', action='store_true', | 123 | dest='force_broken', action='store_true', |
122 | help="continue sync even if a project fails to sync") | 124 | help="continue sync even if a project fails to sync") |
@@ -134,7 +136,8 @@ later is required to fix a server side protocol bug. | |||
134 | help='be more quiet') | 136 | help='be more quiet') |
135 | p.add_option('-j','--jobs', | 137 | p.add_option('-j','--jobs', |
136 | dest='jobs', action='store', type='int', | 138 | dest='jobs', action='store', type='int', |
137 | help="number of projects to fetch simultaneously") | 139 | default=self.jobs, |
140 | help="projects to fetch simultaneously (default %d)" % self.jobs) | ||
138 | if show_smart: | 141 | if show_smart: |
139 | p.add_option('-s', '--smart-sync', | 142 | p.add_option('-s', '--smart-sync', |
140 | dest='smart_sync', action='store_true', | 143 | dest='smart_sync', action='store_true', |