diff --git a/src/git.js b/src/git.js index d4f3dcae..25bfe5c8 100644 --- a/src/git.js +++ b/src/git.js @@ -10,10 +10,9 @@ function GitEngine(options) { this.rootCommit = null; this.refs = {}; this.HEAD = null; - this.id_gen = 0; + this.branchCollection = options.branches; this.commitCollection = options.collection; - this.gitVisuals = options.gitVisuals; // global variable to keep track of the options given @@ -115,11 +114,20 @@ GitEngine.prototype.instantiateFromTree = function(tree) { var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id); this.branchCollection.add(branch, {silent: true}); - this.gitVisuals.addBranch(branch, true /* paper override */); }, this); var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id); this.HEAD = HEAD; + + this.rootCommit = createdSoFar['C0']; + if (!this.rootCommit) { + throw new Error('Need root commit of C0 for calculations'); + } + this.refs = createdSoFar; + + this.branchCollection.each(function(branch) { + this.gitVisuals.addBranch(branch); + }, this); }; GitEngine.prototype.reloadGraphics = function() { @@ -213,6 +221,9 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) { GitEngine.prototype.removeAll = function() { this.branchCollection.reset(); this.commitCollection.reset(); + this.refs = {}; + this.HEAD = null; + this.rootCommit = null; this.gitVisuals.resetAll(); }; @@ -1602,6 +1613,7 @@ var Commit = Backbone.Model.extend({ _.each(this.get('parents'), function(parent) { parent.get('children').push(this); + console.log('adding myself', this.get('id'), 'to parent', parent); this.addEdgeToVisuals(parent); }, this); } diff --git a/src/visuals.js b/src/visuals.js index d9f2dcda..64a1f12b 100644 --- a/src/visuals.js +++ b/src/visuals.js @@ -524,6 +524,10 @@ GitVisuals.prototype.canvasResize = function(width, height) { } }; +GitVisuals.prototype.addCommit = function(commit) { + // TODO +}; + GitVisuals.prototype.addNode = function(id, commit) { this.commitMap[id] = commit; if (commit.get('rootCommit')) { @@ -541,7 +545,6 @@ GitVisuals.prototype.addNode = function(id, commit) { if (this.gitReady) { visNode.genGraphics(this.paper); } - return visNode; }; diff --git a/todo.txt b/todo.txt index 78fea883..9483c168 100644 --- a/todo.txt +++ b/todo.txt @@ -20,14 +20,10 @@ Minor Bugs to fix: Big Bugs to fix: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- load and save no longer work... - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -Pre-publish things: -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/************************************* + ** Publish Things ** + ************************************/ - cross browser support - minify JS - fix terminal input when extra long