diff --git a/build/bundle.js b/build/bundle.js index 20e039ad..fca07320 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -7647,11 +7647,7 @@ GitEngine.prototype.twoArgsImpliedHead = function(args, option) { GitEngine.prototype.revertStarter = function() { this.validateArgBounds(this.generalArgs, 1, NaN); - var response = this.revert(this.generalArgs); - - if (response) { - this.animationFactory.rebaseAnimation(this.animationQueue, response, this, this.gitVisuals); - } + this.revert(this.generalArgs); }; GitEngine.prototype.revert = function(whichCommits) { @@ -7674,46 +7670,35 @@ GitEngine.prototype.revert = function(whichCommits) { }, this)); }, this); - // we animate reverts now!! we use the rebase animation though so that's - // why the terminology is like it is - var animationResponse = {}; - animationResponse.destinationBranch = this.resolveID(toRebase[0]); - animationResponse.toRebaseArray = toRebase.slice(0); - animationResponse.rebaseSteps = []; - - var beforeSnapshot = this.gitVisuals.genSnapshot(); - var afterSnapshot; - - // now make a bunch of commits on top of where we are var base = this.getCommitFromRef('HEAD'); - _.each(toRebase, function(oldCommit) { + // each step makes a new commit + var chainStep = _.bind(function(oldCommit) { var newId = this.rebaseAltID(oldCommit.get('id')); - var commitMessage = intl.str('git-revert-msg', { oldCommit: this.resolveName(oldCommit), oldMsg: oldCommit.get('commitMessage') }); - var newCommit = this.makeCommit([base], newId, { commitMessage: commitMessage }); - base = newCommit; - // animation stuff - afterSnapshot = this.gitVisuals.genSnapshot(); - animationResponse.rebaseSteps.push({ - oldCommit: oldCommit, - newCommit: newCommit, - beforeSnapshot: beforeSnapshot, - afterSnapshot: afterSnapshot - }); - beforeSnapshot = afterSnapshot; - }, this); - // done! update our location - this.setTargetLocation('HEAD', base); - // animation - return animationResponse; + return this.animationFactory.playCommitBirthPromiseAnimation( + newCommit, + this.gitVisuals + ); + }, this); + + // set up the promise chain + _.each(whichCommits, function(commit) { + chain = chain.then(function() { + chainStep(commit); + }); + }, this); + + // done! update our location + // this.setTargetLocation('HEAD', base); + this.animationQueue.thenFinish(chain); }; GitEngine.prototype.resetStarter = function() { @@ -23602,11 +23587,7 @@ GitEngine.prototype.twoArgsImpliedHead = function(args, option) { GitEngine.prototype.revertStarter = function() { this.validateArgBounds(this.generalArgs, 1, NaN); - var response = this.revert(this.generalArgs); - - if (response) { - this.animationFactory.rebaseAnimation(this.animationQueue, response, this, this.gitVisuals); - } + this.revert(this.generalArgs); }; GitEngine.prototype.revert = function(whichCommits) { @@ -23629,46 +23610,35 @@ GitEngine.prototype.revert = function(whichCommits) { }, this)); }, this); - // we animate reverts now!! we use the rebase animation though so that's - // why the terminology is like it is - var animationResponse = {}; - animationResponse.destinationBranch = this.resolveID(toRebase[0]); - animationResponse.toRebaseArray = toRebase.slice(0); - animationResponse.rebaseSteps = []; - - var beforeSnapshot = this.gitVisuals.genSnapshot(); - var afterSnapshot; - - // now make a bunch of commits on top of where we are var base = this.getCommitFromRef('HEAD'); - _.each(toRebase, function(oldCommit) { + // each step makes a new commit + var chainStep = _.bind(function(oldCommit) { var newId = this.rebaseAltID(oldCommit.get('id')); - var commitMessage = intl.str('git-revert-msg', { oldCommit: this.resolveName(oldCommit), oldMsg: oldCommit.get('commitMessage') }); - var newCommit = this.makeCommit([base], newId, { commitMessage: commitMessage }); - base = newCommit; - // animation stuff - afterSnapshot = this.gitVisuals.genSnapshot(); - animationResponse.rebaseSteps.push({ - oldCommit: oldCommit, - newCommit: newCommit, - beforeSnapshot: beforeSnapshot, - afterSnapshot: afterSnapshot - }); - beforeSnapshot = afterSnapshot; - }, this); - // done! update our location - this.setTargetLocation('HEAD', base); - // animation - return animationResponse; + return this.animationFactory.playCommitBirthPromiseAnimation( + newCommit, + this.gitVisuals + ); + }, this); + + // set up the promise chain + _.each(whichCommits, function(commit) { + chain = chain.then(function() { + chainStep(commit); + }); + }, this); + + // done! update our location + // this.setTargetLocation('HEAD', base); + this.animationQueue.thenFinish(chain); }; GitEngine.prototype.resetStarter = function() { diff --git a/src/js/git/index.js b/src/js/git/index.js index 3ee2c742..0d6d1372 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -594,11 +594,7 @@ GitEngine.prototype.twoArgsImpliedHead = function(args, option) { GitEngine.prototype.revertStarter = function() { this.validateArgBounds(this.generalArgs, 1, NaN); - var response = this.revert(this.generalArgs); - - if (response) { - this.animationFactory.rebaseAnimation(this.animationQueue, response, this, this.gitVisuals); - } + this.revert(this.generalArgs); }; GitEngine.prototype.revert = function(whichCommits) { @@ -621,46 +617,35 @@ GitEngine.prototype.revert = function(whichCommits) { }, this)); }, this); - // we animate reverts now!! we use the rebase animation though so that's - // why the terminology is like it is - var animationResponse = {}; - animationResponse.destinationBranch = this.resolveID(toRebase[0]); - animationResponse.toRebaseArray = toRebase.slice(0); - animationResponse.rebaseSteps = []; - - var beforeSnapshot = this.gitVisuals.genSnapshot(); - var afterSnapshot; - - // now make a bunch of commits on top of where we are var base = this.getCommitFromRef('HEAD'); - _.each(toRebase, function(oldCommit) { + // each step makes a new commit + var chainStep = _.bind(function(oldCommit) { var newId = this.rebaseAltID(oldCommit.get('id')); - var commitMessage = intl.str('git-revert-msg', { oldCommit: this.resolveName(oldCommit), oldMsg: oldCommit.get('commitMessage') }); - var newCommit = this.makeCommit([base], newId, { commitMessage: commitMessage }); - base = newCommit; - // animation stuff - afterSnapshot = this.gitVisuals.genSnapshot(); - animationResponse.rebaseSteps.push({ - oldCommit: oldCommit, - newCommit: newCommit, - beforeSnapshot: beforeSnapshot, - afterSnapshot: afterSnapshot - }); - beforeSnapshot = afterSnapshot; - }, this); - // done! update our location - this.setTargetLocation('HEAD', base); - // animation - return animationResponse; + return this.animationFactory.playCommitBirthPromiseAnimation( + newCommit, + this.gitVisuals + ); + }, this); + + // set up the promise chain + _.each(whichCommits, function(commit) { + chain = chain.then(function() { + chainStep(commit); + }); + }, this); + + // done! update our location + // this.setTargetLocation('HEAD', base); + this.animationQueue.thenFinish(chain, deferred); }; GitEngine.prototype.resetStarter = function() { @@ -866,9 +851,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) { return chainStep(); }); } - this.animationQueue.thenFinish(chain); - - deferred.resolve(); + this.animationQueue.thenFinish(chain, deferred); }; GitEngine.prototype.receiveTeamwork = function(id, animationQueue) { @@ -932,7 +915,7 @@ GitEngine.prototype.commitStarter = function() { newCommit, this.gitVisuals ); - this.animationQueue.thenFinish(promise); + this.animationQueue.thenFinish(promise, deferred); }; GitEngine.prototype.commit = function() { diff --git a/src/js/visuals/animation/index.js b/src/js/visuals/animation/index.js index 34f27f9c..a71d84e9 100644 --- a/src/js/visuals/animation/index.js +++ b/src/js/visuals/animation/index.js @@ -40,11 +40,14 @@ var AnimationQueue = Backbone.Model.extend({ } }, - thenFinish: function(promise) { + thenFinish: function(promise, deferred) { promise.then(_.bind(function() { this.finish(); }, this)); this.set('promiseBased', true); + if (deferred) { + deferred.resolve(); + } }, add: function(animation) {