diff options
-rw-r--r-- | project.py | 21 | ||||
-rw-r--r-- | subcmds/sync.py | 7 |
2 files changed, 22 insertions, 6 deletions
@@ -1039,6 +1039,7 @@ class Project(object): | |||
1039 | def Sync_NetworkHalf(self, | 1039 | def Sync_NetworkHalf(self, |
1040 | quiet=False, | 1040 | quiet=False, |
1041 | verbose=False, | 1041 | verbose=False, |
1042 | output_redir=None, | ||
1042 | is_new=None, | 1043 | is_new=None, |
1043 | current_branch_only=False, | 1044 | current_branch_only=False, |
1044 | force_sync=False, | 1045 | force_sync=False, |
@@ -1126,8 +1127,9 @@ class Project(object): | |||
1126 | (ID_RE.match(self.revisionExpr) and | 1127 | (ID_RE.match(self.revisionExpr) and |
1127 | self._CheckForImmutableRevision())): | 1128 | self._CheckForImmutableRevision())): |
1128 | if not self._RemoteFetch( | 1129 | if not self._RemoteFetch( |
1129 | initial=is_new, quiet=quiet, verbose=verbose, alt_dir=alt_dir, | 1130 | initial=is_new, |
1130 | current_branch_only=current_branch_only, | 1131 | quiet=quiet, verbose=verbose, output_redir=output_redir, |
1132 | alt_dir=alt_dir, current_branch_only=current_branch_only, | ||
1131 | tags=tags, prune=prune, depth=depth, | 1133 | tags=tags, prune=prune, depth=depth, |
1132 | submodules=submodules, force_sync=force_sync, | 1134 | submodules=submodules, force_sync=force_sync, |
1133 | clone_filter=clone_filter, retry_fetches=retry_fetches): | 1135 | clone_filter=clone_filter, retry_fetches=retry_fetches): |
@@ -1139,7 +1141,11 @@ class Project(object): | |||
1139 | alternates_file = os.path.join(self.gitdir, 'objects/info/alternates') | 1141 | alternates_file = os.path.join(self.gitdir, 'objects/info/alternates') |
1140 | if os.path.exists(alternates_file): | 1142 | if os.path.exists(alternates_file): |
1141 | cmd = ['repack', '-a', '-d'] | 1143 | cmd = ['repack', '-a', '-d'] |
1142 | if GitCommand(self, cmd, bare=True).Wait() != 0: | 1144 | p = GitCommand(self, cmd, bare=True, capture_stdout=bool(output_redir), |
1145 | merge_output=bool(output_redir)) | ||
1146 | if p.stdout and output_redir: | ||
1147 | buf.write(p.stdout) | ||
1148 | if p.Wait() != 0: | ||
1143 | return False | 1149 | return False |
1144 | platform_utils.remove(alternates_file) | 1150 | platform_utils.remove(alternates_file) |
1145 | 1151 | ||
@@ -1951,6 +1957,7 @@ class Project(object): | |||
1951 | initial=False, | 1957 | initial=False, |
1952 | quiet=False, | 1958 | quiet=False, |
1953 | verbose=False, | 1959 | verbose=False, |
1960 | output_redir=None, | ||
1954 | alt_dir=None, | 1961 | alt_dir=None, |
1955 | tags=True, | 1962 | tags=True, |
1956 | prune=False, | 1963 | prune=False, |
@@ -2128,7 +2135,9 @@ class Project(object): | |||
2128 | ok = prune_tried = False | 2135 | ok = prune_tried = False |
2129 | for try_n in range(retry_fetches): | 2136 | for try_n in range(retry_fetches): |
2130 | gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy, | 2137 | gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy, |
2131 | merge_output=True, capture_stdout=quiet) | 2138 | merge_output=True, capture_stdout=quiet or bool(output_redir)) |
2139 | if gitcmd.stdout and not quiet and output_redir: | ||
2140 | output_redir.write(gitcmd.stdout) | ||
2132 | ret = gitcmd.Wait() | 2141 | ret = gitcmd.Wait() |
2133 | if ret == 0: | 2142 | if ret == 0: |
2134 | ok = True | 2143 | ok = True |
@@ -2170,7 +2179,7 @@ class Project(object): | |||
2170 | # Git died with a signal, exit immediately | 2179 | # Git died with a signal, exit immediately |
2171 | break | 2180 | break |
2172 | if not verbose: | 2181 | if not verbose: |
2173 | print('%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr) | 2182 | print('\n%s:\n%s' % (self.name, gitcmd.stdout), file=sys.stderr) |
2174 | time.sleep(random.randint(30, 45)) | 2183 | time.sleep(random.randint(30, 45)) |
2175 | 2184 | ||
2176 | if initial: | 2185 | if initial: |
@@ -2189,7 +2198,7 @@ class Project(object): | |||
2189 | # Sync the current branch only with depth set to None. | 2198 | # Sync the current branch only with depth set to None. |
2190 | # We always pass depth=None down to avoid infinite recursion. | 2199 | # We always pass depth=None down to avoid infinite recursion. |
2191 | return self._RemoteFetch( | 2200 | return self._RemoteFetch( |
2192 | name=name, quiet=quiet, verbose=verbose, | 2201 | name=name, quiet=quiet, verbose=verbose, output_redir=output_redir, |
2193 | current_branch_only=current_branch_only and depth, | 2202 | current_branch_only=current_branch_only and depth, |
2194 | initial=False, alt_dir=alt_dir, | 2203 | initial=False, alt_dir=alt_dir, |
2195 | depth=None, clone_filter=clone_filter) | 2204 | depth=None, clone_filter=clone_filter) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index b1b6a6ef..d1b631ae 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -13,6 +13,7 @@ | |||
13 | # limitations under the License. | 13 | # limitations under the License. |
14 | 14 | ||
15 | import http.cookiejar as cookielib | 15 | import http.cookiejar as cookielib |
16 | import io | ||
16 | import json | 17 | import json |
17 | import netrc | 18 | import netrc |
18 | from optparse import SUPPRESS_HELP | 19 | from optparse import SUPPRESS_HELP |
@@ -354,6 +355,7 @@ later is required to fix a server side protocol bug. | |||
354 | # - We always make sure we unlock the lock if we locked it. | 355 | # - We always make sure we unlock the lock if we locked it. |
355 | start = time.time() | 356 | start = time.time() |
356 | success = False | 357 | success = False |
358 | buf = io.StringIO() | ||
357 | with lock: | 359 | with lock: |
358 | pm.start(project.name) | 360 | pm.start(project.name) |
359 | try: | 361 | try: |
@@ -361,6 +363,7 @@ later is required to fix a server side protocol bug. | |||
361 | success = project.Sync_NetworkHalf( | 363 | success = project.Sync_NetworkHalf( |
362 | quiet=opt.quiet, | 364 | quiet=opt.quiet, |
363 | verbose=opt.verbose, | 365 | verbose=opt.verbose, |
366 | output_redir=buf, | ||
364 | current_branch_only=opt.current_branch_only, | 367 | current_branch_only=opt.current_branch_only, |
365 | force_sync=opt.force_sync, | 368 | force_sync=opt.force_sync, |
366 | clone_bundle=opt.clone_bundle, | 369 | clone_bundle=opt.clone_bundle, |
@@ -376,6 +379,10 @@ later is required to fix a server side protocol bug. | |||
376 | lock.acquire() | 379 | lock.acquire() |
377 | did_lock = True | 380 | did_lock = True |
378 | 381 | ||
382 | output = buf.getvalue() | ||
383 | if opt.verbose and output: | ||
384 | pm.update(inc=0, msg=output.rstrip()) | ||
385 | |||
379 | if not success: | 386 | if not success: |
380 | err_event.set() | 387 | err_event.set() |
381 | print('error: Cannot fetch %s from %s' | 388 | print('error: Cannot fetch %s from %s' |