mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-11-14 00:07:20 +00:00
style: use import progress everywhere
Align with Google style guides and `import progress` as a module rather than import symbols out of it. Change-Id: I3ef9109af8c6883ac0df7fa19bdb88bc6cdfd5e9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/654818 Reviewed-by: Brian Gan <brgan@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
1 parent
020767b9d3
commit
81e9642c25
6 files changed
+28
-29
No files matched your search
+2
-2
@@ -20,7 +20,7 @@ from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
import error
|
||||
import git_command
|
||||
from progress import Progress
|
||||
import progress
|
||||
import repo_logging
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ It is equivalent to "git branch -D <branchname>".
|
||||
functools.partial(self._ExecuteOne, opt.all, nb),
|
||||
range(len(all_projects)),
|
||||
callback=_ProcessResults,
|
||||
output=Progress(
|
||||
output=progress.Progress(
|
||||
f"Abandon {nb}", len(all_projects), quiet=opt.quiet
|
||||
),
|
||||
chunksize=1,
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ from typing import NamedTuple
|
||||
from command import Command
|
||||
from command import DEFAULT_LOCAL_JOBS
|
||||
import error
|
||||
from progress import Progress
|
||||
import progress
|
||||
import repo_logging
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ The command is equivalent to:
|
||||
functools.partial(self._ExecuteOne, nb),
|
||||
range(len(all_projects)),
|
||||
callback=_ProcessResults,
|
||||
output=Progress(
|
||||
output=progress.Progress(
|
||||
f"Checkout {nb}", len(all_projects), quiet=opt.quiet
|
||||
),
|
||||
)
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ from typing import List, Set
|
||||
from command import Command
|
||||
import git_command
|
||||
import platform_utils
|
||||
from progress import Progress
|
||||
import progress
|
||||
from project import Project
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ are still in the manifests.
|
||||
if ask.lower() != "y":
|
||||
return 1
|
||||
|
||||
pm = Progress(
|
||||
pm = progress.Progress(
|
||||
"Deleting",
|
||||
len(to_delete),
|
||||
delay=False,
|
||||
@@ -180,7 +180,7 @@ are still in the manifests.
|
||||
print(f"Would have repacked {len(repack_projects)} projects.")
|
||||
return 0
|
||||
|
||||
pm = Progress(
|
||||
pm = progress.Progress(
|
||||
"Repacking (this will take a while)",
|
||||
len(repack_projects),
|
||||
delay=False,
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ from command import DEFAULT_LOCAL_JOBS
|
||||
import error
|
||||
import git_command
|
||||
import git_config
|
||||
from progress import Progress
|
||||
import progress
|
||||
import repo_logging
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ revision specified in the manifest.
|
||||
),
|
||||
range(len(all_projects)),
|
||||
callback=_ProcessResults,
|
||||
output=Progress(
|
||||
output=progress.Progress(
|
||||
f"Starting {nb}", len(all_projects), quiet=opt.quiet
|
||||
),
|
||||
chunksize=1,
|
||||
|
||||
+10
-12
@@ -66,9 +66,7 @@ import git_superproject
|
||||
from hooks import RepoHook
|
||||
import manifest_xml
|
||||
import platform_utils
|
||||
from progress import elapsed_str
|
||||
from progress import jobs_str
|
||||
from progress import Progress
|
||||
import progress
|
||||
from project import DeleteWorktreeError
|
||||
from project import Project
|
||||
from project import RemoteSpec
|
||||
@@ -1142,8 +1140,8 @@ later is required to fix a server side protocol bug.
|
||||
return "..working.."
|
||||
|
||||
elapsed = time.time() - earliest_time
|
||||
jobs = jobs_str(len(items))
|
||||
return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}"
|
||||
jobs = progress.jobs_str(len(items))
|
||||
return f"{jobs} | {progress.elapsed_str(elapsed)} {earliest_proj}"
|
||||
|
||||
@classmethod
|
||||
def InitWorker(cls):
|
||||
@@ -1160,7 +1158,7 @@ later is required to fix a server side protocol bug.
|
||||
|
||||
fetched = set()
|
||||
remote_fetched = set()
|
||||
pm = Progress(
|
||||
pm = progress.Progress(
|
||||
"Fetching",
|
||||
len(projects),
|
||||
delay=False,
|
||||
@@ -1484,7 +1482,7 @@ later is required to fix a server side protocol bug.
|
||||
),
|
||||
range(len(projects)),
|
||||
callback=_ProcessResults,
|
||||
output=Progress(
|
||||
output=progress.Progress(
|
||||
"Checking out", len(all_projects), quiet=opt.quiet
|
||||
),
|
||||
# Use chunksize=1 to avoid the chance that some workers are
|
||||
@@ -1616,7 +1614,7 @@ later is required to fix a server side protocol bug.
|
||||
cls._SetPreciousObjectsState(project, opt)
|
||||
return
|
||||
|
||||
pm = Progress(
|
||||
pm = progress.Progress(
|
||||
"Garbage collecting", len(projects), delay=False, quiet=opt.quiet
|
||||
)
|
||||
pm.update(inc=0, msg="prescan")
|
||||
@@ -1783,7 +1781,7 @@ later is required to fix a server side protocol bug.
|
||||
if not projects:
|
||||
return
|
||||
|
||||
pm = Progress(
|
||||
pm = progress.Progress(
|
||||
"Checking for bloat", len(projects), delay=False, quiet=opt.quiet
|
||||
)
|
||||
|
||||
@@ -2810,7 +2808,7 @@ later is required to fix a server side protocol bug.
|
||||
raise e
|
||||
|
||||
def _CreateSyncProgressThread(
|
||||
self, pm: Progress, stop_event: _threading.Event
|
||||
self, pm: progress.Progress, stop_event: _threading.Event
|
||||
) -> _threading.Thread:
|
||||
"""Creates and returns a daemon thread to update a Progress object.
|
||||
|
||||
@@ -3194,7 +3192,7 @@ later is required to fix a server side protocol bug.
|
||||
errors: List[Exception],
|
||||
opt: optparse.Values,
|
||||
pool: Optional[multiprocessing.Pool],
|
||||
pm: Progress,
|
||||
pm: progress.Progress,
|
||||
results_sets: List[_InterleavedSyncResult],
|
||||
):
|
||||
"""Callback to process results from interleaved sync workers."""
|
||||
@@ -3293,7 +3291,7 @@ later is required to fix a server side protocol bug.
|
||||
err_event = multiprocessing.Event()
|
||||
finished_relpaths = set()
|
||||
project_list = list(all_projects)
|
||||
pm = Progress(
|
||||
pm = progress.Progress(
|
||||
"Syncing",
|
||||
len(project_list),
|
||||
delay=False,
|
||||
|
||||
@@ -36,6 +36,7 @@ import error
|
||||
import git_command
|
||||
import git_config
|
||||
import manifest_xml
|
||||
import progress
|
||||
from project import SyncNetworkHalfResult
|
||||
from subcmds import sync
|
||||
|
||||
@@ -1502,7 +1503,7 @@ class CheckForBloatedProjects(unittest.TestCase):
|
||||
self.assertFalse(self.cmd.git_event_log.ErrorEvent.called)
|
||||
|
||||
@mock.patch.object(git_command, "git_require", return_value=True)
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_network_only_skips_check(
|
||||
self, mock_progress: mock.Mock, mock_git_require: mock.Mock
|
||||
) -> None:
|
||||
@@ -1516,7 +1517,7 @@ class CheckForBloatedProjects(unittest.TestCase):
|
||||
self.cmd.ExecuteInParallel.assert_not_called()
|
||||
|
||||
@mock.patch.object(git_command, "git_require", return_value=True)
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_projects_without_worktree_excluded(
|
||||
self, mock_progress: mock.Mock, mock_git_require: mock.Mock
|
||||
) -> None:
|
||||
@@ -1538,7 +1539,7 @@ class CheckForBloatedProjects(unittest.TestCase):
|
||||
self.cmd.ExecuteInParallel.assert_not_called()
|
||||
|
||||
@mock.patch.object(git_command, "git_require")
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_bloated_project_found(self, mock_progress, mock_git_require):
|
||||
"""Test that it adds project to _bloated_projects."""
|
||||
mock_git_require.return_value = True
|
||||
@@ -1561,7 +1562,7 @@ class CheckForBloatedProjects(unittest.TestCase):
|
||||
self.assertEqual(self.cmd._bloated_projects, ["project"])
|
||||
|
||||
@mock.patch.object(git_command, "git_require")
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_stateless_prune_excluded(self, mock_progress, mock_git_require):
|
||||
"""Test that projects pruned for stateless sync are excluded."""
|
||||
mock_git_require.return_value = True
|
||||
@@ -1576,7 +1577,7 @@ class CheckForBloatedProjects(unittest.TestCase):
|
||||
self.assertEqual(self.cmd._bloated_projects, [])
|
||||
|
||||
@mock.patch.object(git_command, "git_require", return_value=True)
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_fetch_cmd_excluded(
|
||||
self, mock_progress: mock.Mock, mock_git_require: mock.Mock
|
||||
) -> None:
|
||||
@@ -1609,7 +1610,7 @@ class GCProjectsTest(unittest.TestCase):
|
||||
self.project.bare_git._project = self.project
|
||||
self.cmd.git_event_log = mock.MagicMock()
|
||||
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_GCProjects_skip_gc(self, mock_progress):
|
||||
"""Test that it skips GC if opt.auto_gc is False."""
|
||||
self.opt.auto_gc = False
|
||||
@@ -1620,7 +1621,7 @@ class GCProjectsTest(unittest.TestCase):
|
||||
mock_set_state.assert_called_once_with(self.project, self.opt)
|
||||
self.assertFalse(self.project.bare_git.gc.called)
|
||||
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_GCProjects_sequential(self, mock_progress):
|
||||
"""Test sequential GC (jobs < 2)."""
|
||||
with mock.patch.object(sync.Sync, "_SetPreciousObjectsState"):
|
||||
@@ -1632,7 +1633,7 @@ class GCProjectsTest(unittest.TestCase):
|
||||
for call in self.project.config.SetString.call_args_list:
|
||||
self.assertNotEqual(call.args[0], "gc.autoDetach")
|
||||
|
||||
@mock.patch("subcmds.sync.Progress")
|
||||
@mock.patch.object(progress, "Progress")
|
||||
def test_GCProjects_parallel(self, mock_progress):
|
||||
"""Test parallel GC (jobs >= 2)."""
|
||||
self.opt.jobs = 2
|
||||
|
||||
Reference in new issue
Block a user