mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
sync: Show number of running fetch jobs
Last of the recent `repo sync` UX changes. Show number of fetch jobs eg: "Fetching: 3% (8/251) 0:03 | 8 jobs | 0:01 chromiumos/overlays/chrom.." Bug: https://crbug.com/gerrit/11293 Change-Id: I1b3dcf3e56ae6731c6c6cb73cfce069b2f374b69 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/374920 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Joanna Wang <jojwang@google.com>
This commit is contained in:
parent
3eacfdf309
commit
04cba4add5
@ -76,6 +76,10 @@ def elapsed_str(total):
|
||||
return ret
|
||||
|
||||
|
||||
def jobs_str(total):
|
||||
return f"{total} job{'s' if total > 1 else ''}"
|
||||
|
||||
|
||||
class Progress(object):
|
||||
def __init__(
|
||||
self,
|
||||
@ -170,10 +174,7 @@ class Progress(object):
|
||||
else:
|
||||
p = (100 * self._done) / self._total
|
||||
if self._show_jobs:
|
||||
jobs = "[%d job%s] " % (
|
||||
self._active,
|
||||
"s" if self._active > 1 else "",
|
||||
)
|
||||
jobs = f"[{jobs_str(self._active)}] "
|
||||
else:
|
||||
jobs = ""
|
||||
if self._show_elapsed:
|
||||
|
@ -66,7 +66,7 @@ from command import (
|
||||
from error import RepoChangedException, GitError
|
||||
import platform_utils
|
||||
from project import SyncBuffer
|
||||
from progress import Progress, elapsed_str
|
||||
from progress import Progress, elapsed_str, jobs_str
|
||||
from repo_trace import Trace
|
||||
import ssh
|
||||
from wrapper import Wrapper
|
||||
@ -673,7 +673,7 @@ later is required to fix a server side protocol bug.
|
||||
def _FetchInitChild(cls, ssh_proxy):
|
||||
cls.ssh_proxy = ssh_proxy
|
||||
|
||||
def _GetLongestSyncMessage(self):
|
||||
def _GetSyncProgressMessage(self):
|
||||
if len(self._sync_dict) == 0:
|
||||
return None
|
||||
|
||||
@ -685,7 +685,8 @@ later is required to fix a server side protocol bug.
|
||||
earliest_proj = project
|
||||
|
||||
elapsed = time.time() - earliest_time
|
||||
return f"{elapsed_str(elapsed)} {earliest_proj}"
|
||||
jobs = jobs_str(len(self._sync_dict))
|
||||
return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}"
|
||||
|
||||
def _Fetch(self, projects, opt, err_event, ssh_proxy):
|
||||
ret = True
|
||||
@ -707,7 +708,7 @@ later is required to fix a server side protocol bug.
|
||||
|
||||
def _MonitorSyncLoop():
|
||||
while True:
|
||||
pm.update(inc=0, msg=self._GetLongestSyncMessage())
|
||||
pm.update(inc=0, msg=self._GetSyncProgressMessage())
|
||||
if sync_event.wait(timeout=1):
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user