mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 07:28:35 +02:00
code move
This commit is contained in:
parent
6a09dcd12e
commit
5a66b762ce
4 changed files with 22 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
||||||
var TreeCompare = require('../src/js/graph/treeCompare');
|
|
||||||
var HeadlessGit = require('../src/js/git/headless').HeadlessGit;
|
var HeadlessGit = require('../src/js/git/headless').HeadlessGit;
|
||||||
|
var TreeCompare = require('../src/js/graph/treeCompare.js');
|
||||||
|
|
||||||
var loadTree = function(json) {
|
var loadTree = function(json) {
|
||||||
return JSON.parse(unescape(json));
|
return JSON.parse(unescape(json));
|
||||||
|
|
|
@ -7,7 +7,7 @@ var intl = require('../intl');
|
||||||
|
|
||||||
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
|
||||||
var AnimationQueue = require('../visuals/animation').AnimationQueue;
|
var AnimationQueue = require('../visuals/animation').AnimationQueue;
|
||||||
var TreeCompare = require('./treeCompare').TreeCompare;
|
var TreeCompare = require('../graph/treeCompare');
|
||||||
|
|
||||||
var Graph = require('../graph');
|
var Graph = require('../graph');
|
||||||
var Errors = require('../util/errors');
|
var Errors = require('../util/errors');
|
||||||
|
@ -141,15 +141,10 @@ GitEngine.prototype.assignLocalRepo = function(repo) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.defaultInit = function() {
|
GitEngine.prototype.defaultInit = function() {
|
||||||
var defaultTree = this.getDefaultTree();
|
var defaultTree = Graph.getDefaultTree();
|
||||||
this.loadTree(defaultTree);
|
this.loadTree(defaultTree);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.getDefaultTree = function() {
|
|
||||||
// lol 80 char limit
|
|
||||||
return 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"));
|
|
||||||
};
|
|
||||||
|
|
||||||
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});
|
||||||
|
@ -987,23 +982,10 @@ GitEngine.prototype.getTargetGraphDifference = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter because we werent doing graph search
|
// filter because we werent doing graph search
|
||||||
var differenceUnique = this.getUniqueObjects(difference);
|
var differenceUnique = Graph.getUniqueObjects(difference);
|
||||||
return this.descendSortDepth(differenceUnique);
|
return this.descendSortDepth(differenceUnique);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.getUniqueObjects = function(objects) {
|
|
||||||
var unique = {};
|
|
||||||
var result = [];
|
|
||||||
_.forEach(objects, function(object) {
|
|
||||||
if (unique[object.id]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
unique[object.id] = true;
|
|
||||||
result.push(object);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
GitEngine.prototype.descendSortDepth = function(objects) {
|
GitEngine.prototype.descendSortDepth = function(objects) {
|
||||||
return objects.sort(function(oA, oB) {
|
return objects.sort(function(oA, oB) {
|
||||||
return oB.depth - oA.depth;
|
return oB.depth - oA.depth;
|
||||||
|
@ -1224,7 +1206,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
|
||||||
// and sort. in this particular app we can never have unfected remote
|
// and sort. in this particular app we can never have unfected remote
|
||||||
// commits that are upstream of multiple branches (since the fakeTeamwork
|
// commits that are upstream of multiple branches (since the fakeTeamwork
|
||||||
// command simply commits), but we are doing it anyways for correctness
|
// command simply commits), but we are doing it anyways for correctness
|
||||||
commitsToMake = this.getUniqueObjects(commitsToMake);
|
commitsToMake = Graph.getUniqueObjects(commitsToMake);
|
||||||
commitsToMake = this.descendSortDepth(commitsToMake);
|
commitsToMake = this.descendSortDepth(commitsToMake);
|
||||||
|
|
||||||
// now here is the tricky part -- the difference between local master
|
// now here is the tricky part -- the difference between local master
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
|
var _ = require('underscore');
|
||||||
|
|
||||||
var Graph = {
|
var Graph = {
|
||||||
|
getUniqueObjects: function(objects) {
|
||||||
|
var unique = {};
|
||||||
|
var result = [];
|
||||||
|
_.forEach(objects, function(object) {
|
||||||
|
if (unique[object.id]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unique[object.id] = true;
|
||||||
|
result.push(object);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultTree: function() {
|
||||||
|
return 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"));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Graph;
|
module.exports = Graph;
|
||||||
|
|
|
@ -395,4 +395,3 @@ TreeCompare.compareTrees = function(treeA, treeB) {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = TreeCompare;
|
module.exports = TreeCompare;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue