Skip to content

Instantly share code, notes, and snippets.

@mvaled
Created April 15, 2013 20:15
Show Gist options
  • Save mvaled/5390968 to your computer and use it in GitHub Desktop.
Save mvaled/5390968 to your computer and use it in GitHub Desktop.
Possible fix (rather hackish)
diff -r 68d58cdd5004 fanstatic/core.py
--- a/fanstatic/core.py Wed Mar 27 07:16:35 2013 -0400
+++ b/fanstatic/core.py Mon Apr 15 16:12:43 2013 -0400
@@ -1063,12 +1063,17 @@
def consolidate(resources):
# keep track of rollups: rollup key -> set of resource keys
potential_rollups = {}
+ used_rollups_depends = {} # resource key -> rollup
for resource in resources:
for rollup in resource.rollups:
s = potential_rollups.setdefault(
(rollup.library, rollup.relpath), set())
s.add((resource.library, resource.relpath))
+ s = used_rollups_depends.setdefault(
+ (resource.library, resource.relpath), set())
+ s.add(rollup)
+
# now go through resources, replacing them with rollups if
# conditions match
result = []
@@ -1084,6 +1089,22 @@
result.append(superseders[-1])
else:
# nothing to supersede resource so use it directly
+ #
+ # But modify the dependency graph so that if a resource depends on
+ # another that's being superseded, update the depends by depending
+ # on the rollup.
+ modify = []
+ for dep in resource.depends:
+ if dep not in result:
+ s = used_rollups_depends.get((dep.library, dep.relpath),
+ [])
+ inrollup = next((rollup for rollup in s
+ if dep in rollup.supersedes
+ if rollup in result), None)
+ if inrollup:
+ modify.append(inrollup)
+ if modify:
+ resource.depends.update(dep for dep in modify)
result.append(resource)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment