have revert and cherry pick

This commit is contained in:
Peter Cottle 2013-06-04 15:13:33 -10:00
parent f400ac238e
commit 246753caad
3 changed files with 147 additions and 90 deletions

View file

@ -7652,23 +7652,18 @@ GitEngine.prototype.revertStarter = function() {
GitEngine.prototype.revert = function(whichCommits) { GitEngine.prototype.revert = function(whichCommits) {
// resolve the commits we will rebase // resolve the commits we will rebase
var toRebase = _.map(whichCommits, function(stringRef) { var toRevert = _.map(whichCommits, function(stringRef) {
return this.getCommitFromRef(stringRef); return this.getCommitFromRef(stringRef);
}, this); }, this);
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
// go highlight all the ones we will rebase first, in order chain = this.animationFactory.highlightEachWithPromise(
var destBranch = this.resolveID(toRebase[0]); chain,
_.each(toRebase, function(commit) { toRevert,
chain = chain.then(_.bind(function() { destBranch
return this.animationFactory.playHighlightPromiseAnimation( );
commit,
destBranch
);
}, this));
}, this);
var base = this.getCommitFromRef('HEAD'); var base = this.getCommitFromRef('HEAD');
// each step makes a new commit // each step makes a new commit
@ -7690,7 +7685,7 @@ GitEngine.prototype.revert = function(whichCommits) {
}, this); }, this);
// set up the promise chain // set up the promise chain
_.each(toRebase, function(commit) { _.each(toRevert, function(commit) {
chain = chain.then(function() { chain = chain.then(function() {
return chainStep(commit); return chainStep(commit);
}); });
@ -7739,7 +7734,7 @@ GitEngine.prototype.cherrypickStarter = function() {
var set = this.getUpstreamSet('HEAD'); var set = this.getUpstreamSet('HEAD');
// first resolve all the refs (as an error check) // first resolve all the refs (as an error check)
_.each(this.generalArgs, function(arg) { var toCherrypick = _.map(this.generalArgs, function(arg) {
var commit = this.getCommitFromRef(arg); var commit = this.getCommitFromRef(arg);
// and check that its not upstream // and check that its not upstream
if (set[commit.get('id')]) { if (set[commit.get('id')]) {
@ -7750,23 +7745,29 @@ GitEngine.prototype.cherrypickStarter = function() {
) )
}); });
} }
return commit;
}, this); }, this);
// error checks are all good, lets go!
var destinationBranch = this.resolveID('HEAD'); // error checks are all good, lets go!
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
var destinationBranch = this.resolveID('HEAD');
var chainStep = _.bind(function(arg) { chain = this.animationFactory.highlightEachWithPromise(
var oldCommit = this.getCommitFromRef(arg); chain,
var newCommit = this.cherrypick(arg); toCherrypick,
destinationBranch
);
var chainStep = _.bind(function(commit) {
var newCommit = this.cherrypick(commit);
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }, this);
_.each(this.generalArgs, function(arg) { _.each(toCherrypick, function(arg) {
chain = chain.then(function() { chain = chain.then(function() {
return chainStep(arg); return chainStep(arg);
}); });
@ -7893,13 +7894,11 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
for (var i = 0; i < numToMake; i++) { _.each(_.range(numToMake), function(i) {
// here is the deal -- we dont want to make the origin receive chain = chian.then(function() {
// teamwork all at once because then the animation of each child return chainStep();
// is difficult. Instead, we will generate a promise chain which will });
// produce the commit right before every animation });
chain = chain.then(chainStepWrap);
}
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -7910,9 +7909,7 @@ GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
return newCommit; return newCommit;
}; };
GitEngine.prototype.cherrypick = function(ref) { GitEngine.prototype.cherrypick = function(commit) {
var commit = this.getCommitFromRef(ref);
// alter the ID slightly // alter the ID slightly
var id = this.rebaseAltID(commit.get('id')); var id = this.rebaseAltID(commit.get('id'));
@ -8477,6 +8474,12 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
}); });
} }
chain = this.animationFactory.highlightEachWithPromise(
chain,
toRebase,
destinationBranch
);
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
// each step makes a new commit // each step makes a new commit
@ -9175,7 +9178,7 @@ var makeHighlightAnimation = function(visNode, visBranch) {
animation: function() { animation: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut'); visNode.highlightTo(visBranch, slowTime, 'easeInOut');
}, },
duration: fullTime * 1.5 duration: slowTime * 1.5
}; };
}; };
@ -9198,6 +9201,22 @@ AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, git
return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode)); return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode));
}; };
AnimationFactory.prototype.highlightEachWithPromise = function(
chain,
toHighlight,
destObj
) {
_.each(toHighlight, function(commit) {
chain = chain.then(_.bind(function() {
return this.playHighlightPromiseAnimation(
commit,
destObj
);
}, this));
}, this);
return chain;
};
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals); var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals);
animation.play(); animation.play();
@ -23589,23 +23608,18 @@ GitEngine.prototype.revertStarter = function() {
GitEngine.prototype.revert = function(whichCommits) { GitEngine.prototype.revert = function(whichCommits) {
// resolve the commits we will rebase // resolve the commits we will rebase
var toRebase = _.map(whichCommits, function(stringRef) { var toRevert = _.map(whichCommits, function(stringRef) {
return this.getCommitFromRef(stringRef); return this.getCommitFromRef(stringRef);
}, this); }, this);
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
// go highlight all the ones we will rebase first, in order chain = this.animationFactory.highlightEachWithPromise(
var destBranch = this.resolveID(toRebase[0]); chain,
_.each(toRebase, function(commit) { toRevert,
chain = chain.then(_.bind(function() { destBranch
return this.animationFactory.playHighlightPromiseAnimation( );
commit,
destBranch
);
}, this));
}, this);
var base = this.getCommitFromRef('HEAD'); var base = this.getCommitFromRef('HEAD');
// each step makes a new commit // each step makes a new commit
@ -23627,7 +23641,7 @@ GitEngine.prototype.revert = function(whichCommits) {
}, this); }, this);
// set up the promise chain // set up the promise chain
_.each(toRebase, function(commit) { _.each(toRevert, function(commit) {
chain = chain.then(function() { chain = chain.then(function() {
return chainStep(commit); return chainStep(commit);
}); });
@ -23676,7 +23690,7 @@ GitEngine.prototype.cherrypickStarter = function() {
var set = this.getUpstreamSet('HEAD'); var set = this.getUpstreamSet('HEAD');
// first resolve all the refs (as an error check) // first resolve all the refs (as an error check)
_.each(this.generalArgs, function(arg) { var toCherrypick = _.map(this.generalArgs, function(arg) {
var commit = this.getCommitFromRef(arg); var commit = this.getCommitFromRef(arg);
// and check that its not upstream // and check that its not upstream
if (set[commit.get('id')]) { if (set[commit.get('id')]) {
@ -23687,23 +23701,29 @@ GitEngine.prototype.cherrypickStarter = function() {
) )
}); });
} }
return commit;
}, this); }, this);
// error checks are all good, lets go!
var destinationBranch = this.resolveID('HEAD'); // error checks are all good, lets go!
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
var destinationBranch = this.resolveID('HEAD');
var chainStep = _.bind(function(arg) { chain = this.animationFactory.highlightEachWithPromise(
var oldCommit = this.getCommitFromRef(arg); chain,
var newCommit = this.cherrypick(arg); toCherrypick,
destinationBranch
);
var chainStep = _.bind(function(commit) {
var newCommit = this.cherrypick(commit);
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }, this);
_.each(this.generalArgs, function(arg) { _.each(toCherrypick, function(arg) {
chain = chain.then(function() { chain = chain.then(function() {
return chainStep(arg); return chainStep(arg);
}); });
@ -23830,13 +23850,11 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
for (var i = 0; i < numToMake; i++) { _.each(_.range(numToMake), function(i) {
// here is the deal -- we dont want to make the origin receive chain = chian.then(function() {
// teamwork all at once because then the animation of each child return chainStep();
// is difficult. Instead, we will generate a promise chain which will });
// produce the commit right before every animation });
chain = chain.then(chainStepWrap);
}
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -23847,9 +23865,7 @@ GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
return newCommit; return newCommit;
}; };
GitEngine.prototype.cherrypick = function(ref) { GitEngine.prototype.cherrypick = function(commit) {
var commit = this.getCommitFromRef(ref);
// alter the ID slightly // alter the ID slightly
var id = this.rebaseAltID(commit.get('id')); var id = this.rebaseAltID(commit.get('id'));
@ -24414,6 +24430,12 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
}); });
} }
chain = this.animationFactory.highlightEachWithPromise(
chain,
toRebase,
destinationBranch
);
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
// each step makes a new commit // each step makes a new commit
@ -31315,7 +31337,7 @@ var makeHighlightAnimation = function(visNode, visBranch) {
animation: function() { animation: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut'); visNode.highlightTo(visBranch, slowTime, 'easeInOut');
}, },
duration: fullTime * 1.5 duration: slowTime * 1.5
}; };
}; };
@ -31338,6 +31360,22 @@ AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, git
return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode)); return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode));
}; };
AnimationFactory.prototype.highlightEachWithPromise = function(
chain,
toHighlight,
destObj
) {
_.each(toHighlight, function(commit) {
chain = chain.then(_.bind(function() {
return this.playHighlightPromiseAnimation(
commit,
destObj
);
}, this));
}, this);
return chain;
};
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals); var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals);
animation.play(); animation.play();

View file

@ -599,23 +599,18 @@ GitEngine.prototype.revertStarter = function() {
GitEngine.prototype.revert = function(whichCommits) { GitEngine.prototype.revert = function(whichCommits) {
// resolve the commits we will rebase // resolve the commits we will rebase
var toRebase = _.map(whichCommits, function(stringRef) { var toRevert = _.map(whichCommits, function(stringRef) {
return this.getCommitFromRef(stringRef); return this.getCommitFromRef(stringRef);
}, this); }, this);
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
// go highlight all the ones we will rebase first, in order chain = this.animationFactory.highlightEachWithPromise(
var destBranch = this.resolveID(toRebase[0]); chain,
_.each(toRebase, function(commit) { toRevert,
chain = chain.then(_.bind(function() { destBranch
return this.animationFactory.playHighlightPromiseAnimation( );
commit,
destBranch
);
}, this));
}, this);
var base = this.getCommitFromRef('HEAD'); var base = this.getCommitFromRef('HEAD');
// each step makes a new commit // each step makes a new commit
@ -637,7 +632,7 @@ GitEngine.prototype.revert = function(whichCommits) {
}, this); }, this);
// set up the promise chain // set up the promise chain
_.each(toRebase, function(commit) { _.each(toRevert, function(commit) {
chain = chain.then(function() { chain = chain.then(function() {
return chainStep(commit); return chainStep(commit);
}); });
@ -686,7 +681,7 @@ GitEngine.prototype.cherrypickStarter = function() {
var set = this.getUpstreamSet('HEAD'); var set = this.getUpstreamSet('HEAD');
// first resolve all the refs (as an error check) // first resolve all the refs (as an error check)
_.each(this.generalArgs, function(arg) { var toCherrypick = _.map(this.generalArgs, function(arg) {
var commit = this.getCommitFromRef(arg); var commit = this.getCommitFromRef(arg);
// and check that its not upstream // and check that its not upstream
if (set[commit.get('id')]) { if (set[commit.get('id')]) {
@ -697,23 +692,29 @@ GitEngine.prototype.cherrypickStarter = function() {
) )
}); });
} }
return commit;
}, this); }, this);
// error checks are all good, lets go!
var destinationBranch = this.resolveID('HEAD'); // error checks are all good, lets go!
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
var destinationBranch = this.resolveID('HEAD');
var chainStep = _.bind(function(arg) { chain = this.animationFactory.highlightEachWithPromise(
var oldCommit = this.getCommitFromRef(arg); chain,
var newCommit = this.cherrypick(arg); toCherrypick,
destinationBranch
);
var chainStep = _.bind(function(commit) {
var newCommit = this.cherrypick(commit);
return this.animationFactory.playCommitBirthPromiseAnimation( return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit, newCommit,
this.gitVisuals this.gitVisuals
); );
}, this); }, this);
_.each(this.generalArgs, function(arg) { _.each(toCherrypick, function(arg) {
chain = chain.then(function() { chain = chain.then(function() {
return chainStep(arg); return chainStep(arg);
}); });
@ -840,13 +841,11 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
for (var i = 0; i < numToMake; i++) { _.each(_.range(numToMake), function(i) {
// here is the deal -- we dont want to make the origin receive chain = chian.then(function() {
// teamwork all at once because then the animation of each child return chainStep();
// is difficult. Instead, we will generate a promise chain which will });
// produce the commit right before every animation });
chain = chain.then(chainStepWrap);
}
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -857,9 +856,7 @@ GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
return newCommit; return newCommit;
}; };
GitEngine.prototype.cherrypick = function(ref) { GitEngine.prototype.cherrypick = function(commit) {
var commit = this.getCommitFromRef(ref);
// alter the ID slightly // alter the ID slightly
var id = this.rebaseAltID(commit.get('id')); var id = this.rebaseAltID(commit.get('id'));
@ -1424,6 +1421,12 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
}); });
} }
chain = this.animationFactory.highlightEachWithPromise(
chain,
toRebase,
destinationBranch
);
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
// each step makes a new commit // each step makes a new commit

View file

@ -49,7 +49,7 @@ var makeHighlightAnimation = function(visNode, visBranch) {
animation: function() { animation: function() {
visNode.highlightTo(visBranch, slowTime, 'easeInOut'); visNode.highlightTo(visBranch, slowTime, 'easeInOut');
}, },
duration: fullTime * 1.5 duration: slowTime * 1.5
}; };
}; };
@ -72,6 +72,22 @@ AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, git
return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode)); return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode));
}; };
AnimationFactory.prototype.highlightEachWithPromise = function(
chain,
toHighlight,
destObj
) {
_.each(toHighlight, function(commit) {
chain = chain.then(_.bind(function() {
return this.playHighlightPromiseAnimation(
commit,
destObj
);
}, this));
}, this);
return chain;
};
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals); var animation = this.genCommitBirthPromiseAnimation(commit, gitVisuals);
animation.play(); animation.play();