diff --git a/progress.py b/progress.py index 6686ad4a..69c95927 100644 --- a/progress.py +++ b/progress.py @@ -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: diff --git a/subcmds/sync.py b/subcmds/sync.py index da9918b9..a44ed5b4 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -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