mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 16:38:50 +02:00
working towards better loading from tree on inint
This commit is contained in:
parent
c8c45c9a40
commit
044ab4b6b4
1 changed files with 6 additions and 7 deletions
13
src/git.js
13
src/git.js
|
@ -23,6 +23,11 @@ function GitEngine(options) {
|
||||||
events.on('processCommand', _.bind(this.dispatch, this));
|
events.on('processCommand', _.bind(this.dispatch, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GitEngine.prototype.defaultInit = function() {
|
||||||
|
var defaultTree = JSON.parse(unescape("%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C1%22%2C%22id%22%3A%22master%22%2C%22type%22%3A%22branch%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22type%22%3A%22commit%22%2C%22parents%22%3A%5B%5D%2C%22author%22%3A%22Peter%20Cottle%22%2C%22createTime%22%3A%22Mon%20Nov%2005%202012%2000%3A56%3A47%20GMT-0800%20%28PST%29%22%2C%22commitMessage%22%3A%22Quick%20Commit.%20Go%20Bears%21%22%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22type%22%3A%22commit%22%2C%22parents%22%3A%5B%22C0%22%5D%2C%22author%22%3A%22Peter%20Cottle%22%2C%22createTime%22%3A%22Mon%20Nov%2005%202012%2000%3A56%3A47%20GMT-0800%20%28PST%29%22%2C%22commitMessage%22%3A%22Quick%20Commit.%20Go%20Bears%21%22%2C%22id%22%3A%22C1%22%7D%7D%2C%22HEAD%22%3A%7B%22id%22%3A%22HEAD%22%2C%22target%22%3A%22master%22%2C%22type%22%3A%22general%20ref%22%7D%7D"));
|
||||||
|
this.loadTree(defaultTree);
|
||||||
|
};
|
||||||
|
|
||||||
GitEngine.prototype.init = function() {
|
GitEngine.prototype.init = function() {
|
||||||
// make an initial commit and a master branch
|
// make an initial commit and a master branch
|
||||||
this.rootCommit = this.makeCommit(null, null, {rootCommit: true});
|
this.rootCommit = this.makeCommit(null, null, {rootCommit: true});
|
||||||
|
@ -109,10 +114,9 @@ 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);
|
||||||
|
|
||||||
|
@ -157,7 +161,6 @@ 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];
|
||||||
|
@ -1517,10 +1520,6 @@ var Ref = Backbone.Model.extend({
|
||||||
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return 'a ' + this.get('type') + 'pointing to ' + String(this.get('target'));
|
return 'a ' + this.get('type') + 'pointing to ' + String(this.get('target'));
|
||||||
},
|
|
||||||
|
|
||||||
delete: function() {
|
|
||||||
console.log('DELETING ' + this.get('type') + ' ' + this.get('id'));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue