summaryrefslogtreecommitdiff
path: root/morphlib/morphset.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-23 16:23:49 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-24 10:34:27 +0000
commite59d4347f511412e2162d97eca3fc65bf1c3b978 (patch)
tree452a31af4578099e4540f68218c69d684e55040d /morphlib/morphset.py
parente664f2000e233c1f05657e7e2dd85e8a182deb0e (diff)
downloadmorph-e59d4347f511412e2162d97eca3fc65bf1c3b978.tar.gz
MorphSet: Add method for changing refs en-masse
This is used to change all the refs of the morphologies in the root repository to point to the system branch instead.
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 dad3c834..2343cbae 100644
--- a/morphlib/morphset.py
+++ b/morphlib/morphset.py
@@ -222,6 +222,26 @@ class MorphologySet(object):
return known
+ def repoint_refs(self, repo_url, new_ref):
+ '''Change all specs which refer to (repo, *) to (repo, new_ref).
+
+ This is stunningly similar to change_ref, with the exception of
+ ignoring the morphology name and ref fields.
+
+ It is intended to be used before chunks are petrified
+
+ '''
+ def wanted_spec(m, kind, spec):
+ return spec['repo'] == repo_url
+
+ def process_spec(m, kind, spec):
+ if 'unpetrify-ref' not in spec:
+ spec['unpetrify-ref'] = spec['ref']
+ spec['ref'] = new_ref
+ return True
+
+ self._traverse_specs(process_spec, wanted_spec)
+
def petrify_chunks(self, resolutions):
'''Update _every_ chunk's ref to the value resolved in resolutions.