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

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