can't merge a commit anyomre

This commit is contained in:
Peter Cottle 2012-10-12 23:18:12 -07:00
parent f353fa118d
commit 703591be5c
3 changed files with 42 additions and 15 deletions

View file

@ -42,10 +42,6 @@ AnimationFactory.prototype.genCommitBirthAnimation = function(animationQueue, co
})); }));
}; };
AnimationFactory.prototype.genCommitBirthAnimationInSequence = function(animationQueue, index, commits) {
};
AnimationFactory.prototype.refreshTree = function(animationQueue) { AnimationFactory.prototype.refreshTree = function(animationQueue) {
animationQueue.add(new Animation({ animationQueue.add(new Animation({
closure: function() { closure: function() {
@ -55,3 +51,7 @@ AnimationFactory.prototype.refreshTree = function(animationQueue) {
})); }));
}; };
AnimationFactory.prototype.rebaseAnimation = function(animationQueue, rebaseResponse, gitEngine) {
};

View file

@ -542,12 +542,14 @@ GitEngine.prototype.rebaseStarter = function() {
this.generalArgs.push('HEAD'); this.generalArgs.push('HEAD');
} }
var response = this.rebase(this.generalArgs[0], this.generalArgs[1]); var response = this.rebase(this.generalArgs[0], this.generalArgs[1]);
if (response === undefined) { if (response === undefined) {
// was a fastforward or already up to date // was a fastforward or already up to date. returning now
// will trigger the refresh animation
return; return;
} }
this.rebaseAnimation(response); animationFactory.rebaseAnimation(this.animationQueue, response, this);
}; };
GitEngine.prototype.rebaseAnimation = function(response) { GitEngine.prototype.rebaseAnimation = function(response) {
@ -615,12 +617,15 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
return; return;
} }
var animationResponse = {};
// now the part of actually rebasing. // now the part of actually rebasing.
// We need to get the downstream set of targetSource first. // We need to get the downstream set of targetSource first.
// then we BFS from currentLocation, using the downstream set as our stopping point. // 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 // 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 // pop these commits on top of targetSource and modify their ids with quotes
var stopSet = this.getUpstreamSet(targetSource) var stopSet = this.getUpstreamSet(targetSource)
animationResponse.upstreamSet = stopSet;
// now BFS from here on out // now BFS from here on out
var toRebaseRough = []; var toRebaseRough = [];
@ -633,6 +638,7 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
if (stopSet[popped.get('id')]) { if (stopSet[popped.get('id')]) {
continue; continue;
} }
// it's not in the set, so we need to rebase this commit // it's not in the set, so we need to rebase this commit
toRebaseRough.push(popped); toRebaseRough.push(popped);
// keep searching // keep searching
@ -651,29 +657,37 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
// now sort // now sort
toRebase.sort(this.idSortFunc); toRebase.sort(this.idSortFunc);
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);
var animationInfo = []; // do the rebase, and also maintain all our animation info during this
for (var i = 0; i < toRebase.length; i++) { animationResponse.rebaseSteps = [];
var old = toRebase[i]; var beforeSnapshot = gitVisuals.genSnapshot();
var afterSnapshot;
_.each(toRebase, function(old) {
var newId = this.rebaseAltId(old.get('id')); var newId = this.rebaseAltId(old.get('id'));
var newCommit = this.makeCommit([base], newId);
var newCommit = this.makeCommit([base], newId);
base = newCommit; base = newCommit;
animationInfo.push({ // animation info
afterSnapshot = gitVisuals.genSnapshot();
animationResponse.rebaseSteps.push({
oldCommit: old, oldCommit: old,
newCommit: newCommit, newCommit: newCommit,
snapshot: gitVisuals.genSnapshot() beforeSnapshot: beforeSnapshot,
afterSnapshot: afterSnapshot
}); });
} beforeSnapshot = afterSnapshot;
}, this);
// now we just need to update where we are // now we just need to update where we are
this.setLocationTarget(currentLocation, base); this.setLocationTarget(currentLocation, base);
// for animation // for animation
return animationInfo; return animationResponse;
}; };
GitEngine.prototype.mergeStarter = function() { GitEngine.prototype.mergeStarter = function() {
@ -697,6 +711,15 @@ GitEngine.prototype.mergeStarter = function() {
}); });
} }
// also can't merge commits directly, even though it makes sense
_.each(this.generalArgs, function(ref) {
if (this.resolveId(ref).get('type') == 'commit') {
throw new GitError({
msg: "Can't merge a commit!"
});
}
}, this);
this.merge(this.generalArgs[0], this.generalArgs[1]); this.merge(this.generalArgs[0], this.generalArgs[1]);
}; };

View file

@ -23,7 +23,11 @@ Small things to implement:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Bugs to fix: Minor Bugs to fix:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Big Bugs to fix:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- resolve core ID from alt Id's (C4''' becomes C4), and then skip those commits when rebasing. big