sync: Don't checkout if no worktree
Interleaved sync should not try checkout out a project if it's a mirror. Change-Id: I2549faab197a3202d79a10e44b449b68d53e3fe7
This commit is contained in:
parent
25858c8b16
commit
8402130ca2
2 changed files with 74 additions and 45 deletions
|
@ -2269,7 +2269,13 @@ later is required to fix a server side protocol bug.
|
||||||
checkout_finish = None
|
checkout_finish = None
|
||||||
checkout_stderr = ""
|
checkout_stderr = ""
|
||||||
|
|
||||||
if fetch_success and not opt.network_only:
|
if fetch_success:
|
||||||
|
# We skip checkout if it's network-only or if the project has no
|
||||||
|
# working tree (e.g., a mirror).
|
||||||
|
if opt.network_only or not project.worktree:
|
||||||
|
checkout_success = True
|
||||||
|
else:
|
||||||
|
# This is a normal project that needs a checkout.
|
||||||
checkout_start = time.time()
|
checkout_start = time.time()
|
||||||
stderr_capture = io.StringIO()
|
stderr_capture = io.StringIO()
|
||||||
try:
|
try:
|
||||||
|
@ -2299,7 +2305,9 @@ later is required to fix a server side protocol bug.
|
||||||
except GitError as e:
|
except GitError as e:
|
||||||
checkout_error = e
|
checkout_error = e
|
||||||
logger.error(
|
logger.error(
|
||||||
"error.GitError: Cannot checkout %s: %s", project.name, e
|
"error.GitError: Cannot checkout %s: %s",
|
||||||
|
project.name,
|
||||||
|
e,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
checkout_error = e
|
checkout_error = e
|
||||||
|
@ -2488,9 +2496,10 @@ later is required to fix a server side protocol bug.
|
||||||
sync_event = _threading.Event()
|
sync_event = _threading.Event()
|
||||||
sync_progress_thread = self._CreateSyncProgressThread(pm, sync_event)
|
sync_progress_thread = self._CreateSyncProgressThread(pm, sync_event)
|
||||||
|
|
||||||
with multiprocessing.Manager() as manager, ssh.ProxyManager(
|
with (
|
||||||
manager
|
multiprocessing.Manager() as manager,
|
||||||
) as ssh_proxy:
|
ssh.ProxyManager(manager) as ssh_proxy,
|
||||||
|
):
|
||||||
ssh_proxy.sock()
|
ssh_proxy.sock()
|
||||||
with self.ParallelContext():
|
with self.ParallelContext():
|
||||||
self.get_parallel_context()["ssh_proxy"] = ssh_proxy
|
self.get_parallel_context()["ssh_proxy"] = ssh_proxy
|
||||||
|
|
|
@ -309,6 +309,7 @@ class FakeProject:
|
||||||
self.relpath = relpath
|
self.relpath = relpath
|
||||||
self.name = name or relpath
|
self.name = name or relpath
|
||||||
self.objdir = objdir or relpath
|
self.objdir = objdir or relpath
|
||||||
|
self.worktree = relpath
|
||||||
|
|
||||||
self.use_git_worktrees = False
|
self.use_git_worktrees = False
|
||||||
self.UseAlternates = False
|
self.UseAlternates = False
|
||||||
|
@ -836,6 +837,25 @@ class InterleavedSyncTest(unittest.TestCase):
|
||||||
project.Sync_NetworkHalf.assert_called_once()
|
project.Sync_NetworkHalf.assert_called_once()
|
||||||
project.Sync_LocalHalf.assert_not_called()
|
project.Sync_LocalHalf.assert_not_called()
|
||||||
|
|
||||||
|
def test_worker_no_worktree(self):
|
||||||
|
"""Test interleaved sync does not checkout with no worktree."""
|
||||||
|
opt = self._get_opts()
|
||||||
|
project = self.projA
|
||||||
|
project.worktree = None
|
||||||
|
project.Sync_NetworkHalf = mock.Mock(
|
||||||
|
return_value=SyncNetworkHalfResult(error=None, remote_fetched=True)
|
||||||
|
)
|
||||||
|
project.Sync_LocalHalf = mock.Mock()
|
||||||
|
self.mock_context["projects"] = [project]
|
||||||
|
|
||||||
|
result_obj = self.cmd._SyncProjectList(opt, [0])
|
||||||
|
result = result_obj.results[0]
|
||||||
|
|
||||||
|
self.assertTrue(result.fetch_success)
|
||||||
|
self.assertTrue(result.checkout_success)
|
||||||
|
project.Sync_NetworkHalf.assert_called_once()
|
||||||
|
project.Sync_LocalHalf.assert_not_called()
|
||||||
|
|
||||||
def test_worker_fetch_fails_exception(self):
|
def test_worker_fetch_fails_exception(self):
|
||||||
"""Test _SyncProjectList with an exception during fetch."""
|
"""Test _SyncProjectList with an exception during fetch."""
|
||||||
opt = self._get_opts()
|
opt = self._get_opts()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue