clearing out global references in git

This commit is contained in:
Peter Cottle 2012-11-03 14:35:56 -07:00
parent b1d78c2459
commit b31d550184
2 changed files with 16 additions and 12 deletions

View file

@ -14,6 +14,9 @@ function GitEngine(options) {
this.branchCollection = options.branches; this.branchCollection = options.branches;
this.commitCollection = options.collection; this.commitCollection = options.collection;
this.gitVisuals = options.gitVisuals;
console.log('git visuals is', this.gitVisuals);
// global variable to keep track of the options given // global variable to keep track of the options given
// along with the command call. // along with the command call.
this.commandOptions = {}; this.commandOptions = {};
@ -115,7 +118,7 @@ GitEngine.prototype.instantiateFromTree = function(tree) {
var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id); var branch = this.getOrMakeRecursive(tree, createdSoFar, branchJSON.id);
this.branchCollection.add(branch, {silent: true}); this.branchCollection.add(branch, {silent: true});
gitVisuals.addBranch(branch, true /* paper override */); this.gitVisuals.addBranch(branch, true /* paper override */);
}, this); }, this);
var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id); var HEAD = this.getOrMakeRecursive(tree, createdSoFar, tree.HEAD.id);
@ -131,16 +134,16 @@ GitEngine.prototype.reloadGraphics = function() {
} }
}); });
gitVisuals.rootCommit = rootCommit; this.gitVisuals.rootCommit = rootCommit;
// this just basically makes the HEAD branch. the head branch really should have been // this just basically makes the HEAD branch. the head branch really should have been
// a member of a collection and not this annoying edge case stuff... // a member of a collection and not this annoying edge case stuff...
gitVisuals.whenGitEngineReady(this); this.gitVisuals.whenGitEngineReady(this);
// when the paper is ready // when the paper is ready
gitVisuals.drawTreeFromReload(); this.gitVisuals.drawTreeFromReload();
gitVisuals.refreshTreeHarsh(); this.gitVisuals.refreshTreeHarsh();
}; };
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) { GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -214,7 +217,7 @@ GitEngine.prototype.removeAll = function() {
this.branchCollection.reset(); this.branchCollection.reset();
this.commitCollection.reset(); this.commitCollection.reset();
gitVisuals.resetAll(); this.gitVisuals.resetAll();
}; };
GitEngine.prototype.getDetachedHead = function() { GitEngine.prototype.getDetachedHead = function() {
@ -389,7 +392,7 @@ GitEngine.prototype.revert = function(whichCommits) {
animationResponse.toRebaseArray = toRebase.slice(0); animationResponse.toRebaseArray = toRebase.slice(0);
animationResponse.rebaseSteps = []; animationResponse.rebaseSteps = [];
beforeSnapshot = gitVisuals.genSnapshot(); beforeSnapshot = this.gitVisuals.genSnapshot();
var afterSnapshot; var afterSnapshot;
// now make a bunch of commits on top of where we are // now make a bunch of commits on top of where we are
@ -405,7 +408,7 @@ GitEngine.prototype.revert = function(whichCommits) {
base = newCommit; base = newCommit;
// animation stuff // animation stuff
afterSnapshot = gitVisuals.genSnapshot(); afterSnapshot = this.gitVisuals.genSnapshot();
animationResponse.rebaseSteps.push({ animationResponse.rebaseSteps.push({
oldCommit: oldCommit, oldCommit: oldCommit,
newCommit: newCommit, newCommit: newCommit,
@ -1001,7 +1004,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
// do the rebase, and also maintain all our animation info during this // do the rebase, and also maintain all our animation info during this
animationResponse.rebaseSteps = []; animationResponse.rebaseSteps = [];
var beforeSnapshot = gitVisuals.genSnapshot(); var beforeSnapshot = this.gitVisuals.genSnapshot();
var afterSnapshot; var afterSnapshot;
_.each(toRebase, function(old) { _.each(toRebase, function(old) {
var newId = this.rebaseAltID(old.get('id')); var newId = this.rebaseAltID(old.get('id'));
@ -1010,7 +1013,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
base = newCommit; base = newCommit;
// animation info // animation info
afterSnapshot = gitVisuals.genSnapshot(); afterSnapshot = this.gitVisuals.genSnapshot();
animationResponse.rebaseSteps.push({ animationResponse.rebaseSteps.push({
oldCommit: old, oldCommit: old,
newCommit: newCommit, newCommit: newCommit,
@ -1259,7 +1262,7 @@ GitEngine.prototype.dispatch = function(command, callback) {
if (!this.animationQueue.get('animations').length && !this.animationQueue.get('defer')) { if (!this.animationQueue.get('animations').length && !this.animationQueue.get('defer')) {
this.animationQueue.add(new Animation({ this.animationQueue.add(new Animation({
closure: function() { closure: function() {
gitVisuals.refreshTree(); this.gitVisuals.refreshTree();
} }
})); }));
} }

View file

@ -23,7 +23,8 @@ var Visualization = Backbone.View.extend({
gitEngine = new GitEngine({ gitEngine = new GitEngine({
collection: this.commitCollection, collection: this.commitCollection,
branches: this.branchCollection branches: this.branchCollection,
gitVisuals: this.gitVisuals
}); });
this.gitEngine = gitEngine; this.gitEngine = gitEngine;