launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18992
[Merge] lp:~blr/launchpad/product-vcs-garbo into lp:launchpad
Bayard 'kit' Randel has proposed merging lp:~blr/launchpad/product-vcs-garbo into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~blr/launchpad/product-vcs-garbo/+merge/264509
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~blr/launchpad/product-vcs-garbo into lp:launchpad.
=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py 2015-03-12 15:21:27 +0000
+++ lib/lp/scripts/garbo.py 2015-07-13 00:56:34 +0000
@@ -1363,6 +1363,32 @@
transaction.commit()
+class ProductVCSPopulator(TunableLoop):
+ """Populates product.vcs from product.inferred_vcs if not set."""
+
+ maximum_chunk_size = 5000
+
+ def __init__(self, log, abort_time=None):
+ super(ProductVCSPopulator, self).__init__(log, abort_time)
+ self.start_at = 1
+ self.store = IMasterStore(Product)
+
+ def findProducts(self):
+ return self.store.find(
+ Product, Product.id >= self.start_at).order_by(Product.id)
+
+ def isDone(self):
+ return self.findProducts().is_empty()
+
+ def __call__(self, chunk_size):
+ products = list(self.findProducts()[:chunk_size])
+ for product in products:
+ if not product.vcs:
+ product.vcs = product.inferred_vcs
+ self.start_at = products[-1].id + 1
+ transaction.commit()
+
+
class LiveFSFilePruner(BulkPruner):
"""A BulkPruner to remove old `LiveFSFile`s.
@@ -1676,6 +1702,7 @@
UnlinkedAccountPruner,
UnusedAccessPolicyPruner,
UnusedPOTMsgSetPruner,
+ ProductVCSPopulator,
PreviewDiffPruner,
DiffPruner,
]
=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py 2015-05-14 13:57:51 +0000
+++ lib/lp/scripts/tests/test_garbo.py 2015-07-13 00:56:34 +0000
@@ -49,6 +49,7 @@
)
from lp.code.enums import CodeImportResultStatus
from lp.code.interfaces.codeimportevent import ICodeImportEventSet
+from lp.code.interfaces.gitrepository import IGitRepositorySet
from lp.code.model.branchjob import (
BranchJob,
BranchUpgradeJob,
@@ -63,6 +64,7 @@
from lp.registry.enums import (
BranchSharingPolicy,
BugSharingPolicy,
+ VCSType,
)
from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.person import IPersonSet
@@ -116,6 +118,7 @@
from lp.soyuz.model.reporting import LatestPersonSourcePackageReleaseCache
from lp.testing import (
FakeAdapterMixin,
+ admin_logged_in,
person_logged_in,
TestCase,
TestCaseWithFactory,
@@ -1209,6 +1212,20 @@
[InformationType.PRIVATESECURITY, InformationType.PROPRIETARY],
self.getAccessPolicyTypes(product))
+ def test_ProductVCSPopulator(self):
+ switch_dbuser('testadmin')
+ product = self.factory.makeProduct()
+ self.assertIs(None, product.vcs)
+
+ with admin_logged_in():
+ repo = self.factory.makeGitRepository(target=product)
+ getUtility(IGitRepositorySet).setDefaultRepository(
+ target=product, repository=repo)
+
+ self.runDaily()
+
+ self.assertEqual(VCSType.GIT, product.vcs)
+
def test_PopulateLatestPersonSourcePackageReleaseCache(self):
switch_dbuser('testadmin')
# Make some same test data - we create published source package
Follow ups