revert partway

This commit is contained in:
Peter Cottle 2013-06-04 10:38:26 -10:00
parent 880e1ca630
commit ec1bab114f
3 changed files with 93 additions and 44 deletions

View file

@ -7655,10 +7655,23 @@ GitEngine.prototype.revertStarter = function() {
}; };
GitEngine.prototype.revert = function(whichCommits) { GitEngine.prototype.revert = function(whichCommits) {
// for each commit, we want to revert it // resolve the commits we will rebase
var toRebase = []; var toRebase = _.map(whichCommits, function(stringRef) {
_.each(whichCommits, function(stringRef) { return this.getCommitFromRef(stringRef);
toRebase.push(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(whichCommits, function(commit) {
chain = chain.then(_.bind(function() {
return this.animationFactory.playHighlightPromiseAnimation(
commit,
destBranch
);
}, this));
}, this); }, this);
// we animate reverts now!! we use the rebase animation though so that's // we animate reverts now!! we use the rebase animation though so that's
@ -9214,11 +9227,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
var visNode = commit.get('visNode'); var visNode = commit.get('visNode');
var anPack = makeCommitBirthAnimation(gitVisuals, visNode); return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode));
return new PromiseAnimation({
closure: anPack.animation,
duration: anPack.duration
});
}; };
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
@ -9300,9 +9309,6 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp
}; };
AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebaseResponse, gitEngine) { AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebaseResponse, gitEngine) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
// we want to highlight all the old commits // we want to highlight all the old commits
var oldCommits = rebaseResponse.toRebaseArray; var oldCommits = rebaseResponse.toRebaseArray;
// we are either highlighting to a visBranch or a visNode // we are either highlighting to a visBranch or a visNode
@ -9321,9 +9327,22 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
})); }));
}, this); }, this);
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
this.delay(animationQueue, fullTime * 2); this.delay(animationQueue, fullTime * 2);
}; };
AnimationFactory.prototype.genHighlightPromiseAnmation = function(commit, destBranch) {
var visBranch = destBranch.get('visBranch');
var visNode = commit.get('visNode');
return new PromiseAnimation(makeHighlightAnimation(visNode, visBranch));
};
AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destBranch) {
var animation = this.genHighlightPromiseAnimation(commit, destBranch);
animation.play();
return animation.getPromise();
};
AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse, AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse,
gitEngine, gitVisuals) { gitEngine, gitVisuals) {
var rebaseSteps = rebaseResponse.rebaseSteps; var rebaseSteps = rebaseResponse.rebaseSteps;
@ -9552,10 +9571,10 @@ var PromiseAnimation = Backbone.Model.extend({
}, },
initialize: function(options) { initialize: function(options) {
if (!options.closure) { if (!options.closure && !options.animation) {
throw new Error('need closure'); throw new Error('need closure or animation');
} }
// TODO needed? this.set('closure', options.closure || options.animation);
this.set('deferred', options.deferred || Q.defer()); this.set('deferred', options.deferred || Q.defer());
}, },
@ -23591,10 +23610,23 @@ GitEngine.prototype.revertStarter = function() {
}; };
GitEngine.prototype.revert = function(whichCommits) { GitEngine.prototype.revert = function(whichCommits) {
// for each commit, we want to revert it // resolve the commits we will rebase
var toRebase = []; var toRebase = _.map(whichCommits, function(stringRef) {
_.each(whichCommits, function(stringRef) { return this.getCommitFromRef(stringRef);
toRebase.push(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(whichCommits, function(commit) {
chain = chain.then(_.bind(function() {
return this.animationFactory.playHighlightPromiseAnimation(
commit,
destBranch
);
}, this));
}, this); }, this);
// we animate reverts now!! we use the rebase animation though so that's // we animate reverts now!! we use the rebase animation though so that's
@ -31353,11 +31385,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
var visNode = commit.get('visNode'); var visNode = commit.get('visNode');
var anPack = makeCommitBirthAnimation(gitVisuals, visNode); return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode));
return new PromiseAnimation({
closure: anPack.animation,
duration: anPack.duration
});
}; };
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
@ -31439,9 +31467,6 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp
}; };
AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebaseResponse, gitEngine) { AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebaseResponse, gitEngine) {
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
var slowTime = fullTime * 2.0;
// we want to highlight all the old commits // we want to highlight all the old commits
var oldCommits = rebaseResponse.toRebaseArray; var oldCommits = rebaseResponse.toRebaseArray;
// we are either highlighting to a visBranch or a visNode // we are either highlighting to a visBranch or a visNode
@ -31460,9 +31485,22 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
})); }));
}, this); }, this);
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
this.delay(animationQueue, fullTime * 2); this.delay(animationQueue, fullTime * 2);
}; };
AnimationFactory.prototype.genHighlightPromiseAnmation = function(commit, destBranch) {
var visBranch = destBranch.get('visBranch');
var visNode = commit.get('visNode');
return new PromiseAnimation(makeHighlightAnimation(visNode, visBranch));
};
AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destBranch) {
var animation = this.genHighlightPromiseAnimation(commit, destBranch);
animation.play();
return animation.getPromise();
};
AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse, AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse,
gitEngine, gitVisuals) { gitEngine, gitVisuals) {
var rebaseSteps = rebaseResponse.rebaseSteps; var rebaseSteps = rebaseResponse.rebaseSteps;
@ -31692,10 +31730,10 @@ var PromiseAnimation = Backbone.Model.extend({
}, },
initialize: function(options) { initialize: function(options) {
if (!options.closure) { if (!options.closure && !options.animation) {
throw new Error('need closure'); throw new Error('need closure or animation');
} }
// TODO needed? this.set('closure', options.closure || options.animation);
this.set('deferred', options.deferred || Q.defer()); this.set('deferred', options.deferred || Q.defer());
}, },

View file

@ -602,10 +602,23 @@ GitEngine.prototype.revertStarter = function() {
}; };
GitEngine.prototype.revert = function(whichCommits) { GitEngine.prototype.revert = function(whichCommits) {
// for each commit, we want to revert it // resolve the commits we will rebase
var toRebase = []; var toRebase = _.map(whichCommits, function(stringRef) {
_.each(whichCommits, function(stringRef) { return this.getCommitFromRef(stringRef);
toRebase.push(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(whichCommits, function(commit) {
chain = chain.then(_.bind(function() {
return this.animationFactory.playHighlightPromiseAnimation(
commit,
destBranch
);
}, this));
}, this); }, this);
// we animate reverts now!! we use the rebase animation though so that's // we animate reverts now!! we use the rebase animation though so that's

View file

@ -69,11 +69,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) {
var visNode = commit.get('visNode'); var visNode = commit.get('visNode');
var anPack = makeCommitBirthAnimation(gitVisuals, visNode); return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode));
return new PromiseAnimation({
closure: anPack.animation,
duration: anPack.duration
});
}; };
AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) {
@ -173,18 +169,20 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase
})); }));
}, this); }, this);
var fullTime = GRAPHICS.defaultAnimationTime * 0.66;
this.delay(animationQueue, fullTime * 2); this.delay(animationQueue, fullTime * 2);
}; };
AnimationFactory.prototype.genHighlightPromiseAnmation = function(commit, destBranch) { AnimationFactory.prototype.genHighlightPromiseAnmation = function(commit, destBranch) {
var visBranch = destBranch.get('visBranch'); var visBranch = destBranch.get('visBranch');
var visNode = commit.get('visNode'); var visNode = commit.get('visNode');
return new PromiseAnimation(makeHighlightAnimation(visNode, visBranch));
};
var anPack = makeHighlightAnimation(visNode, visBranch); AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destBranch) {
return new PromiseAnimation({ var animation = this.genHighlightPromiseAnimation(commit, destBranch);
closure: anPack.animation, animation.play();
duration: anPack.duration return animation.getPromise();
});
}; };
AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse, AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse,