Merge lp:~cjwatson/launchpad/git-do-not-snapshot-refs into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17841
Proposed branch: lp:~cjwatson/launchpad/git-do-not-snapshot-refs
Merge into: lp:launchpad
Diff against target: 66 lines (+13/-4)
2 files modified
lib/lp/code/interfaces/gitrepository.py (+5/-4)
lib/lp/code/model/tests/test_gitrepository.py (+8/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/git-do-not-snapshot-refs
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+276404@code.launchpad.net

Commit message

Don't snapshot GitRepository.refs or GitRepository.branches.

Description of the change

Don't snapshot GitRepository.refs or GitRepository.branches. They may be very large.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/interfaces/gitrepository.py'
--- lib/lp/code/interfaces/gitrepository.py 2015-09-29 15:54:05 +0000
+++ lib/lp/code/interfaces/gitrepository.py 2015-11-02 15:37:27 +0000
@@ -17,6 +17,7 @@
1717
18import re18import re
1919
20from lazr.lifecycle.snapshot import doNotSnapshot
20from lazr.restful.declarations import (21from lazr.restful.declarations import (
21 call_with,22 call_with,
22 collection_default_content,23 collection_default_content,
@@ -224,17 +225,17 @@
224 title=_("SSH URL"), readonly=True,225 title=_("SSH URL"), readonly=True,
225 description=_("A git+ssh:// URL for this repository.")))226 description=_("A git+ssh:// URL for this repository.")))
226227
227 refs = exported(CollectionField(228 refs = exported(doNotSnapshot(CollectionField(
228 title=_("The references present in this repository."),229 title=_("The references present in this repository."),
229 readonly=True,230 readonly=True,
230 # Really IGitRef, patched in _schema_circular_imports.py.231 # Really IGitRef, patched in _schema_circular_imports.py.
231 value_type=Reference(Interface)))232 value_type=Reference(Interface))))
232233
233 branches = exported(CollectionField(234 branches = exported(doNotSnapshot(CollectionField(
234 title=_("The branch references present in this repository."),235 title=_("The branch references present in this repository."),
235 readonly=True,236 readonly=True,
236 # Really IGitRef, patched in _schema_circular_imports.py.237 # Really IGitRef, patched in _schema_circular_imports.py.
237 value_type=Reference(Interface)))238 value_type=Reference(Interface))))
238239
239 branches_by_date = Attribute(240 branches_by_date = Attribute(
240 "The branch references present in this repository, ordered by last "241 "The branch references present in this repository, ordered by last "
241242
=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
--- lib/lp/code/model/tests/test_gitrepository.py 2015-10-05 17:02:57 +0000
+++ lib/lp/code/model/tests/test_gitrepository.py 2015-11-02 15:37:27 +0000
@@ -69,6 +69,7 @@
69from lp.code.interfaces.gitrepository import (69from lp.code.interfaces.gitrepository import (
70 IGitRepository,70 IGitRepository,
71 IGitRepositorySet,71 IGitRepositorySet,
72 IGitRepositoryView,
72 )73 )
73from lp.code.interfaces.revision import IRevisionSet74from lp.code.interfaces.revision import IRevisionSet
74from lp.code.model.branchmergeproposal import BranchMergeProposal75from lp.code.model.branchmergeproposal import BranchMergeProposal
@@ -136,6 +137,7 @@
136 ZopelessDatabaseLayer,137 ZopelessDatabaseLayer,
137 )138 )
138from lp.testing.mail_helpers import pop_notifications139from lp.testing.mail_helpers import pop_notifications
140from lp.testing.matchers import DoesNotSnapshot
139from lp.testing.pages import webservice_for_person141from lp.testing.pages import webservice_for_person
140142
141143
@@ -148,6 +150,12 @@
148 repository = self.factory.makeGitRepository()150 repository = self.factory.makeGitRepository()
149 verifyObject(IGitRepository, repository)151 verifyObject(IGitRepository, repository)
150152
153 def test_avoids_large_snapshots(self):
154 large_properties = ['refs', 'branches']
155 self.assertThat(
156 self.factory.makeGitRepository(),
157 DoesNotSnapshot(large_properties, IGitRepositoryView))
158
151 def test_unique_name_project(self):159 def test_unique_name_project(self):
152 project = self.factory.makeProduct()160 project = self.factory.makeProduct()
153 repository = self.factory.makeGitRepository(target=project)161 repository = self.factory.makeGitRepository(target=project)