moving to interactive rebasing

This commit is contained in:
Peter Cottle 2012-10-23 15:18:37 -07:00
parent 7e28fd8452
commit 0674d77fed
5 changed files with 50 additions and 17 deletions

View file

@ -93,7 +93,6 @@ AnimationFactory.prototype.genCommitBirthClosureFromSnapshot = function(step) {
AnimationFactory.prototype.refreshTree = function(animationQueue) {
animationQueue.add(new Animation({
closure: function() {
console.log('refreshing tree from here');
gitVisuals.refreshTree();
}
}));

View file

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

View file

@ -264,7 +264,9 @@ OptionParser.prototype.getMasterOptionMap = function() {
'--soft': false, // this will raise an error but we catch it in gitEngine
},
merge: {},
rebase: {},
rebase: {
'-i': false // the mother of all options
},
revert: {},
show: {}
};

View file

@ -443,7 +443,7 @@ GitEngine.prototype.commitStarter = function() {
if (this.commandOptions['-am']) {
var args = this.commandOptions['-am'];
this.validateArgBounds(args, 1, 1);
this.validateArgBounds(args, 1, 1, '-am');
this.command.addWarning("Don't worry about adding files in this demo. I'll take " +
"down your commit message anyways, but you can commit without a message " +
@ -453,7 +453,7 @@ GitEngine.prototype.commitStarter = function() {
if (this.commandOptions['-m']) {
var args = this.commandOptions['-m'];
this.validateArgBounds(args, 1, 1);
this.validateArgBounds(args, 1, 1, '-m');
msg = args[0];
}
@ -739,7 +739,21 @@ GitEngine.prototype.idSortFunc = function(cA, cB) {
return getNumToSort(cA.get('id')) - getNumToSort(cB.get('id'));
};
GitEngine.prototype.rebaseInteractiveStarter = function() {
// first of all, our animation queue will be deferred because now its async
this.animationQueue.set('defer', true);
this.twoArgsImpliedHead(this.commandOptions['-i'], 1, 1, '-i');
// now do stuff :D
};
GitEngine.prototype.rebaseStarter = function() {
if (this.commandOptions['-i']) {
this.rebaseInteractiveStarter();
return;
}
this.twoArgsImpliedHead(this.generalArgs);
var response = this.rebase(this.generalArgs[0], this.generalArgs[1]);
@ -779,16 +793,12 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
return;
}
var animationResponse = {};
animationResponse.destinationBranch = this.resolveID(targetSource);
// now the part of actually rebasing.
// We need to get the downstream set of targetSource first.
// then we BFS from currentLocation, using the downstream set as our stopping point.
// we need to BFS because we need to include all commits below
// pop these commits on top of targetSource and modify their ids with quotes
var stopSet = this.getUpstreamSet(targetSource)
animationResponse.upstreamSet = stopSet;
// now BFS from here on out
var toRebaseRough = [];
@ -809,7 +819,14 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
// pQueue.sort(this.idSortFunc);
}
// now we have the all the commits between currentLocation and the set of target.
return this.rebaseFinish(toRebaseRough, stopSet, targetSource, currentLocation);
};
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 animationResponse = {};
animationResponse.destinationBranch = this.resolveID(targetSource);
// we need to throw out merge commits
var toRebase = [];
@ -827,7 +844,7 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
changesAlreadyMade[this.scrapeBaseID(key)] = val; // val == true
}, this);
// now get rid of those other ones
// now get rid of the commits that will redo same changes
toRebaseRough = toRebase;
toRebase = [];
_.each(toRebaseRough, function(commit) {
@ -871,9 +888,20 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
beforeSnapshot = afterSnapshot;
}, this);
if (this.resolveID(currentLocation).get('type') == 'commit') {
// we referenced a commit like git rebase C2 C1, so we have
// to manually check out C1'
var steps = animationResponse.rebaseSteps;
var newestCommit = steps[steps.length - 1].newCommit;
this.checkout(newestCommit);
} else {
// now we just need to update the rebased branch is
this.setTargetLocation(currentLocation, base);
this.checkout(currentLocation);
}
// for animation
return animationResponse;
};
@ -972,7 +1000,7 @@ GitEngine.prototype.branchStarter = function() {
// handle deletion first
if (this.commandOptions['-d'] || this.commandOptions['-D']) {
var names = this.commandOptions['-d'] || this.commandOptions['-D'];
this.validateArgBounds(names, 1, NaN);
this.validateArgBounds(names, 1, NaN, '-d');
_.each(names, function(name) {
this.deleteBranch(name);
@ -1098,7 +1126,9 @@ GitEngine.prototype.dispatch = function(command, callback) {
}
// animation queue will call the callback when its done
if (!this.animationQueue.get('defer')) {
this.animationQueue.start();
}
};
GitEngine.prototype.showStarter = function() {

View file

@ -6,6 +6,7 @@ Big things:
Big Graphic things:
~~~~~~~~~~~~~~~~~~~~~~~~~
- gitVisuals OVERHAUL. Will make the load / save tree easier
- Callback animations?
Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~