summaryrefslogtreecommitdiff
path: root/morphlib/morphset.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-19 10:27:36 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-24 10:26:03 +0000
commit924e2192ae3de5974ee058c0ea9c180f2e46d78e (patch)
tree895c52ab9f1d1401f58eb971609a6faebdf04d77 /morphlib/morphset.py
parentf58e5f85d135d00f92116a97bb8bce82d46f0d36 (diff)
downloadmorph-924e2192ae3de5974ee058c0ea9c180f2e46d78e.tar.gz
MorphSet: add a list_refs() method
This will be used to factor the morphology traversal code out of petrify, since it is cleaner to find out which refs are present, resolve them, then update them, instead of the previous approach which updated as part of the traversal.
Diffstat (limited to 'morphlib/morphset.py')
-rw-r--r--morphlib/morphset.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/morphlib/morphset.py b/morphlib/morphset.py
index 468bcbe9..10583326 100644
--- a/morphlib/morphset.py
+++ b/morphlib/morphset.py
@@ -202,3 +202,23 @@ class MorphologySet(object):
self._traverse_specs(process_spec, wanted_spec)
+ def list_refs(self):
+ '''Return a set of all the (repo, ref) pairs in the MorphologySet.
+
+ This does not dirty the morphologies so they do not need to be
+ written back to the disk.
+
+ '''
+ known = set()
+
+ def wanted_spec(m, kind, spec):
+ return (spec['repo'], spec['ref']) not in known
+
+ def process_spec(spec):
+ known.add((spec['repo'], spec['ref']))
+ return False
+
+ self._traverse_specs(process_spec, wanted_spec)
+
+ return known
+