got rid of every underscore bind i think -- 1500 line diff

This commit is contained in:
Peter Cottle 2015-04-20 16:41:56 +10:00
parent 3833319476
commit 2257668f9d
21 changed files with 229 additions and 230 deletions

View file

@ -50,7 +50,7 @@ function GitEngine(options) {
}
GitEngine.prototype.initUniqueID = function() {
// backbone or something uses _.uniqueId, so we make our own here
// backbone or something uses _ .uniqueId, so we make our own here
this.uniqueId = (function() {
var n = 0;
return function(prepend) {
@ -102,18 +102,18 @@ GitEngine.prototype.setMode = function(vcs) {
// branching ahead...
var neededUpdate = this.updateAllBranchesForHg();
if (neededUpdate) {
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.animationFactory.playRefreshAnimationSlow(this.gitVisuals);
}, this));
}.bind(this));
// ok we need to refresh anyways, so do the prune after
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
var neededPrune = this.pruneTree();
if (!neededPrune) {
return;
}
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}.bind(this));
return chain;
}
@ -795,7 +795,7 @@ GitEngine.prototype.printRemotes = function(options) {
GitEngine.prototype.getUniqueID = function() {
var id = this.uniqueId('C');
var hasID = _.bind(function(idToCheck) {
var hasID = function(idToCheck) {
// loop through and see if we have it locally or
// remotely
if (this.refs[idToCheck]) {
@ -805,7 +805,7 @@ GitEngine.prototype.getUniqueID = function() {
return true;
}
return false;
}, this);
}.bind(this);
while (hasID(id)) {
id = this.uniqueId('C');
@ -852,7 +852,7 @@ GitEngine.prototype.revert = function(whichCommits) {
var base = this.getCommitFromRef('HEAD');
// each step makes a new commit
var chainStep = _.bind(function(oldCommit) {
var chainStep = function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id'));
var commitMessage = intl.str('git-revert-msg', {
oldCommit: this.resolveName(oldCommit),
@ -867,7 +867,7 @@ GitEngine.prototype.revert = function(whichCommits) {
newCommit,
this.gitVisuals
);
}, this);
}.bind(this);
// set up the promise chain
_.each(toRevert, function(commit) {
@ -877,10 +877,10 @@ GitEngine.prototype.revert = function(whichCommits) {
}, this);
// done! update our location
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
this.setTargetLocation('HEAD', base);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}.bind(this));
this.animationQueue.thenFinish(chain, deferred);
};
@ -901,13 +901,13 @@ GitEngine.prototype.setupCherrypickChain = function(toCherrypick) {
destinationBranch
);
var chainStep = _.bind(function(commit) {
var chainStep = function(commit) {
var newCommit = this.cherrypick(commit);
return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.gitVisuals
);
}, this);
}.bind(this);
_.each(toCherrypick, function(arg) {
chain = chain.then(function() {
@ -1085,34 +1085,34 @@ GitEngine.prototype.push = function(options) {
return !this.origin.refs[commitJSON.id];
}, this);
var makeCommit = _.bind(function(id, parentIDs) {
var makeCommit = function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
return this.origin.refs[parentID];
}, this);
return this.origin.makeCommit(parents, id);
}, this);
}.bind(this);
// now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) {
var chainStep = function(id, parents) {
var newCommit = makeCommit(id, parents);
return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.origin.gitVisuals
);
}, this);
}.bind(this);
var deferred = Q.defer();
var chain = deferred.promise;
_.each(commitsToMake, function(commitJSON) {
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.animationFactory.playHighlightPromiseAnimation(
this.refs[commitJSON.id],
branchOnRemote
);
}, this));
}.bind(this));
chain = chain.then(function() {
return chainStep(
@ -1122,21 +1122,21 @@ GitEngine.prototype.push = function(options) {
});
}, this);
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
var localLocationID = this.getCommitFromRef(sourceLocation).get('id');
var remoteCommit = this.origin.refs[localLocationID];
this.origin.setTargetLocation(branchOnRemote, remoteCommit);
// unhighlight local
this.animationFactory.playRefreshAnimation(this.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
}.bind(this));
// HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
var localCommit = this.getCommitFromRef(sourceLocation);
this.setTargetLocation(this.refs[ORIGIN_PREFIX + options.destination], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}.bind(this));
if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred);
@ -1259,31 +1259,31 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
return !this.refs[commitJSON.id];
}, this);
var makeCommit = _.bind(function(id, parentIDs) {
var makeCommit = function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
return this.refs[parentID];
}, this);
return this.makeCommit(parents, id);
}, this);
}.bind(this);
// now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) {
var chainStep = function(id, parents) {
var newCommit = makeCommit(id, parents);
return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.gitVisuals
);
}, this);
}.bind(this);
var deferred = Q.defer();
var chain = deferred.promise;
if (options.didMakeBranch) {
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}.bind(this));
}
var originBranchSet = this.origin.getUpstreamBranchSet();
@ -1293,12 +1293,12 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
var originBranch = originBranchSet[commitJSON.id][0].obj;
var localBranch = this.refs[originBranch.getPrefixedID()];
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.animationFactory.playHighlightPromiseAnimation(
this.origin.refs[commitJSON.id],
localBranch
);
}, this));
}.bind(this));
chain = chain.then(function() {
return chainStep(
@ -1308,7 +1308,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
});
}, this);
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
// update all the destinations
_.each(sourceDestPairs, function(pair) {
var ours = this.refs[pair.destination];
@ -1322,7 +1322,7 @@ GitEngine.prototype.fetchCore = function(sourceDestPairs, options) {
// unhighlight origin by refreshing
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}.bind(this));
if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred);
@ -1366,31 +1366,31 @@ GitEngine.prototype.pullFinishWithRebase = function(
) {
var chain = pendingFetch.chain;
var deferred = pendingFetch.deferred;
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
if (this.isUpstreamOf(remoteBranch, localBranch)) {
this.command.set('error', new CommandResult({
msg: intl.str('git-result-uptodate')
}));
throw SHORT_CIRCUIT_CHAIN;
}
}, this));
}.bind(this));
// delay a bit after the intense refresh animation from
// fetch
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.animationFactory.getDelayedPromise(300);
}, this));
}.bind(this));
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
// highlight last commit on o/master to color of
// local branch
return this.animationFactory.playHighlightPromiseAnimation(
this.getCommitFromRef(remoteBranch),
localBranch
);
}, this));
}.bind(this));
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
pendingFetch.dontResolvePromise = true;
try {
@ -1410,7 +1410,7 @@ GitEngine.prototype.pullFinishWithRebase = function(
this.checkout(localBranch);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}
}, this));
}.bind(this));
chain = chain.fail(catchShortCircuit);
this.animationQueue.thenFinish(chain, deferred);
@ -1424,43 +1424,43 @@ GitEngine.prototype.pullFinishWithMerge = function(
var chain = pendingFetch.chain;
var deferred = pendingFetch.deferred;
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
if (this.mergeCheck(remoteBranch, localBranch)) {
this.command.set('error', new CommandResult({
msg: intl.str('git-result-uptodate')
}));
throw SHORT_CIRCUIT_CHAIN;
}
}, this));
}.bind(this));
// delay a bit after the intense refresh animation from
// fetch
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.animationFactory.getDelayedPromise(300);
}, this));
}.bind(this));
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
// highlight last commit on o/master to color of
// local branch
return this.animationFactory.playHighlightPromiseAnimation(
this.getCommitFromRef(remoteBranch),
localBranch
);
}, this));
}.bind(this));
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
// highlight commit on master to color of remote
return this.animationFactory.playHighlightPromiseAnimation(
this.getCommitFromRef(localBranch),
remoteBranch
);
}, this));
}.bind(this));
// delay and merge
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.animationFactory.getDelayedPromise(700);
}, this));
chain = chain.then(_.bind(function() {
}.bind(this));
chain = chain.then(function() {
var newCommit = this.merge(remoteBranch);
if (!newCommit) {
// it is a fast forward
@ -1471,25 +1471,25 @@ GitEngine.prototype.pullFinishWithMerge = function(
newCommit,
this.gitVisuals
);
}, this));
}.bind(this));
chain = chain.fail(catchShortCircuit);
this.animationQueue.thenFinish(chain, deferred);
};
GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
var makeOriginCommit = _.bind(function() {
var makeOriginCommit = function() {
var id = this.getUniqueID();
return this.origin.receiveTeamwork(id, branch, this.animationQueue);
}, this);
}.bind(this);
var chainStep = _.bind(function() {
var chainStep = function() {
var newCommit = makeOriginCommit();
return this.animationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.origin.gitVisuals
);
}, this);
}.bind(this);
var deferred = Q.defer();
var chain = deferred.promise;
@ -2033,7 +2033,7 @@ GitEngine.prototype.hgRebase = function(destination, base) {
return id;
});
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
// now we just moved a bunch of commits, but we havent updated the
// dangling guys. lets do that and then prune
var anyChange = this.updateCommitParentsForHgRebase(masterSet);
@ -2041,16 +2041,16 @@ GitEngine.prototype.hgRebase = function(destination, base) {
return;
}
return this.animationFactory.playRefreshAnimationSlow(this.gitVisuals);
}, this));
}.bind(this));
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
return this.updateAllBranchesForHgAndPlay(branchList);
}, this));
}.bind(this));
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
// now that we have moved branches, lets prune
return this.pruneTreeAndPlay();
}, this));
}.bind(this));
this.animationQueue.thenFinish(chain, deferred);
};
@ -2194,7 +2194,7 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
var deferred = Q.defer();
deferred.promise
.then(_.bind(function(userSpecifiedRebase) {
.then(function(userSpecifiedRebase) {
// first, they might have dropped everything (annoying)
if (!userSpecifiedRebase.length) {
throw new CommandResult({
@ -2204,12 +2204,12 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
// finish the rebase crap and animate!
this.rebaseFinish(userSpecifiedRebase, {}, targetSource, currentLocation);
}, this))
.fail(_.bind(function(err) {
}.bind(this))
.fail(function(err) {
this.filterError(err);
this.command.set('error', err);
this.animationQueue.start();
}, this))
}.bind(this))
.done();
// If we have a solution provided, set up the GUI to display it by default
@ -2316,7 +2316,7 @@ GitEngine.prototype.rebaseFinish = function(
var base = this.getCommitFromRef(targetSource);
var hasStartedChain = false;
// each step makes a new commit
var chainStep = _.bind(function(oldCommit) {
var chainStep = function(oldCommit) {
var newId = this.rebaseAltID(oldCommit.get('id'));
var parents;
if (!options.preserveMerges || !hasStartedChain) {
@ -2338,7 +2338,7 @@ GitEngine.prototype.rebaseFinish = function(
newCommit,
this.gitVisuals
);
}, this);
}.bind(this);
// set up the promise chain
_.each(toRebase, function(commit) {
@ -2347,7 +2347,7 @@ GitEngine.prototype.rebaseFinish = function(
});
}, this);
chain = chain.then(_.bind(function() {
chain = chain.then(function() {
if (this.resolveID(currentLocation).get('type') == 'commit') {
// we referenced a commit like git rebase C2 C1, so we have
// to manually check out C1'
@ -2358,7 +2358,7 @@ GitEngine.prototype.rebaseFinish = function(
this.checkout(currentLocation);
}
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}.bind(this));
if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred);
@ -2600,9 +2600,9 @@ GitEngine.prototype.externalRefresh = function() {
GitEngine.prototype.dispatch = function(command, deferred) {
this.command = command;
var vcs = command.get('vcs');
var executeCommand = _.bind(function() {
var executeCommand = function() {
this.dispatchProcess(command, deferred);
}, this);
}.bind(this);
// handle mode change will either execute sync or
// animate during tree pruning / etc
this.handleModeChange(vcs, executeCommand);
@ -2610,9 +2610,9 @@ GitEngine.prototype.dispatch = function(command, deferred) {
GitEngine.prototype.dispatchProcess = function(command, deferred) {
// set up the animation queue
var whenDone = _.bind(function() {
var whenDone = function() {
command.finishWith(deferred);
}, this);
}.bind(this);
this.animationQueue = new AnimationQueue({
callback: whenDone
});