launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29335
[Merge] ~cjwatson/launchpad:remove-SpecificationSet-getDependencyDict into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:remove-SpecificationSet-getDependencyDict into launchpad:master.
Commit message:
Remove SpecificationSet.getDependencyDict
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/431815
This was used for about six months, but it hasn't been used outside tests since commit d057c934a1ba16643082d587bc785ff3e72c52b6 in August 2008.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-SpecificationSet-getDependencyDict into launchpad:master.
diff --git a/lib/lp/blueprints/doc/specification.rst b/lib/lp/blueprints/doc/specification.rst
index dbc6876..7ba3314 100644
--- a/lib/lp/blueprints/doc/specification.rst
+++ b/lib/lp/blueprints/doc/specification.rst
@@ -312,89 +312,6 @@ block-them-too.
svg-support
-Dependency mapping - `ISpecificationSet.getDependencyDict`
-..........................................................
-
-In order to implement the specification plan page efficiently,
-`ISpecificationSet` provides a utility method that returns a mapping
-from a sequence of specifications to their dependencies.
-
- >>> spec_a = specset.new(
- ... "spec-a",
- ... "Spec A",
- ... "http://www.example.com/SpecA",
- ... "Specification A",
- ... SpecificationDefinitionStatus.APPROVED,
- ... mark,
- ... target=ubuntu,
- ... )
- >>> spec_b = specset.new(
- ... "spec-b",
- ... "Spec B",
- ... "http://www.example.com/SpecB",
- ... "Specification B",
- ... SpecificationDefinitionStatus.APPROVED,
- ... mark,
- ... target=ubuntu,
- ... )
- >>> spec_c = specset.new(
- ... "spec-c",
- ... "Spec C",
- ... "http://www.example.com/SpecC",
- ... "Specification C",
- ... SpecificationDefinitionStatus.APPROVED,
- ... mark,
- ... target=ubuntu,
- ... )
- >>> spec_d = specset.new(
- ... "spec-d",
- ... "Spec D",
- ... "http://www.example.com/SpecD",
- ... "Specification D",
- ... SpecificationDefinitionStatus.APPROVED,
- ... mark,
- ... target=ubuntu,
- ... )
-
-When the specs provided have no dependencies, an empty dict is returned.
-
- >>> specset.getDependencyDict([spec_a, spec_b, spec_c, spec_d])
- {}
-
-If there are dependencies between the specs, the method returns a
-mapping between them.
-
- >>> spec_a.createDependency(spec_b)
- <...SpecificationDependency object at ...>
-
- >>> spec_a.createDependency(spec_c)
- <...SpecificationDependency object at ...>
-
- >>> spec_c.createDependency(spec_d)
- <...SpecificationDependency object at ...>
-
- >>> deps_dict = specset.getDependencyDict(
- ... [spec_a, spec_b, spec_c, spec_d]
- ... )
- >>> spec_deps = [
- ... (specset.get(key).name, value)
- ... for (key, value) in deps_dict.items()
- ... ]
- >>> for (spec_name, deps) in sorted(spec_deps):
- ... print(
- ... "%s --> %s"
- ... % (spec_name, ", ".join([dep.name for dep in deps]))
- ... )
- ...
- spec-a --> spec-b, spec-c
- spec-c --> spec-d
-
-Passing in an empty sequences returns an empty dict:
-
- >>> specset.getDependencyDict([])
- {}
-
-
Specification Subscriptions
---------------------------
diff --git a/lib/lp/blueprints/interfaces/specification.py b/lib/lp/blueprints/interfaces/specification.py
index 2443c8c..b47f64d 100644
--- a/lib/lp/blueprints/interfaces/specification.py
+++ b/lib/lp/blueprints/interfaces/specification.py
@@ -963,15 +963,6 @@ class ISpecificationSet(IHasSpecifications):
):
"""Create a new specification."""
- def getDependencyDict(specifications):
- """Return a dictionary mapping specifications to their dependencies.
-
- The results are ordered by descending priority, ascending dependency
- name, and id.
-
- :param specifications: a sequence of the `ISpecification` to look up.
- """
-
def get(spec_id):
"""Return the ISpecification with the given spec_id."""
diff --git a/lib/lp/blueprints/model/specification.py b/lib/lp/blueprints/model/specification.py
index 2c27cfa..4ae2df1 100644
--- a/lib/lp/blueprints/model/specification.py
+++ b/lib/lp/blueprints/model/specification.py
@@ -86,10 +86,7 @@ from lp.services.database import bulk
from lp.services.database.constants import DEFAULT, UTC_NOW
from lp.services.database.enumcol import DBEnum
from lp.services.database.interfaces import IStore
-from lp.services.database.sqlbase import (
- convert_storm_clause_to_string,
- sqlvalues,
-)
+from lp.services.database.sqlbase import convert_storm_clause_to_string
from lp.services.database.stormbase import StormBase
from lp.services.mail.helpers import get_contact_email_addresses
from lp.services.propertycache import cachedproperty, get_property_cache
@@ -1375,39 +1372,6 @@ class SpecificationSet(HasSpecificationsMixin):
spec.transitionToInformationType(information_type, None)
return spec
- def getDependencyDict(self, specifications):
- """See `ISpecificationSet`."""
- specification_ids = [spec.id for spec in specifications]
-
- if len(specification_ids) == 0:
- return {}
-
- results = (
- Store.of(specifications[0])
- .execute(
- """
- SELECT SpecificationDependency.specification,
- SpecificationDependency.dependency
- FROM SpecificationDependency, Specification
- WHERE SpecificationDependency.specification IN %s
- AND SpecificationDependency.dependency = Specification.id
- ORDER BY Specification.priority DESC, Specification.name,
- Specification.id
- """
- % sqlvalues(specification_ids)
- )
- .get_all()
- )
-
- dependencies = {}
- for spec_id, dep_id in results:
- if spec_id not in dependencies:
- dependencies[spec_id] = []
- dependency = IStore(Specification).get(Specification, dep_id)
- dependencies[spec_id].append(dependency)
-
- return dependencies
-
def get(self, spec_id):
"""See lp.blueprints.interfaces.specification.ISpecificationSet."""
return IStore(Specification).get(Specification, spec_id)