WIP working on get target graph difference

This commit is contained in:
Peter Cottle 2013-06-08 22:40:46 -07:00
parent 6e75e04daf
commit 6cc0b182cc
7 changed files with 115 additions and 106 deletions

View file

@ -7774,16 +7774,35 @@ GitEngine.prototype.fetchStarter = function() {
this.fetch();
};
GitEngine.prototype.checkUpstreamOfSource = function(
target,
source,
targetBranch,
sourceBranch
) {
// here we are downloading some X number of commits from source onto
// target. Hence target should be strictly upstream of source
// lets first get the upstream set from source's dest branch
var upstream = source.getUpstreamSet(sourceBranch);
var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
if (!upstream[targetLocationID]) {
throw new GitError({
msg: 'no no'
});
}
};
GitEngine.prototype.fetch = function() {
// ok so we essentially are always in "-force" mode, since we always assume
// the origin commits are downstream of where we are. Here is the outline:
//
// first we get the commits we need by exporting the origin tree and
// walking upwards until we hit the upstream set defined by origin/master.
//
// then we simply set the target of o/master to the target of master on
// the origin branch
// TODO -- we cant abuse this anymore if we want to animate it :(
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
this.refs['o/master'],
this.origin.refs['master']
);
var oldCommits = this.exportTree().commits;
// HAX HAX omg we will abuse our tree instantiation here :D
var originTree = this.origin.exportTree();
@ -8607,7 +8626,7 @@ GitEngine.prototype.checkout = function(idOrTarget) {
var type = target.get('type');
// check if this is an origin branch, and if so go to the commit referenced
if (type === 'branch' && target.getIsRemote()) {
target = this.getCommitFromRef(target.get('id'));
//target = this.getCommitFromRef(target.get('id'));
}
if (type !== 'branch' && type !== 'commit') {
@ -9407,7 +9426,9 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
};
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
switch(true) {
var getAroundLintTrue = true;
// i actually prefer this to else if
switch (getAroundLintTrue) {
case !!levelBlob.compareOnlyMaster:
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
case !!levelBlob.compareOnlyBranches:
@ -16639,18 +16660,8 @@ var VisBranch = VisBase.extend({
}
},
shouldOffsetY: function() {
return this.gitEngine.getBranches().length > 1;
},
refreshOffset: function() {
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
if (!this.shouldOffsetY()) {
this.set('offsetY', 0);
this.set('offsetX', baseOffsetX);
return;
}
var offsetY = 33;
var deltaX = 10;
if (this.get('flip') === 1) {
@ -16663,9 +16674,7 @@ var VisBranch = VisBase.extend({
},
getArrowTransform: function() {
if (!this.shouldOffsetY()) {
return '';
} else if (this.get('flip') === 1) {
if (this.get('flip') === 1) {
return 't-2,-20R-35';
} else {
return 't2,20R-35';
@ -23620,16 +23629,35 @@ GitEngine.prototype.fetchStarter = function() {
this.fetch();
};
GitEngine.prototype.checkUpstreamOfSource = function(
target,
source,
targetBranch,
sourceBranch
) {
// here we are downloading some X number of commits from source onto
// target. Hence target should be strictly upstream of source
// lets first get the upstream set from source's dest branch
var upstream = source.getUpstreamSet(sourceBranch);
var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
if (!upstream[targetLocationID]) {
throw new GitError({
msg: 'no no'
});
}
};
GitEngine.prototype.fetch = function() {
// ok so we essentially are always in "-force" mode, since we always assume
// the origin commits are downstream of where we are. Here is the outline:
//
// first we get the commits we need by exporting the origin tree and
// walking upwards until we hit the upstream set defined by origin/master.
//
// then we simply set the target of o/master to the target of master on
// the origin branch
// TODO -- we cant abuse this anymore if we want to animate it :(
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
this.refs['o/master'],
this.origin.refs['master']
);
var oldCommits = this.exportTree().commits;
// HAX HAX omg we will abuse our tree instantiation here :D
var originTree = this.origin.exportTree();
@ -24453,7 +24481,7 @@ GitEngine.prototype.checkout = function(idOrTarget) {
var type = target.get('type');
// check if this is an origin branch, and if so go to the commit referenced
if (type === 'branch' && target.getIsRemote()) {
target = this.getCommitFromRef(target.get('id'));
//target = this.getCommitFromRef(target.get('id'));
}
if (type !== 'branch' && type !== 'commit') {
@ -24960,7 +24988,9 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
};
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
switch(true) {
var getAroundLintTrue = true;
// i actually prefer this to else if
switch (getAroundLintTrue) {
case !!levelBlob.compareOnlyMaster:
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
case !!levelBlob.compareOnlyBranches:
@ -32539,18 +32569,8 @@ var VisBranch = VisBase.extend({
}
},
shouldOffsetY: function() {
return this.gitEngine.getBranches().length > 1;
},
refreshOffset: function() {
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
if (!this.shouldOffsetY()) {
this.set('offsetY', 0);
this.set('offsetX', baseOffsetX);
return;
}
var offsetY = 33;
var deltaX = 10;
if (this.get('flip') === 1) {
@ -32563,9 +32583,7 @@ var VisBranch = VisBase.extend({
},
getArrowTransform: function() {
if (!this.shouldOffsetY()) {
return '';
} else if (this.get('flip') === 1) {
if (this.get('flip') === 1) {
return 't-2,-20R-35';
} else {
return 't2,20R-35';

File diff suppressed because one or more lines are too long

1
build/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -426,7 +426,7 @@
For a much easier time perusing the source, see the individual files at:
https://github.com/pcottle/learnGitBranching
-->
<script src="build/bundle.min.565ccc81.js"></script>
<script src="build/bundle.js"></script>
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
The downside? No raw logs to parse for analytics, so I have to include

View file

@ -740,51 +740,52 @@ GitEngine.prototype.fetchStarter = function() {
this.fetch();
};
GitEngine.prototype.checkUpstreamOfSource = function(
target,
source,
targetBranch,
sourceBranch
) {
// here we are downloading some X number of commits from source onto
// target. Hence target should be strictly upstream of source
// lets first get the upstream set from source's dest branch
var upstream = source.getUpstreamSet(sourceBranch);
var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
if (!upstream[targetLocationID]) {
throw new GitError({
msg: intl.str('git-error-origin-fetch-no-ff')
});
}
};
GitEngine.prototype.getTargetGraphDifference = function(
target,
targetBranch,
source,
sourceBranch
) = {
sourceBranch = source.resolveID(sourceBranch);
var targetSet = target.getUpstreamSet(targetBranch);
var sourceTree = source.exportTree();
var startCommit = sourceTree.commits[
};
GitEngine.prototype.fetch = function() {
// ok so we essentially are always in "-force" mode, since we always assume
// the origin commits are downstream of where we are. Here is the outline:
//
// first we get the commits we need by exporting the origin tree and
// walking upwards until we hit the upstream set defined by origin/master.
//
// then we simply set the target of o/master to the target of master on
// the origin branch
// TODO -- we cant abuse this anymore if we want to animate it :(
var oldCommits = this.exportTree().commits;
// HAX HAX omg we will abuse our tree instantiation here :D
var originTree = this.origin.exportTree();
_.each(originTree.commits, function(commit, id) {
// if we have it, no worries
if (this.refs[id]) {
return;
}
// go make it!
var downloadedCommit = this.getOrMakeRecursive(originTree, this.refs, id);
this.commitCollection.add(downloadedCommit);
}, this);
// since we now might have many commits more than before, lets
// check all the ones that didn't use to exist and make animations
var newCommits = this.exportTree().commits;
var commitsToAnimate = [];
_.each(newCommits, function(commit, id) {
if (oldCommits[id]) {
return;
}
commitsToAnimate.push(this.refs[id]);
}, this);
// now sort by id...
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
_.each(commitsToAnimate, function(newCommit) {
AnimationFactory.genCommitBirthAnimation(
this.animationQueue,
newCommit,
this.gitVisuals
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
this.refs['o/master'],
this.origin.refs['master']
);
}, this);
// then we get the difference in commits between these two graphs, ordered by
// depth
// this.commitCollection.add(downloadedCommit);
var originLocation = this.origin.exportTree().branches.master.target;
// yay! now we just set o/master and do a simple refresh
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);

View file

@ -52,6 +52,10 @@ exports.strings = {
'en_US': 'Quick commit. Go Bears!',
'zh_CN': '快速提交。上啊月熊!'
},
'git-error-origin-fetch-no-ff': {
'__desc__': 'One of the error messages for git',
'en_US': 'Your origin branch is out of sync with the remote branch and fetch cannot be performed. try using --force'
},
'git-error-remote-branch': {
'__desc__': 'One of the error messages for git',
'en_US': 'You cannot execute that command on a remote branch'

View file

@ -102,18 +102,8 @@ var VisBranch = VisBase.extend({
}
},
shouldOffsetY: function() {
return this.gitEngine.getBranches().length > 1;
},
refreshOffset: function() {
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
if (!this.shouldOffsetY()) {
this.set('offsetY', 0);
this.set('offsetX', baseOffsetX);
return;
}
var offsetY = 33;
var deltaX = 10;
if (this.get('flip') === 1) {
@ -126,9 +116,7 @@ var VisBranch = VisBase.extend({
},
getArrowTransform: function() {
if (!this.shouldOffsetY()) {
return '';
} else if (this.get('flip') === 1) {
if (this.get('flip') === 1) {
return 't-2,-20R-35';
} else {
return 't2,20R-35';