got tags making commits not faded out or orphaned anymore

This commit is contained in:
Peter Cottle 2013-11-01 10:01:13 -07:00
parent e9e2cda241
commit 9fbe654cb2
3 changed files with 37 additions and 22 deletions

View file

@ -1747,6 +1747,14 @@ GitEngine.prototype.pruneTree = function() {
}; };
GitEngine.prototype.getUpstreamBranchSet = function() { GitEngine.prototype.getUpstreamBranchSet = function() {
return this.getUpstreamCollectionSet(this.branchCollection);
};
GitEngine.prototype.getUpstreamTagSet = function() {
return this.getUpstreamCollectionSet(this.tagCollection);
};
GitEngine.prototype.getUpstreamCollectionSet = function(collection) {
// this is expensive!! so only call once in a while // this is expensive!! so only call once in a while
var commitToSet = {}; var commitToSet = {};
@ -1775,16 +1783,16 @@ GitEngine.prototype.getUpstreamBranchSet = function() {
return set; return set;
}; };
this.branchCollection.each(function(branch) { collection.each(function(ref) {
var set = bfsSearch(branch.get('target')); var set = bfsSearch(ref.get('target'));
_.each(set, function(id) { _.each(set, function(id) {
commitToSet[id] = commitToSet[id] || []; commitToSet[id] = commitToSet[id] || [];
// only add it if it's not there, so hue blending is ok // only add it if it's not there, so hue blending is ok
if (!inArray(commitToSet[id], branch.get('id'))) { if (!inArray(commitToSet[id], ref.get('id'))) {
commitToSet[id].push({ commitToSet[id].push({
obj: branch, obj: ref,
id: branch.get('id') id: ref.get('id')
}); });
} }
}); });

View file

@ -36,6 +36,7 @@ function GitVisuals(options) {
this.branchStackMap = null; this.branchStackMap = null;
this.tagStackMap = null; this.tagStackMap = null;
this.upstreamBranchSet = null; this.upstreamBranchSet = null;
this.upstreamTagSet = null;
this.upstreamHeadSet = null; this.upstreamHeadSet = null;
this.paper = options.paper; this.paper = options.paper;
@ -451,6 +452,7 @@ GitVisuals.prototype.calcGraphicsCoords = function() {
GitVisuals.prototype.calcUpstreamSets = function() { GitVisuals.prototype.calcUpstreamSets = function() {
this.upstreamBranchSet = this.gitEngine.getUpstreamBranchSet(); this.upstreamBranchSet = this.gitEngine.getUpstreamBranchSet();
this.upstreamHeadSet = this.gitEngine.getUpstreamHeadSet(); this.upstreamHeadSet = this.gitEngine.getUpstreamHeadSet();
this.upstreamTagSet = this.gitEngine.getUpstreamTagSet();
}; };
GitVisuals.prototype.getCommitUpstreamBranches = function(commit) { GitVisuals.prototype.getCommitUpstreamBranches = function(commit) {
@ -492,9 +494,12 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
var id = commit.get('id'); var id = commit.get('id');
var branch = this.upstreamBranchSet; var branch = this.upstreamBranchSet;
var head = this.upstreamHeadSet; var head = this.upstreamHeadSet;
var tag = this.upstreamTagSet;
if (branch[id]) { if (branch[id]) {
return 'branch'; return 'branch';
} else if (tag[id]) {
return 'tag';
} else if (head[id]) { } else if (head[id]) {
return 'head'; return 'head';
} else { } else {
@ -502,6 +507,23 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) {
} }
}; };
GitVisuals.prototype.calcTagStacks = function() {
var tags = this.gitEngine.getTags();
var map = {};
_.each(tags, function(tag) {
var thisId = tag.target.get('id');
map[thisId] = map[thisId] || [];
map[thisId].push(tag);
map[thisId].sort(function(a, b) {
var aId = a.obj.get('id');
var bId = b.obj.get('id');
return aId.localeCompare(bId);
});
});
this.tagStackMap = map;
};
GitVisuals.prototype.calcBranchStacks = function() { GitVisuals.prototype.calcBranchStacks = function() {
var branches = this.gitEngine.getBranches(); var branches = this.gitEngine.getBranches();
var map = {}; var map = {};
@ -522,23 +544,6 @@ GitVisuals.prototype.calcBranchStacks = function() {
this.branchStackMap = map; this.branchStackMap = map;
}; };
GitVisuals.prototype.calcTagStacks = function() {
var tags = this.gitEngine.getTags();
var map = {};
_.each(tags, function(tag) {
var thisId = tag.target.get('id');
map[thisId] = map[thisId] || [];
map[thisId].push(tag);
map[thisId].sort(function(a, b) {
var aId = a.obj.get('id');
var bId = b.obj.get('id');
return aId.localeCompare(bId);
});
});
this.tagStackMap = map;
};
GitVisuals.prototype.calcWidth = function() { GitVisuals.prototype.calcWidth = function() {
this.maxWidthRecursive(this.rootCommit); this.maxWidthRecursive(this.rootCommit);

View file

@ -318,6 +318,8 @@ var VisNode = VisBase.extend({
var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit')); var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit'));
if (stat == 'head') { if (stat == 'head') {
return GRAPHICS.headRectFill; return GRAPHICS.headRectFill;
} else if (stat == 'tag') {
return GRAPHICS.orphanNodeFill;
} else if (stat == 'none') { } else if (stat == 'none') {
return GRAPHICS.orphanNodeFill; return GRAPHICS.orphanNodeFill;
} }