From ec1bab114fe7c697880cb64b8107e00d81647a72 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Tue, 4 Jun 2013 10:38:26 -1000 Subject: [PATCH] revert partway --- build/bundle.js | 98 ++++++++++++++------ src/js/git/index.js | 21 ++++- src/js/visuals/animation/animationFactory.js | 18 ++-- 3 files changed, 93 insertions(+), 44 deletions(-) diff --git a/build/bundle.js b/build/bundle.js index 12fd172e..20e039ad 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -7655,10 +7655,23 @@ GitEngine.prototype.revertStarter = function() { }; GitEngine.prototype.revert = function(whichCommits) { - // for each commit, we want to revert it - var toRebase = []; - _.each(whichCommits, function(stringRef) { - toRebase.push(this.getCommitFromRef(stringRef)); + // resolve the commits we will rebase + var toRebase = _.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(whichCommits, function(commit) { + chain = chain.then(_.bind(function() { + return this.animationFactory.playHighlightPromiseAnimation( + commit, + destBranch + ); + }, this)); }, this); // 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) { var visNode = commit.get('visNode'); - var anPack = makeCommitBirthAnimation(gitVisuals, visNode); - return new PromiseAnimation({ - closure: anPack.animation, - duration: anPack.duration - }); + return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode)); }; AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { @@ -9300,9 +9309,6 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp }; 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 var oldCommits = rebaseResponse.toRebaseArray; // we are either highlighting to a visBranch or a visNode @@ -9321,9 +9327,22 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase })); }, this); + var fullTime = GRAPHICS.defaultAnimationTime * 0.66; 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, gitEngine, gitVisuals) { var rebaseSteps = rebaseResponse.rebaseSteps; @@ -9552,10 +9571,10 @@ var PromiseAnimation = Backbone.Model.extend({ }, initialize: function(options) { - if (!options.closure) { - throw new Error('need closure'); + if (!options.closure && !options.animation) { + throw new Error('need closure or animation'); } - // TODO needed? + this.set('closure', options.closure || options.animation); this.set('deferred', options.deferred || Q.defer()); }, @@ -23591,10 +23610,23 @@ GitEngine.prototype.revertStarter = function() { }; GitEngine.prototype.revert = function(whichCommits) { - // for each commit, we want to revert it - var toRebase = []; - _.each(whichCommits, function(stringRef) { - toRebase.push(this.getCommitFromRef(stringRef)); + // resolve the commits we will rebase + var toRebase = _.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(whichCommits, function(commit) { + chain = chain.then(_.bind(function() { + return this.animationFactory.playHighlightPromiseAnimation( + commit, + destBranch + ); + }, this)); }, this); // 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) { var visNode = commit.get('visNode'); - var anPack = makeCommitBirthAnimation(gitVisuals, visNode); - return new PromiseAnimation({ - closure: anPack.animation, - duration: anPack.duration - }); + return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode)); }; AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { @@ -31439,9 +31467,6 @@ AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResp }; 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 var oldCommits = rebaseResponse.toRebaseArray; // we are either highlighting to a visBranch or a visNode @@ -31460,9 +31485,22 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase })); }, this); + var fullTime = GRAPHICS.defaultAnimationTime * 0.66; 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, gitEngine, gitVisuals) { var rebaseSteps = rebaseResponse.rebaseSteps; @@ -31692,10 +31730,10 @@ var PromiseAnimation = Backbone.Model.extend({ }, initialize: function(options) { - if (!options.closure) { - throw new Error('need closure'); + if (!options.closure && !options.animation) { + throw new Error('need closure or animation'); } - // TODO needed? + this.set('closure', options.closure || options.animation); this.set('deferred', options.deferred || Q.defer()); }, diff --git a/src/js/git/index.js b/src/js/git/index.js index 144b01a8..3ee2c742 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -602,10 +602,23 @@ GitEngine.prototype.revertStarter = function() { }; GitEngine.prototype.revert = function(whichCommits) { - // for each commit, we want to revert it - var toRebase = []; - _.each(whichCommits, function(stringRef) { - toRebase.push(this.getCommitFromRef(stringRef)); + // resolve the commits we will rebase + var toRebase = _.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(whichCommits, function(commit) { + chain = chain.then(_.bind(function() { + return this.animationFactory.playHighlightPromiseAnimation( + commit, + destBranch + ); + }, this)); }, this); // we animate reverts now!! we use the rebase animation though so that's diff --git a/src/js/visuals/animation/animationFactory.js b/src/js/visuals/animation/animationFactory.js index 2ee074b7..937e0ce0 100644 --- a/src/js/visuals/animation/animationFactory.js +++ b/src/js/visuals/animation/animationFactory.js @@ -69,11 +69,7 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co AnimationFactory.prototype.genCommitBirthPromiseAnimation = function(commit, gitVisuals) { var visNode = commit.get('visNode'); - var anPack = makeCommitBirthAnimation(gitVisuals, visNode); - return new PromiseAnimation({ - closure: anPack.animation, - duration: anPack.duration - }); + return new PromiseAnimation(makeCommitBirthAnimation(gitVisuals, visNode)); }; AnimationFactory.prototype.playCommitBirthPromiseAnimation = function(commit, gitVisuals) { @@ -173,18 +169,20 @@ AnimationFactory.prototype.rebaseHighlightPart = function(animationQueue, rebase })); }, this); + var fullTime = GRAPHICS.defaultAnimationTime * 0.66; 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)); +}; - var anPack = makeHighlightAnimation(visNode, visBranch); - return new PromiseAnimation({ - closure: anPack.animation, - duration: anPack.duration - }); +AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destBranch) { + var animation = this.genHighlightPromiseAnimation(commit, destBranch); + animation.play(); + return animation.getPromise(); }; AnimationFactory.prototype.rebaseBirthPart = function(animationQueue, rebaseResponse,