Prune images that are only referenced by tags which are not currently alive.
This commit is contained in:
parent
f32bd748e4
commit
d81e6c7a4d
1 changed files with 20 additions and 0 deletions
|
@ -485,6 +485,9 @@ ImageHistoryTree.prototype.buildRoot_ = function() {
|
||||||
maxChildHeight = Math.max(maxChildHeight, key);
|
maxChildHeight = Math.max(maxChildHeight, key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Recursively prune the nodes that are not referenced by a tag
|
||||||
|
this.pruneUnreferenced_(root);
|
||||||
|
|
||||||
// Compact the graph so that any single chain of three (or more) images becomes a collapsed
|
// Compact the graph so that any single chain of three (or more) images becomes a collapsed
|
||||||
// section. We only do this if the max width is > 1 (since for a single width tree, no long
|
// section. We only do this if the max width is > 1 (since for a single width tree, no long
|
||||||
// chain will hide a branch).
|
// chain will hide a branch).
|
||||||
|
@ -505,6 +508,23 @@ ImageHistoryTree.prototype.buildRoot_ = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prunes images which are not referenced either directly or indireclty by any tag.
|
||||||
|
*/
|
||||||
|
ImageHistoryTree.prototype.pruneUnreferenced_ = function(node) {
|
||||||
|
if (node.children) {
|
||||||
|
var surviving_children = []
|
||||||
|
for (var i = 0; i < node.children.length; ++i) {
|
||||||
|
if (!this.pruneUnreferenced_(node.children[i])) {
|
||||||
|
surviving_children.push(node.children[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.children = surviving_children;
|
||||||
|
}
|
||||||
|
return (node.children.length == 0 && node.tags.length == 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the height of the tree at its longest chain.
|
* Determines the height of the tree at its longest chain.
|
||||||
*/
|
*/
|
||||||
|
|
Reference in a new issue