diff options
| author | Josip Sokcevic <sokcevic@google.com> | 2024-02-22 16:38:00 -0800 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-02-27 17:28:33 +0000 |
| commit | 5554572f02537b8646139d59ab520e59e1d5f7b3 (patch) | |
| tree | d730611b566ec7f691619dc9a6c08b7e3d6b958e /tests | |
| parent | 97ca50f5f946c39e8ecd00c7e6ea78e90b4bb6dd (diff) | |
| download | git-repo-5554572f02537b8646139d59ab520e59e1d5f7b3.tar.gz | |
sync: Introduce git checkout levelsv2.42
If a repo manifest is updated so that project B is placed within a
project A, and if project A had content in new B's location in the old
checkout, then repo sync could break depending on checkout order, since
B can't be checked out before A.
This change introduces checkout levels which enforces right sequence of
checkouts while still allowing for parallel checkout. In an example
above, A will always be checked out first before B.
BUG=b:325119758
TEST=./run_tests, manual sync on ChromeOS repository
Change-Id: Ib3b5e4d2639ca56620a1e4c6bf76d7b1ab805250
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/410421
Tested-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Greg Edelston <gredelston@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_subcmds_sync.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_subcmds_sync.py b/tests/test_subcmds_sync.py index af6bbef7..13e23e34 100644 --- a/tests/test_subcmds_sync.py +++ b/tests/test_subcmds_sync.py | |||
| @@ -304,6 +304,32 @@ class LocalSyncState(unittest.TestCase): | |||
| 304 | self.assertEqual(self.state.GetFetchTime(projA), 5) | 304 | self.assertEqual(self.state.GetFetchTime(projA), 5) |
| 305 | 305 | ||
| 306 | 306 | ||
| 307 | class SafeCheckoutOrder(unittest.TestCase): | ||
| 308 | def test_no_nested(self): | ||
| 309 | p_f = mock.MagicMock(relpath="f") | ||
| 310 | p_foo = mock.MagicMock(relpath="foo") | ||
| 311 | out = sync._SafeCheckoutOrder([p_f, p_foo]) | ||
| 312 | self.assertEqual(out, [[p_f, p_foo]]) | ||
| 313 | |||
| 314 | def test_basic_nested(self): | ||
| 315 | p_foo = p_foo = mock.MagicMock(relpath="foo") | ||
| 316 | p_foo_bar = mock.MagicMock(relpath="foo/bar") | ||
| 317 | out = sync._SafeCheckoutOrder([p_foo, p_foo_bar]) | ||
| 318 | self.assertEqual(out, [[p_foo], [p_foo_bar]]) | ||
| 319 | |||
| 320 | def test_complex_nested(self): | ||
| 321 | p_foo = mock.MagicMock(relpath="foo") | ||
| 322 | p_foo_bar = mock.MagicMock(relpath="foo/bar") | ||
| 323 | p_foo_bar_baz_baq = mock.MagicMock(relpath="foo/bar/baz/baq") | ||
| 324 | p_bar = mock.MagicMock(relpath="bar") | ||
| 325 | out = sync._SafeCheckoutOrder( | ||
| 326 | [p_foo_bar_baz_baq, p_foo, p_foo_bar, p_bar] | ||
| 327 | ) | ||
| 328 | self.assertEqual( | ||
| 329 | out, [[p_bar, p_foo], [p_foo_bar], [p_foo_bar_baz_baq]] | ||
| 330 | ) | ||
| 331 | |||
| 332 | |||
| 307 | class GetPreciousObjectsState(unittest.TestCase): | 333 | class GetPreciousObjectsState(unittest.TestCase): |
| 308 | """Tests for _GetPreciousObjectsState.""" | 334 | """Tests for _GetPreciousObjectsState.""" |
| 309 | 335 | ||
