rebase started

This commit is contained in:
Peter Cottle 2013-06-04 14:48:36 -10:00
parent 6931992316
commit 8eff13284f
4 changed files with 180 additions and 243 deletions

View file

@ -7895,6 +7895,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
this.origin.gitVisuals this.origin.gitVisuals
); );
}, this); }, this);
var chainStepWrap = function() { return chainStep(); };
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
@ -7904,9 +7905,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
// teamwork all at once because then the animation of each child // teamwork all at once because then the animation of each child
// is difficult. Instead, we will generate a promise chain which will // is difficult. Instead, we will generate a promise chain which will
// produce the commit right before every animation // produce the commit right before every animation
chain = chain.then(function() { chain = chain.then(chainStepWrap);
return chainStep();
});
} }
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -8441,96 +8440,85 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
}); });
}; };
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) { GitEngine.prototype.filterRebaseCommits = function(toRebaseRough, stopSet) {
// now we have the all the commits between currentLocation and the set of target to rebase. var changesAlreadyMade = {};
var animationResponse = {}; _.each(stopSet, function(val, key) {
animationResponse.destinationBranch = this.resolveID(targetSource); changesAlreadyMade[this.scrapeBaseID(key)] = true;
}, this);
var uniqueIDs = {};
// we need to throw out merge commits // resolve the commits we will rebase
var toRebase = []; return _.filter(toRebaseRough, function(commit) {
_.each(toRebaseRough, function(commit) { // no merge commits
if (commit.get('parents').length == 1) { if (commit.get('parents').length !== 1) {
toRebase.push(commit); return false;
} }
});
// we ALSO need to throw out commits that will do the same changes. like // we ALSO need to throw out commits that will do the same changes. like
// if the upstream set has a commit C4 and we have C4', we dont rebase the C4' again. // if the upstream set has a commit C4 and we have C4', we dont rebase the C4' again.
// get this by doing ID scraping
var changesAlreadyMade = {};
_.each(stopSet, function(val, key) {
changesAlreadyMade[this.scrapeBaseID(key)] = val; // val == true
}, this);
// now get rid of the commits that will redo same changes
toRebaseRough = toRebase;
toRebase = [];
_.each(toRebaseRough, function(commit) {
var baseID = this.scrapeBaseID(commit.get('id')); var baseID = this.scrapeBaseID(commit.get('id'));
if (!changesAlreadyMade[baseID]) { if (changesAlreadyMade[baseID]) {
toRebase.push(commit); return false;
} }
}, this);
toRebaseRough = toRebase; // make unique
toRebase = []; if (uniqueIDs[commit.get('id')]) {
// finally, make the set unique return false;
var uniqueIDs = {}; }
_.each(toRebaseRough, function(commit) {
if (uniqueIDs[commit.get('id')]) { return; }
uniqueIDs[commit.get('id')] = true; uniqueIDs[commit.get('id')] = true;
toRebase.push(commit); return true;
}, this); });
};
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) {
// now we have the all the commits between currentLocation and the set of target to rebase.
var destinationBranch = this.resolveID(targetSource);
var deferred = Q.defer();
var chain = deferred.promise;
var toRebase = this.filterRebaseCommits(toRebaseRough, stopSet);
if (!toRebase.length) { if (!toRebase.length) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-rebase-none') msg: intl.str('git-error-rebase-none')
}); });
} }
animationResponse.toRebaseArray = toRebase.slice(0);
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
// each step makes a new commit
// do the rebase, and also maintain all our animation info during this var chainStep = _.bind(function(oldCommit) {
animationResponse.rebaseSteps = []; var newId = this.rebaseAltID(oldCommit.get('id'));
var beforeSnapshot = this.gitVisuals.genSnapshot();
var afterSnapshot;
_.each(toRebase, function(old) {
var newId = this.rebaseAltID(old.get('id'));
var newCommit = this.makeCommit([base], newId); var newCommit = this.makeCommit([base], newId);
base = newCommit; base = newCommit;
// animation info return this.animationFactory.playCommitBirthPromiseAnimation(
afterSnapshot = this.gitVisuals.genSnapshot(); newCommit,
animationResponse.rebaseSteps.push({ this.gitVisuals
oldCommit: old, );
newCommit: newCommit,
beforeSnapshot: beforeSnapshot,
afterSnapshot: afterSnapshot
});
beforeSnapshot = afterSnapshot;
}, this); }, this);
// set up the promise chain
_.each(toRebase, function(commit) {
chain = chain.then(function() {
return chainStep(commit);
});
}, this);
chain = chain.then(_.bind(function() {
if (this.resolveID(currentLocation).get('type') == 'commit') { if (this.resolveID(currentLocation).get('type') == 'commit') {
// we referenced a commit like git rebase C2 C1, so we have // we referenced a commit like git rebase C2 C1, so we have
// to manually check out C1' // to manually check out C1'
this.checkout(base);
var steps = animationResponse.rebaseSteps;
var newestCommit = steps[steps.length - 1].newCommit;
this.checkout(newestCommit);
} else { } else {
// now we just need to update the rebased branch is // now we just need to update the rebased branch is
this.setTargetLocation(currentLocation, base); this.setTargetLocation(currentLocation, base);
this.checkout(currentLocation); this.checkout(currentLocation);
} }
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
// for animation this.animationQueue.thenFinish(chain, deferred);
return animationResponse;
}; };
GitEngine.prototype.mergeStarter = function() { GitEngine.prototype.mergeStarter = function() {
@ -9336,17 +9324,8 @@ AnimationFactory.prototype.genHighlightPromiseAnimation = function(commit, destO
}; };
AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destObj) { AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destObj) {
console.log('playing highlight animation');
try {
var animation = this.genHighlightPromiseAnimation(commit, destObj); var animation = this.genHighlightPromiseAnimation(commit, destObj);
console.log('aniamtion duration', animation.get('duration'));
animation.play(); animation.play();
console.log('aniamtion duration', animation.get('duration'));
animation.getPromise();
} catch (e) {
debugger;
console.log(e);
}
return animation.getPromise(); return animation.getPromise();
}; };
@ -9505,7 +9484,7 @@ var AnimationQueue = Backbone.Model.extend({
index: 0, index: 0,
callback: null, callback: null,
defer: false, defer: false,
promiseBased: false, promiseBased: false
}, },
initialize: function(options) { initialize: function(options) {
@ -23860,6 +23839,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
this.origin.gitVisuals this.origin.gitVisuals
); );
}, this); }, this);
var chainStepWrap = function() { return chainStep(); };
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
@ -23869,9 +23849,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
// teamwork all at once because then the animation of each child // teamwork all at once because then the animation of each child
// is difficult. Instead, we will generate a promise chain which will // is difficult. Instead, we will generate a promise chain which will
// produce the commit right before every animation // produce the commit right before every animation
chain = chain.then(function() { chain = chain.then(chainStepWrap);
return chainStep();
});
} }
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -24406,96 +24384,85 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
}); });
}; };
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) { GitEngine.prototype.filterRebaseCommits = function(toRebaseRough, stopSet) {
// now we have the all the commits between currentLocation and the set of target to rebase. var changesAlreadyMade = {};
var animationResponse = {}; _.each(stopSet, function(val, key) {
animationResponse.destinationBranch = this.resolveID(targetSource); changesAlreadyMade[this.scrapeBaseID(key)] = true;
}, this);
var uniqueIDs = {};
// we need to throw out merge commits // resolve the commits we will rebase
var toRebase = []; return _.filter(toRebaseRough, function(commit) {
_.each(toRebaseRough, function(commit) { // no merge commits
if (commit.get('parents').length == 1) { if (commit.get('parents').length !== 1) {
toRebase.push(commit); return false;
} }
});
// we ALSO need to throw out commits that will do the same changes. like // we ALSO need to throw out commits that will do the same changes. like
// if the upstream set has a commit C4 and we have C4', we dont rebase the C4' again. // if the upstream set has a commit C4 and we have C4', we dont rebase the C4' again.
// get this by doing ID scraping
var changesAlreadyMade = {};
_.each(stopSet, function(val, key) {
changesAlreadyMade[this.scrapeBaseID(key)] = val; // val == true
}, this);
// now get rid of the commits that will redo same changes
toRebaseRough = toRebase;
toRebase = [];
_.each(toRebaseRough, function(commit) {
var baseID = this.scrapeBaseID(commit.get('id')); var baseID = this.scrapeBaseID(commit.get('id'));
if (!changesAlreadyMade[baseID]) { if (changesAlreadyMade[baseID]) {
toRebase.push(commit); return false;
} }
}, this);
toRebaseRough = toRebase; // make unique
toRebase = []; if (uniqueIDs[commit.get('id')]) {
// finally, make the set unique return false;
var uniqueIDs = {}; }
_.each(toRebaseRough, function(commit) {
if (uniqueIDs[commit.get('id')]) { return; }
uniqueIDs[commit.get('id')] = true; uniqueIDs[commit.get('id')] = true;
toRebase.push(commit); return true;
}, this); });
};
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) {
// now we have the all the commits between currentLocation and the set of target to rebase.
var destinationBranch = this.resolveID(targetSource);
var deferred = Q.defer();
var chain = deferred.promise;
var toRebase = this.filterRebaseCommits(toRebaseRough, stopSet);
if (!toRebase.length) { if (!toRebase.length) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-rebase-none') msg: intl.str('git-error-rebase-none')
}); });
} }
animationResponse.toRebaseArray = toRebase.slice(0);
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
// each step makes a new commit
// do the rebase, and also maintain all our animation info during this var chainStep = _.bind(function(oldCommit) {
animationResponse.rebaseSteps = []; var newId = this.rebaseAltID(oldCommit.get('id'));
var beforeSnapshot = this.gitVisuals.genSnapshot();
var afterSnapshot;
_.each(toRebase, function(old) {
var newId = this.rebaseAltID(old.get('id'));
var newCommit = this.makeCommit([base], newId); var newCommit = this.makeCommit([base], newId);
base = newCommit; base = newCommit;
// animation info return this.animationFactory.playCommitBirthPromiseAnimation(
afterSnapshot = this.gitVisuals.genSnapshot(); newCommit,
animationResponse.rebaseSteps.push({ this.gitVisuals
oldCommit: old, );
newCommit: newCommit,
beforeSnapshot: beforeSnapshot,
afterSnapshot: afterSnapshot
});
beforeSnapshot = afterSnapshot;
}, this); }, this);
// set up the promise chain
_.each(toRebase, function(commit) {
chain = chain.then(function() {
return chainStep(commit);
});
}, this);
chain = chain.then(_.bind(function() {
if (this.resolveID(currentLocation).get('type') == 'commit') { if (this.resolveID(currentLocation).get('type') == 'commit') {
// we referenced a commit like git rebase C2 C1, so we have // we referenced a commit like git rebase C2 C1, so we have
// to manually check out C1' // to manually check out C1'
this.checkout(base);
var steps = animationResponse.rebaseSteps;
var newestCommit = steps[steps.length - 1].newCommit;
this.checkout(newestCommit);
} else { } else {
// now we just need to update the rebased branch is // now we just need to update the rebased branch is
this.setTargetLocation(currentLocation, base); this.setTargetLocation(currentLocation, base);
this.checkout(currentLocation); this.checkout(currentLocation);
} }
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
// for animation this.animationQueue.thenFinish(chain, deferred);
return animationResponse;
}; };
GitEngine.prototype.mergeStarter = function() { GitEngine.prototype.mergeStarter = function() {
@ -31504,17 +31471,8 @@ AnimationFactory.prototype.genHighlightPromiseAnimation = function(commit, destO
}; };
AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destObj) { AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destObj) {
console.log('playing highlight animation');
try {
var animation = this.genHighlightPromiseAnimation(commit, destObj); var animation = this.genHighlightPromiseAnimation(commit, destObj);
console.log('aniamtion duration', animation.get('duration'));
animation.play(); animation.play();
console.log('aniamtion duration', animation.get('duration'));
animation.getPromise();
} catch (e) {
debugger;
console.log(e);
}
return animation.getPromise(); return animation.getPromise();
}; };
@ -31674,7 +31632,7 @@ var AnimationQueue = Backbone.Model.extend({
index: 0, index: 0,
callback: null, callback: null,
defer: false, defer: false,
promiseBased: false, promiseBased: false
}, },
initialize: function(options) { initialize: function(options) {

View file

@ -842,6 +842,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
this.origin.gitVisuals this.origin.gitVisuals
); );
}, this); }, this);
var chainStepWrap = function() { return chainStep(); };
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
@ -851,9 +852,7 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
// teamwork all at once because then the animation of each child // teamwork all at once because then the animation of each child
// is difficult. Instead, we will generate a promise chain which will // is difficult. Instead, we will generate a promise chain which will
// produce the commit right before every animation // produce the commit right before every animation
chain = chain.then(function() { chain = chain.then(chainStepWrap);
return chainStep();
});
} }
this.animationQueue.thenFinish(chain, deferred); this.animationQueue.thenFinish(chain, deferred);
}; };
@ -1388,96 +1387,85 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
}); });
}; };
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) { GitEngine.prototype.filterRebaseCommits = function(toRebaseRough, stopSet) {
// now we have the all the commits between currentLocation and the set of target to rebase. var changesAlreadyMade = {};
var animationResponse = {}; _.each(stopSet, function(val, key) {
animationResponse.destinationBranch = this.resolveID(targetSource); changesAlreadyMade[this.scrapeBaseID(key)] = true;
}, this);
var uniqueIDs = {};
// we need to throw out merge commits // resolve the commits we will rebase
var toRebase = []; return _.filter(toRebaseRough, function(commit) {
_.each(toRebaseRough, function(commit) { // no merge commits
if (commit.get('parents').length == 1) { if (commit.get('parents').length !== 1) {
toRebase.push(commit); return false;
} }
});
// we ALSO need to throw out commits that will do the same changes. like // we ALSO need to throw out commits that will do the same changes. like
// if the upstream set has a commit C4 and we have C4', we dont rebase the C4' again. // if the upstream set has a commit C4 and we have C4', we dont rebase the C4' again.
// get this by doing ID scraping
var changesAlreadyMade = {};
_.each(stopSet, function(val, key) {
changesAlreadyMade[this.scrapeBaseID(key)] = val; // val == true
}, this);
// now get rid of the commits that will redo same changes
toRebaseRough = toRebase;
toRebase = [];
_.each(toRebaseRough, function(commit) {
var baseID = this.scrapeBaseID(commit.get('id')); var baseID = this.scrapeBaseID(commit.get('id'));
if (!changesAlreadyMade[baseID]) { if (changesAlreadyMade[baseID]) {
toRebase.push(commit); return false;
} }
}, this);
toRebaseRough = toRebase; // make unique
toRebase = []; if (uniqueIDs[commit.get('id')]) {
// finally, make the set unique return false;
var uniqueIDs = {}; }
_.each(toRebaseRough, function(commit) {
if (uniqueIDs[commit.get('id')]) { return; }
uniqueIDs[commit.get('id')] = true; uniqueIDs[commit.get('id')] = true;
toRebase.push(commit); return true;
}, this); });
};
GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource, currentLocation) {
// now we have the all the commits between currentLocation and the set of target to rebase.
var destinationBranch = this.resolveID(targetSource);
var deferred = Q.defer();
var chain = deferred.promise;
var toRebase = this.filterRebaseCommits(toRebaseRough, stopSet);
if (!toRebase.length) { if (!toRebase.length) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-rebase-none') msg: intl.str('git-error-rebase-none')
}); });
} }
animationResponse.toRebaseArray = toRebase.slice(0);
// now pop all of these commits onto targetLocation // now pop all of these commits onto targetLocation
var base = this.getCommitFromRef(targetSource); var base = this.getCommitFromRef(targetSource);
// each step makes a new commit
// do the rebase, and also maintain all our animation info during this var chainStep = _.bind(function(oldCommit) {
animationResponse.rebaseSteps = []; var newId = this.rebaseAltID(oldCommit.get('id'));
var beforeSnapshot = this.gitVisuals.genSnapshot();
var afterSnapshot;
_.each(toRebase, function(old) {
var newId = this.rebaseAltID(old.get('id'));
var newCommit = this.makeCommit([base], newId); var newCommit = this.makeCommit([base], newId);
base = newCommit; base = newCommit;
// animation info return this.animationFactory.playCommitBirthPromiseAnimation(
afterSnapshot = this.gitVisuals.genSnapshot(); newCommit,
animationResponse.rebaseSteps.push({ this.gitVisuals
oldCommit: old, );
newCommit: newCommit,
beforeSnapshot: beforeSnapshot,
afterSnapshot: afterSnapshot
});
beforeSnapshot = afterSnapshot;
}, this); }, this);
// set up the promise chain
_.each(toRebase, function(commit) {
chain = chain.then(function() {
return chainStep(commit);
});
}, this);
chain = chain.then(_.bind(function() {
if (this.resolveID(currentLocation).get('type') == 'commit') { if (this.resolveID(currentLocation).get('type') == 'commit') {
// we referenced a commit like git rebase C2 C1, so we have // we referenced a commit like git rebase C2 C1, so we have
// to manually check out C1' // to manually check out C1'
this.checkout(base);
var steps = animationResponse.rebaseSteps;
var newestCommit = steps[steps.length - 1].newCommit;
this.checkout(newestCommit);
} else { } else {
// now we just need to update the rebased branch is // now we just need to update the rebased branch is
this.setTargetLocation(currentLocation, base); this.setTargetLocation(currentLocation, base);
this.checkout(currentLocation); this.checkout(currentLocation);
} }
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
// for animation this.animationQueue.thenFinish(chain, deferred);
return animationResponse;
}; };
GitEngine.prototype.mergeStarter = function() { GitEngine.prototype.mergeStarter = function() {

View file

@ -191,17 +191,8 @@ AnimationFactory.prototype.genHighlightPromiseAnimation = function(commit, destO
}; };
AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destObj) { AnimationFactory.prototype.playHighlightPromiseAnimation = function(commit, destObj) {
console.log('playing highlight animation');
try {
var animation = this.genHighlightPromiseAnimation(commit, destObj); var animation = this.genHighlightPromiseAnimation(commit, destObj);
console.log('aniamtion duration', animation.get('duration'));
animation.play(); animation.play();
console.log('aniamtion duration', animation.get('duration'));
animation.getPromise();
} catch (e) {
debugger;
console.log(e);
}
return animation.getPromise(); return animation.getPromise();
}; };

View file

@ -30,7 +30,7 @@ var AnimationQueue = Backbone.Model.extend({
index: 0, index: 0,
callback: null, callback: null,
defer: false, defer: false,
promiseBased: false, promiseBased: false
}, },
initialize: function(options) { initialize: function(options) {