← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:gitrepository-no-mp-snapshots into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:gitrepository-no-mp-snapshots into launchpad:master.

Commit message:
Don't snapshot GitRepository's merge proposal collections

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/399089

They can end up being very big: for instance, ~cjwatson/launchpad has just ticked past the point of being the source repository for 1000 merge proposals, at which point `lp.services.webapp.snapshot.HARD_LIMIT_FOR_SNAPSHOT` starts to be a problem.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:gitrepository-no-mp-snapshots into launchpad:master.
diff --git a/lib/lp/code/interfaces/gitrepository.py b/lib/lp/code/interfaces/gitrepository.py
index 5b3cc61..365f082 100644
--- a/lib/lp/code/interfaces/gitrepository.py
+++ b/lib/lp/code/interfaces/gitrepository.py
@@ -518,7 +518,7 @@ class IGitRepositoryView(IHasRecipes):
         "A collection of the merge proposals where this repository is "
         "the source.")
     _api_landing_targets = exported(
-        CollectionField(
+        doNotSnapshot(CollectionField(
             title=_("Landing targets"),
             description=_(
                 "A collection of the merge proposals where this repository is "
@@ -526,13 +526,13 @@ class IGitRepositoryView(IHasRecipes):
             readonly=True,
             # Really IBranchMergeProposal, patched in
             # _schema_circular_imports.py.
-            value_type=Reference(Interface)),
+            value_type=Reference(Interface))),
         exported_as="landing_targets")
     landing_candidates = Attribute(
         "A collection of the merge proposals where this repository is "
         "the target.")
     _api_landing_candidates = exported(
-        CollectionField(
+        doNotSnapshot(CollectionField(
             title=_("Landing candidates"),
             description=_(
                 "A collection of the merge proposals where this repository is "
@@ -540,16 +540,16 @@ class IGitRepositoryView(IHasRecipes):
             readonly=True,
             # Really IBranchMergeProposal, patched in
             # _schema_circular_imports.py.
-            value_type=Reference(Interface)),
+            value_type=Reference(Interface))),
         exported_as="landing_candidates")
-    dependent_landings = exported(CollectionField(
+    dependent_landings = exported(doNotSnapshot(CollectionField(
         title=_("Dependent landings"),
         description=_(
             "A collection of the merge proposals that are dependent on this "
             "repository."),
         readonly=True,
         # Really IBranchMergeProposal, patched in _schema_circular_imports.py.
-        value_type=Reference(Interface)))
+        value_type=Reference(Interface))))
 
     def getPrecachedLandingTargets(user):
         """Return precached landing targets.
diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
index c8e5bcf..e79c4e0 100644
--- a/lib/lp/code/model/tests/test_gitrepository.py
+++ b/lib/lp/code/model/tests/test_gitrepository.py
@@ -209,7 +209,13 @@ class TestGitRepository(TestCaseWithFactory):
         verifyObject(IGitRepository, repository)
 
     def test_avoids_large_snapshots(self):
-        large_properties = ['refs', 'branches']
+        large_properties = [
+            'refs',
+            'branches',
+            '_api_landing_targets',
+            '_api_landing_candidates',
+            'dependent_landings',
+            ]
         self.assertThat(
             self.factory.makeGitRepository(),
             DoesNotSnapshot(large_properties, IGitRepositoryView))