tag loading from trees now works

This commit is contained in:
Peter Cottle 2013-10-29 09:57:46 -07:00
parent 5a66b762ce
commit 7bbc81de97
2 changed files with 22 additions and 10 deletions

View file

@ -211,7 +211,6 @@ GitEngine.prototype.exportTree = function() {
_.each(this.branchCollection.toJSON(), function(branch) { _.each(this.branchCollection.toJSON(), function(branch) {
branch.target = branch.target.get('id'); branch.target = branch.target.get('id');
branch.visBranch = undefined; branch.visBranch = undefined;
branch.visTag = undefined;
totalExport.branches[branch.id] = branch; totalExport.branches[branch.id] = branch;
}); });
@ -232,6 +231,13 @@ GitEngine.prototype.exportTree = function() {
totalExport.commits[commit.id] = commit; totalExport.commits[commit.id] = commit;
}, this); }, this);
_.each(this.tagCollection.toJSON(), function(tag) {
tag.visTag = undefined;
tag.target = tag.target.get('id');
totalExport.tags[tag.id] = tag;
}, this);
var HEAD = this.HEAD.toJSON(); var HEAD = this.HEAD.toJSON();
HEAD.lastTarget = HEAD.lastLastTarget = HEAD.visBranch = HEAD.visTag =undefined; HEAD.lastTarget = HEAD.lastLastTarget = HEAD.visBranch = HEAD.visTag =undefined;
HEAD.target = HEAD.target.get('id'); HEAD.target = HEAD.target.get('id');
@ -473,7 +479,11 @@ GitEngine.prototype.setLocalToTrackRemote = function(localBranch, remoteBranch)
this.command.addWarning(intl.todo(msg)); this.command.addWarning(intl.todo(msg));
}; };
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) { GitEngine.prototype.getOrMakeRecursive = function(
tree,
createdSoFar,
objID
) {
if (createdSoFar[objID]) { if (createdSoFar[objID]) {
// base case // base case
return createdSoFar[objID]; return createdSoFar[objID];
@ -486,6 +496,8 @@ GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
return 'branch'; return 'branch';
} else if (id == 'HEAD') { } else if (id == 'HEAD') {
return 'HEAD'; return 'HEAD';
} else if (tree.tags[id]) {
return 'tag';
} }
throw new Error("bad type for " + id); throw new Error("bad type for " + id);
}; };
@ -983,13 +995,7 @@ GitEngine.prototype.getTargetGraphDifference = function(
// filter because we werent doing graph search // filter because we werent doing graph search
var differenceUnique = Graph.getUniqueObjects(difference); var differenceUnique = Graph.getUniqueObjects(difference);
return this.descendSortDepth(differenceUnique); return Graph.descendSortDepth(differenceUnique);
};
GitEngine.prototype.descendSortDepth = function(objects) {
return objects.sort(function(oA, oB) {
return oB.depth - oA.depth;
});
}; };
GitEngine.prototype.push = function(options) { GitEngine.prototype.push = function(options) {
@ -1207,7 +1213,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
// 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 = Graph.getUniqueObjects(commitsToMake); commitsToMake = Graph.getUniqueObjects(commitsToMake);
commitsToMake = this.descendSortDepth(commitsToMake); commitsToMake = Graph.descendSortDepth(commitsToMake);
// now here is the tricky part -- the difference between local master // now here is the tricky part -- the difference between local master
// and remote master might be commits C2, C3, and C4, but we // and remote master might be commits C2, C3, and C4, but we

View file

@ -1,6 +1,12 @@
var _ = require('underscore'); var _ = require('underscore');
var Graph = { var Graph = {
descendSortDepth: function(objects) {
return objects.sort(function(oA, oB) {
return oB.depth - oA.depth;
});
},
getUniqueObjects: function(objects) { getUniqueObjects: function(objects) {
var unique = {}; var unique = {};
var result = []; var result = [];