From 9fbe654cb2e52a7cf400c130802a224a75be71b7 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Fri, 1 Nov 2013 10:01:13 -0700 Subject: [PATCH] got tags making commits not faded out or orphaned anymore --- src/js/git/index.js | 18 +++++++++++++----- src/js/visuals/index.js | 39 ++++++++++++++++++++++----------------- src/js/visuals/visNode.js | 2 ++ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/js/git/index.js b/src/js/git/index.js index 3047c6af..e46d2016 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -1747,6 +1747,14 @@ GitEngine.prototype.pruneTree = 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 var commitToSet = {}; @@ -1775,16 +1783,16 @@ GitEngine.prototype.getUpstreamBranchSet = function() { return set; }; - this.branchCollection.each(function(branch) { - var set = bfsSearch(branch.get('target')); + collection.each(function(ref) { + var set = bfsSearch(ref.get('target')); _.each(set, function(id) { commitToSet[id] = commitToSet[id] || []; // 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({ - obj: branch, - id: branch.get('id') + obj: ref, + id: ref.get('id') }); } }); diff --git a/src/js/visuals/index.js b/src/js/visuals/index.js index 5ddb6cec..3d2ea47a 100644 --- a/src/js/visuals/index.js +++ b/src/js/visuals/index.js @@ -36,6 +36,7 @@ function GitVisuals(options) { this.branchStackMap = null; this.tagStackMap = null; this.upstreamBranchSet = null; + this.upstreamTagSet = null; this.upstreamHeadSet = null; this.paper = options.paper; @@ -451,6 +452,7 @@ GitVisuals.prototype.calcGraphicsCoords = function() { GitVisuals.prototype.calcUpstreamSets = function() { this.upstreamBranchSet = this.gitEngine.getUpstreamBranchSet(); this.upstreamHeadSet = this.gitEngine.getUpstreamHeadSet(); + this.upstreamTagSet = this.gitEngine.getUpstreamTagSet(); }; GitVisuals.prototype.getCommitUpstreamBranches = function(commit) { @@ -492,9 +494,12 @@ GitVisuals.prototype.getCommitUpstreamStatus = function(commit) { var id = commit.get('id'); var branch = this.upstreamBranchSet; var head = this.upstreamHeadSet; + var tag = this.upstreamTagSet; if (branch[id]) { return 'branch'; + } else if (tag[id]) { + return 'tag'; } else if (head[id]) { return 'head'; } 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() { var branches = this.gitEngine.getBranches(); var map = {}; @@ -522,23 +544,6 @@ GitVisuals.prototype.calcBranchStacks = function() { 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() { this.maxWidthRecursive(this.rootCommit); diff --git a/src/js/visuals/visNode.js b/src/js/visuals/visNode.js index 22ee35da..ca87f30a 100644 --- a/src/js/visuals/visNode.js +++ b/src/js/visuals/visNode.js @@ -318,6 +318,8 @@ var VisNode = VisBase.extend({ var stat = this.gitVisuals.getCommitUpstreamStatus(this.get('commit')); if (stat == 'head') { return GRAPHICS.headRectFill; + } else if (stat == 'tag') { + return GRAPHICS.orphanNodeFill; } else if (stat == 'none') { return GRAPHICS.orphanNodeFill; }