mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 01:10:04 +02:00
deep copy error
This commit is contained in:
parent
0a9ec17852
commit
c8c45c9a40
1 changed files with 7 additions and 1 deletions
|
@ -74,6 +74,7 @@ GitEngine.prototype.exportTree = function() {
|
||||||
|
|
||||||
var HEAD = this.HEAD.toJSON();
|
var HEAD = this.HEAD.toJSON();
|
||||||
HEAD.visBranch = undefined;
|
HEAD.visBranch = undefined;
|
||||||
|
HEAD.lastTarget = HEAD.lastLastTarget = HEAD.visBranch = undefined;
|
||||||
HEAD.target = HEAD.target.get('id');
|
HEAD.target = HEAD.target.get('id');
|
||||||
totalExport.HEAD = HEAD;
|
totalExport.HEAD = HEAD;
|
||||||
|
|
||||||
|
@ -90,6 +91,9 @@ GitEngine.prototype.printAndCopyTree = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.loadTree = function(tree) {
|
GitEngine.prototype.loadTree = function(tree) {
|
||||||
|
// deep copy in case we use it a bunch
|
||||||
|
tree = $.extend(true, {}, tree);
|
||||||
|
|
||||||
// first clear everything
|
// first clear everything
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
|
|
||||||
|
@ -105,8 +109,10 @@ GitEngine.prototype.loadTreeFromString = function(treeString) {
|
||||||
GitEngine.prototype.instantiateFromTree = function(tree) {
|
GitEngine.prototype.instantiateFromTree = function(tree) {
|
||||||
// now we do the loading part
|
// now we do the loading part
|
||||||
var createdSoFar = {};
|
var createdSoFar = {};
|
||||||
|
debugger
|
||||||
_.each(tree.commits, function(commitJSON) {
|
_.each(tree.commits, function(commitJSON) {
|
||||||
var commit = this.getOrMakeRecursive(tree, createdSoFar, commitJSON.id);
|
var commit = this.getOrMakeRecursive(tree, createdSoFar, commitJSON.id);
|
||||||
|
console.log(commit);
|
||||||
this.commitCollection.add(commit);
|
this.commitCollection.add(commit);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
@ -151,6 +157,7 @@ GitEngine.prototype.reloadGraphics = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
|
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
|
||||||
|
console.log('get or make recursive', objID, tree, createdSoFar);
|
||||||
if (createdSoFar[objID]) {
|
if (createdSoFar[objID]) {
|
||||||
// base case
|
// base case
|
||||||
return createdSoFar[objID];
|
return createdSoFar[objID];
|
||||||
|
@ -1613,7 +1620,6 @@ var Commit = Backbone.Model.extend({
|
||||||
|
|
||||||
_.each(this.get('parents'), function(parent) {
|
_.each(this.get('parents'), function(parent) {
|
||||||
parent.get('children').push(this);
|
parent.get('children').push(this);
|
||||||
console.log('adding myself', this.get('id'), 'to parent', parent);
|
|
||||||
this.addEdgeToVisuals(parent);
|
this.addEdgeToVisuals(parent);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue