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
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def jobs_str(total):
|
||||||
|
return f"{total} job{'s' if total > 1 else ''}"
|
||||||
|
|
||||||
|
|
||||||
class Progress(object):
|
class Progress(object):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -170,10 +174,7 @@ class Progress(object):
|
|||||||
else:
|
else:
|
||||||
p = (100 * self._done) / self._total
|
p = (100 * self._done) / self._total
|
||||||
if self._show_jobs:
|
if self._show_jobs:
|
||||||
jobs = "[%d job%s] " % (
|
jobs = f"[{jobs_str(self._active)}] "
|
||||||
self._active,
|
|
||||||
"s" if self._active > 1 else "",
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
jobs = ""
|
jobs = ""
|
||||||
if self._show_elapsed:
|
if self._show_elapsed:
|
||||||
|
@ -66,7 +66,7 @@ from command import (
|
|||||||
from error import RepoChangedException, GitError
|
from error import RepoChangedException, GitError
|
||||||
import platform_utils
|
import platform_utils
|
||||||
from project import SyncBuffer
|
from project import SyncBuffer
|
||||||
from progress import Progress, elapsed_str
|
from progress import Progress, elapsed_str, jobs_str
|
||||||
from repo_trace import Trace
|
from repo_trace import Trace
|
||||||
import ssh
|
import ssh
|
||||||
from wrapper import Wrapper
|
from wrapper import Wrapper
|
||||||
@ -673,7 +673,7 @@ later is required to fix a server side protocol bug.
|
|||||||
def _FetchInitChild(cls, ssh_proxy):
|
def _FetchInitChild(cls, ssh_proxy):
|
||||||
cls.ssh_proxy = ssh_proxy
|
cls.ssh_proxy = ssh_proxy
|
||||||
|
|
||||||
def _GetLongestSyncMessage(self):
|
def _GetSyncProgressMessage(self):
|
||||||
if len(self._sync_dict) == 0:
|
if len(self._sync_dict) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -685,7 +685,8 @@ later is required to fix a server side protocol bug.
|
|||||||
earliest_proj = project
|
earliest_proj = project
|
||||||
|
|
||||||
elapsed = time.time() - earliest_time
|
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):
|
def _Fetch(self, projects, opt, err_event, ssh_proxy):
|
||||||
ret = True
|
ret = True
|
||||||
@ -707,7 +708,7 @@ later is required to fix a server side protocol bug.
|
|||||||
|
|
||||||
def _MonitorSyncLoop():
|
def _MonitorSyncLoop():
|
||||||
while True:
|
while True:
|
||||||
pm.update(inc=0, msg=self._GetLongestSyncMessage())
|
pm.update(inc=0, msg=self._GetSyncProgressMessage())
|
||||||
if sync_event.wait(timeout=1):
|
if sync_event.wait(timeout=1):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user