From 4054ead45d03b5c4068a3a9c32472afe941a43e0 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 20 Jan 2014 17:38:33 -0500 Subject: [PATCH] Fix tree graph when there are many branches and they do not have a common root node. Also adds a test repo to check this case --- initdb.py | 23 ++++++++++++++++++++++- static/js/graphing.js | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/initdb.py b/initdb.py index 2cd57708f..a7911f9f3 100644 --- a/initdb.py +++ b/initdb.py @@ -104,7 +104,11 @@ def __generate_repository(user, name, description, is_public, permissions, model.set_user_repo_permission(delegate.username, user.username, name, role) - __create_subtree(repo, structure, None) + if isinstance(structure, list): + for s in structure: + __create_subtree(repo, s, None) + else: + __create_subtree(repo, structure, None) return repo @@ -216,6 +220,23 @@ def populate_database(): (1, [(1, [], 'v5.0'), (1, [], 'v6.0')], None)], None)) + __generate_repository(new_user_1, 'superwide', None, False, [], + [(10, [], 'latest2'), + (10, [], 'latest3'), + (6, [(2, [], 'latest11'), (4, [], 'latest12')], 'latest4'), + (10, [], 'latest5'), + (10, [], 'latest6'), + (10, [], 'latest7'), + (10, [], 'latest8'), + (10, [], 'latest9'), + (10, [], 'latest10'), + (10, [], 'latest13'), + (10, [], 'latest14'), + (10, [], 'latest15'), + (10, [], 'latest16'), + (10, [], 'latest17'), + (10, [], 'latest18'),]) + __generate_repository(new_user_2, 'publicrepo', 'Public repository pullable by the world.', True, [], (10, [], 'latest')) diff --git a/static/js/graphing.js b/static/js/graphing.js index 396228ab0..dffa24e0a 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -26,7 +26,7 @@ if (!Function.prototype.bind) { } var DEPTH_HEIGHT = 100; -var DEPTH_WIDTH = 132; +var DEPTH_WIDTH = 140; /** * Based off of http://mbostock.github.io/d3/talk/20111018/tree.html by Mike Bostock (@mbostock) @@ -387,7 +387,7 @@ ImageHistoryTree.prototype.buildRoot_ = function() { // Determine the maximum number of nodes at a particular level. This is used to size // the width of the tree properly. - var maxChildCount = 0; + var maxChildCount = roots.length; for (var i = 0; i < this.images_.length; ++i) { var image = this.images_[i]; var imageNode = imageByDBID[image.dbid];