diff options
| -rw-r--r-- | project.py | 17 | ||||
| -rw-r--r-- | subcmds/sync.py | 24 |
2 files changed, 27 insertions, 14 deletions
| @@ -618,18 +618,19 @@ class Project(object): | |||
| 618 | 618 | ||
| 619 | ## Sync ## | 619 | ## Sync ## |
| 620 | 620 | ||
| 621 | def Sync_NetworkHalf(self): | 621 | def Sync_NetworkHalf(self, quiet=False): |
| 622 | """Perform only the network IO portion of the sync process. | 622 | """Perform only the network IO portion of the sync process. |
| 623 | Local working directory/branch state is not affected. | 623 | Local working directory/branch state is not affected. |
| 624 | """ | 624 | """ |
| 625 | is_new = not self.Exists | 625 | is_new = not self.Exists |
| 626 | if is_new: | 626 | if is_new: |
| 627 | print >>sys.stderr | 627 | if not quiet: |
| 628 | print >>sys.stderr, 'Initializing project %s ...' % self.name | 628 | print >>sys.stderr |
| 629 | print >>sys.stderr, 'Initializing project %s ...' % self.name | ||
| 629 | self._InitGitDir() | 630 | self._InitGitDir() |
| 630 | 631 | ||
| 631 | self._InitRemote() | 632 | self._InitRemote() |
| 632 | if not self._RemoteFetch(initial = is_new): | 633 | if not self._RemoteFetch(initial=is_new, quiet=quiet): |
| 633 | return False | 634 | return False |
| 634 | 635 | ||
| 635 | #Check that the requested ref was found after fetch | 636 | #Check that the requested ref was found after fetch |
| @@ -642,7 +643,7 @@ class Project(object): | |||
| 642 | # | 643 | # |
| 643 | rev = self.revisionExpr | 644 | rev = self.revisionExpr |
| 644 | if rev.startswith(R_TAGS): | 645 | if rev.startswith(R_TAGS): |
| 645 | self._RemoteFetch(None, rev[len(R_TAGS):]) | 646 | self._RemoteFetch(None, rev[len(R_TAGS):], quiet=quiet) |
| 646 | 647 | ||
| 647 | if self.worktree: | 648 | if self.worktree: |
| 648 | self._InitMRef() | 649 | self._InitMRef() |
| @@ -1025,7 +1026,9 @@ class Project(object): | |||
| 1025 | 1026 | ||
| 1026 | ## Direct Git Commands ## | 1027 | ## Direct Git Commands ## |
| 1027 | 1028 | ||
| 1028 | def _RemoteFetch(self, name=None, tag=None, initial=False): | 1029 | def _RemoteFetch(self, name=None, tag=None, |
| 1030 | initial=False, | ||
| 1031 | quiet=False): | ||
| 1029 | if not name: | 1032 | if not name: |
| 1030 | name = self.remote.name | 1033 | name = self.remote.name |
| 1031 | 1034 | ||
| @@ -1088,6 +1091,8 @@ class Project(object): | |||
| 1088 | ref_dir = None | 1091 | ref_dir = None |
| 1089 | 1092 | ||
| 1090 | cmd = ['fetch'] | 1093 | cmd = ['fetch'] |
| 1094 | if quiet: | ||
| 1095 | cmd.append('--quiet') | ||
| 1091 | if not self.worktree: | 1096 | if not self.worktree: |
| 1092 | cmd.append('--update-head-ok') | 1097 | cmd.append('--update-head-ok') |
| 1093 | cmd.append(name) | 1098 | cmd.append(name) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 6cac2e52..1f4b137f 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -110,6 +110,9 @@ later is required to fix a server side protocol bug. | |||
| 110 | p.add_option('-d','--detach', | 110 | p.add_option('-d','--detach', |
| 111 | dest='detach_head', action='store_true', | 111 | dest='detach_head', action='store_true', |
| 112 | help='detach projects back to manifest revision') | 112 | help='detach projects back to manifest revision') |
| 113 | p.add_option('-q','--quiet', | ||
| 114 | dest='quiet', action='store_true', | ||
| 115 | help='be more quiet') | ||
| 113 | p.add_option('-j','--jobs', | 116 | p.add_option('-j','--jobs', |
| 114 | dest='jobs', action='store', type='int', | 117 | dest='jobs', action='store', type='int', |
| 115 | help="number of projects to fetch simultaneously") | 118 | help="number of projects to fetch simultaneously") |
| @@ -126,8 +129,8 @@ later is required to fix a server side protocol bug. | |||
| 126 | dest='repo_upgraded', action='store_true', | 129 | dest='repo_upgraded', action='store_true', |
| 127 | help=SUPPRESS_HELP) | 130 | help=SUPPRESS_HELP) |
| 128 | 131 | ||
| 129 | def _FetchHelper(self, project, lock, fetched, pm, sem): | 132 | def _FetchHelper(self, opt, project, lock, fetched, pm, sem): |
| 130 | if not project.Sync_NetworkHalf(): | 133 | if not project.Sync_NetworkHalf(quiet=opt.quiet): |
| 131 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name | 134 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name |
| 132 | sem.release() | 135 | sem.release() |
| 133 | sys.exit(1) | 136 | sys.exit(1) |
| @@ -138,14 +141,14 @@ later is required to fix a server side protocol bug. | |||
| 138 | lock.release() | 141 | lock.release() |
| 139 | sem.release() | 142 | sem.release() |
| 140 | 143 | ||
| 141 | def _Fetch(self, projects): | 144 | def _Fetch(self, projects, opt): |
| 142 | fetched = set() | 145 | fetched = set() |
| 143 | pm = Progress('Fetching projects', len(projects)) | 146 | pm = Progress('Fetching projects', len(projects)) |
| 144 | 147 | ||
| 145 | if self.jobs == 1: | 148 | if self.jobs == 1: |
| 146 | for project in projects: | 149 | for project in projects: |
| 147 | pm.update() | 150 | pm.update() |
| 148 | if project.Sync_NetworkHalf(): | 151 | if project.Sync_NetworkHalf(quiet=opt.quiet): |
| 149 | fetched.add(project.gitdir) | 152 | fetched.add(project.gitdir) |
| 150 | else: | 153 | else: |
| 151 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name | 154 | print >>sys.stderr, 'error: Cannot fetch %s' % project.name |
| @@ -157,7 +160,12 @@ later is required to fix a server side protocol bug. | |||
| 157 | for project in projects: | 160 | for project in projects: |
| 158 | sem.acquire() | 161 | sem.acquire() |
| 159 | t = _threading.Thread(target = self._FetchHelper, | 162 | t = _threading.Thread(target = self._FetchHelper, |
| 160 | args = (project, lock, fetched, pm, sem)) | 163 | args = (opt, |
| 164 | project, | ||
| 165 | lock, | ||
| 166 | fetched, | ||
| 167 | pm, | ||
| 168 | sem)) | ||
| 161 | threads.add(t) | 169 | threads.add(t) |
| 162 | t.start() | 170 | t.start() |
| 163 | 171 | ||
| @@ -291,7 +299,7 @@ uncommitted changes are present' % project.relpath | |||
| 291 | _PostRepoUpgrade(self.manifest) | 299 | _PostRepoUpgrade(self.manifest) |
| 292 | 300 | ||
| 293 | if not opt.local_only: | 301 | if not opt.local_only: |
| 294 | mp.Sync_NetworkHalf() | 302 | mp.Sync_NetworkHalf(quiet=opt.quiet) |
| 295 | 303 | ||
| 296 | if mp.HasChanges: | 304 | if mp.HasChanges: |
| 297 | syncbuf = SyncBuffer(mp.config) | 305 | syncbuf = SyncBuffer(mp.config) |
| @@ -308,7 +316,7 @@ uncommitted changes are present' % project.relpath | |||
| 308 | to_fetch.append(rp) | 316 | to_fetch.append(rp) |
| 309 | to_fetch.extend(all) | 317 | to_fetch.extend(all) |
| 310 | 318 | ||
| 311 | fetched = self._Fetch(to_fetch) | 319 | fetched = self._Fetch(to_fetch, opt) |
| 312 | _PostRepoFetch(rp, opt.no_repo_verify) | 320 | _PostRepoFetch(rp, opt.no_repo_verify) |
| 313 | if opt.network_only: | 321 | if opt.network_only: |
| 314 | # bail out now; the rest touches the working tree | 322 | # bail out now; the rest touches the working tree |
| @@ -320,7 +328,7 @@ uncommitted changes are present' % project.relpath | |||
| 320 | for project in all: | 328 | for project in all: |
| 321 | if project.gitdir not in fetched: | 329 | if project.gitdir not in fetched: |
| 322 | missing.append(project) | 330 | missing.append(project) |
| 323 | self._Fetch(missing) | 331 | self._Fetch(missing, opt) |
| 324 | 332 | ||
| 325 | if self.manifest.IsMirror: | 333 | if self.manifest.IsMirror: |
| 326 | # bail out now, we have no working tree | 334 | # bail out now, we have no working tree |
