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
1=== modified file 'lib/lp/code/interfaces/gitrepository.py'
2--- lib/lp/code/interfaces/gitrepository.py 2015-09-29 15:54:05 +0000
3+++ lib/lp/code/interfaces/gitrepository.py 2015-11-02 15:37:27 +0000
4@@ -17,6 +17,7 @@
5
6 import re
7
8+from lazr.lifecycle.snapshot import doNotSnapshot
9 from lazr.restful.declarations import (
10 call_with,
11 collection_default_content,
12@@ -224,17 +225,17 @@
13 title=_("SSH URL"), readonly=True,
14 description=_("A git+ssh:// URL for this repository.")))
15
16- refs = exported(CollectionField(
17+ refs = exported(doNotSnapshot(CollectionField(
18 title=_("The references present in this repository."),
19 readonly=True,
20 # Really IGitRef, patched in _schema_circular_imports.py.
21- value_type=Reference(Interface)))
22+ value_type=Reference(Interface))))
23
24- branches = exported(CollectionField(
25+ branches = exported(doNotSnapshot(CollectionField(
26 title=_("The branch references present in this repository."),
27 readonly=True,
28 # Really IGitRef, patched in _schema_circular_imports.py.
29- value_type=Reference(Interface)))
30+ value_type=Reference(Interface))))
31
32 branches_by_date = Attribute(
33 "The branch references present in this repository, ordered by last "
34
35=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
36--- lib/lp/code/model/tests/test_gitrepository.py 2015-10-05 17:02:57 +0000
37+++ lib/lp/code/model/tests/test_gitrepository.py 2015-11-02 15:37:27 +0000
38@@ -69,6 +69,7 @@
39 from lp.code.interfaces.gitrepository import (
40 IGitRepository,
41 IGitRepositorySet,
42+ IGitRepositoryView,
43 )
44 from lp.code.interfaces.revision import IRevisionSet
45 from lp.code.model.branchmergeproposal import BranchMergeProposal
46@@ -136,6 +137,7 @@
47 ZopelessDatabaseLayer,
48 )
49 from lp.testing.mail_helpers import pop_notifications
50+from lp.testing.matchers import DoesNotSnapshot
51 from lp.testing.pages import webservice_for_person
52
53
54@@ -148,6 +150,12 @@
55 repository = self.factory.makeGitRepository()
56 verifyObject(IGitRepository, repository)
57
58+ def test_avoids_large_snapshots(self):
59+ large_properties = ['refs', 'branches']
60+ self.assertThat(
61+ self.factory.makeGitRepository(),
62+ DoesNotSnapshot(large_properties, IGitRepositoryView))
63+
64 def test_unique_name_project(self):
65 project = self.factory.makeProduct()
66 repository = self.factory.makeGitRepository(target=project)