Merge ~cjwatson/launchpad:remove-SpecificationSet-getDependencyDict into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 82c3a0f58bba54604094836dd98a46b0ecef8ac4
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:remove-SpecificationSet-getDependencyDict
Merge into: launchpad:master
Diff against target: 170 lines (+1/-129)
3 files modified
lib/lp/blueprints/doc/specification.rst (+0/-83)
lib/lp/blueprints/interfaces/specification.py (+0/-9)
lib/lp/blueprints/model/specification.py (+1/-37)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+431815@code.launchpad.net

Commit message

Remove SpecificationSet.getDependencyDict

Description of the change

This was used for about six months, but it hasn't been used outside tests since commit d057c934a1ba16643082d587bc785ff3e72c52b6 in August 2008.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/blueprints/doc/specification.rst b/lib/lp/blueprints/doc/specification.rst
2index dbc6876..7ba3314 100644
3--- a/lib/lp/blueprints/doc/specification.rst
4+++ b/lib/lp/blueprints/doc/specification.rst
5@@ -312,89 +312,6 @@ block-them-too.
6 svg-support
7
8
9-Dependency mapping - `ISpecificationSet.getDependencyDict`
10-..........................................................
11-
12-In order to implement the specification plan page efficiently,
13-`ISpecificationSet` provides a utility method that returns a mapping
14-from a sequence of specifications to their dependencies.
15-
16- >>> spec_a = specset.new(
17- ... "spec-a",
18- ... "Spec A",
19- ... "http://www.example.com/SpecA",
20- ... "Specification A",
21- ... SpecificationDefinitionStatus.APPROVED,
22- ... mark,
23- ... target=ubuntu,
24- ... )
25- >>> spec_b = specset.new(
26- ... "spec-b",
27- ... "Spec B",
28- ... "http://www.example.com/SpecB",
29- ... "Specification B",
30- ... SpecificationDefinitionStatus.APPROVED,
31- ... mark,
32- ... target=ubuntu,
33- ... )
34- >>> spec_c = specset.new(
35- ... "spec-c",
36- ... "Spec C",
37- ... "http://www.example.com/SpecC",
38- ... "Specification C",
39- ... SpecificationDefinitionStatus.APPROVED,
40- ... mark,
41- ... target=ubuntu,
42- ... )
43- >>> spec_d = specset.new(
44- ... "spec-d",
45- ... "Spec D",
46- ... "http://www.example.com/SpecD",
47- ... "Specification D",
48- ... SpecificationDefinitionStatus.APPROVED,
49- ... mark,
50- ... target=ubuntu,
51- ... )
52-
53-When the specs provided have no dependencies, an empty dict is returned.
54-
55- >>> specset.getDependencyDict([spec_a, spec_b, spec_c, spec_d])
56- {}
57-
58-If there are dependencies between the specs, the method returns a
59-mapping between them.
60-
61- >>> spec_a.createDependency(spec_b)
62- <...SpecificationDependency object at ...>
63-
64- >>> spec_a.createDependency(spec_c)
65- <...SpecificationDependency object at ...>
66-
67- >>> spec_c.createDependency(spec_d)
68- <...SpecificationDependency object at ...>
69-
70- >>> deps_dict = specset.getDependencyDict(
71- ... [spec_a, spec_b, spec_c, spec_d]
72- ... )
73- >>> spec_deps = [
74- ... (specset.get(key).name, value)
75- ... for (key, value) in deps_dict.items()
76- ... ]
77- >>> for (spec_name, deps) in sorted(spec_deps):
78- ... print(
79- ... "%s --> %s"
80- ... % (spec_name, ", ".join([dep.name for dep in deps]))
81- ... )
82- ...
83- spec-a --> spec-b, spec-c
84- spec-c --> spec-d
85-
86-Passing in an empty sequences returns an empty dict:
87-
88- >>> specset.getDependencyDict([])
89- {}
90-
91-
92 Specification Subscriptions
93 ---------------------------
94
95diff --git a/lib/lp/blueprints/interfaces/specification.py b/lib/lp/blueprints/interfaces/specification.py
96index 2443c8c..b47f64d 100644
97--- a/lib/lp/blueprints/interfaces/specification.py
98+++ b/lib/lp/blueprints/interfaces/specification.py
99@@ -963,15 +963,6 @@ class ISpecificationSet(IHasSpecifications):
100 ):
101 """Create a new specification."""
102
103- def getDependencyDict(specifications):
104- """Return a dictionary mapping specifications to their dependencies.
105-
106- The results are ordered by descending priority, ascending dependency
107- name, and id.
108-
109- :param specifications: a sequence of the `ISpecification` to look up.
110- """
111-
112 def get(spec_id):
113 """Return the ISpecification with the given spec_id."""
114
115diff --git a/lib/lp/blueprints/model/specification.py b/lib/lp/blueprints/model/specification.py
116index 2c27cfa..4ae2df1 100644
117--- a/lib/lp/blueprints/model/specification.py
118+++ b/lib/lp/blueprints/model/specification.py
119@@ -86,10 +86,7 @@ from lp.services.database import bulk
120 from lp.services.database.constants import DEFAULT, UTC_NOW
121 from lp.services.database.enumcol import DBEnum
122 from lp.services.database.interfaces import IStore
123-from lp.services.database.sqlbase import (
124- convert_storm_clause_to_string,
125- sqlvalues,
126-)
127+from lp.services.database.sqlbase import convert_storm_clause_to_string
128 from lp.services.database.stormbase import StormBase
129 from lp.services.mail.helpers import get_contact_email_addresses
130 from lp.services.propertycache import cachedproperty, get_property_cache
131@@ -1375,39 +1372,6 @@ class SpecificationSet(HasSpecificationsMixin):
132 spec.transitionToInformationType(information_type, None)
133 return spec
134
135- def getDependencyDict(self, specifications):
136- """See `ISpecificationSet`."""
137- specification_ids = [spec.id for spec in specifications]
138-
139- if len(specification_ids) == 0:
140- return {}
141-
142- results = (
143- Store.of(specifications[0])
144- .execute(
145- """
146- SELECT SpecificationDependency.specification,
147- SpecificationDependency.dependency
148- FROM SpecificationDependency, Specification
149- WHERE SpecificationDependency.specification IN %s
150- AND SpecificationDependency.dependency = Specification.id
151- ORDER BY Specification.priority DESC, Specification.name,
152- Specification.id
153- """
154- % sqlvalues(specification_ids)
155- )
156- .get_all()
157- )
158-
159- dependencies = {}
160- for spec_id, dep_id in results:
161- if spec_id not in dependencies:
162- dependencies[spec_id] = []
163- dependency = IStore(Specification).get(Specification, dep_id)
164- dependencies[spec_id].append(dependency)
165-
166- return dependencies
167-
168 def get(self, spec_id):
169 """See lp.blueprints.interfaces.specification.ISpecificationSet."""
170 return IStore(Specification).get(Specification, spec_id)

Subscribers

People subscribed via source and target branches

to status/vote changes: