This commit is contained in:
Peter Cottle 2013-08-22 19:49:44 -07:00
parent fc502bcdaf
commit d6c89f913f
7 changed files with 192 additions and 72 deletions

View file

@ -7236,6 +7236,7 @@ var GitError = Errors.GitError;
var CommandResult = Errors.CommandResult;
var EventBaton = require('../util/eventBaton').EventBaton;
var ORIGIN_PREFIX = 'o/';
function GitEngine(options) {
this.rootCommit = null;
@ -7565,19 +7566,25 @@ GitEngine.prototype.makeOrigin = function(treeString) {
_.each(originTree.branches, function(branchJSON, branchName) {
var originTarget = branchJSON.target;
var originBranch = this.makeBranch(
'o/' + branchName,
ORIGIN_PREFIX + branchName,
this.getCommitFromRef(originTarget)
);
originBranch.set('remote', true);
// TODO
this.setLocalToTrackRemote();
this.setLocalToTrackRemote(this.refs[branchJSON.id], originBranch);
}, this);
};
GitEngine.prototype.setLocalToTrackRemote = function(localBranch, remoteBranch) {
this.command.addWarning(
'local branch set to track remote branch'
);
remoteBranch.addLocalBranchThatTracksThis(localBranch);
localBranch.setRemoteTrackingBranchID(remoteBranch.get('id'));
// same for local
var msg = 'local branch "' +
localBranch.get('id') +
'" set to track remote branch "' +
remoteBranch.get('id') +
'"';
this.command.addWarning(msg);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -8091,7 +8098,7 @@ GitEngine.prototype.push = function(options) {
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
// HAX HAX update o/master
// HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchID();
@ -8110,16 +8117,26 @@ GitEngine.prototype.fetch = function(options) {
var localBranch = this.refs['o/master'];
var remoteBranch = this.origin.refs['master'];
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
localBranch,
remoteBranch
);
// fetch all local branches
var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote();
});
console.log(allRemotes);
// first check if our local remote branch is upstream of the origin branch set.
// this check essentially pretends the local remote branch is in origin and
// could be fast forwarded (basic sanity check)
_.each(allRemotes, function(localRemoteBranch) {
this.checkUpstreamOfSource(
this,
this.origin,
localRemoteBranch,
localRemoteBranch.getRemoteBranchFromEngine(this.origin)
);
}, this);
// then we get the difference in commits between these two graphs, ordered by
// depth
// depth. TODO -- make work for all branches
var commitsToMake = this.getTargetGraphDifference(
this,
this.origin,
@ -9486,12 +9503,22 @@ var Branch = Ref.extend({
this.set('type', 'branch');
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
/**
* Here is the deal -- there are essentially three types of branches
* we deal with:
* 1) Normal local branches (that may track a remote branch)
* 2) Local remote branches (o/master) that track an origin branch
* 3) Origin branches (master) that exist in origin
*
* With that in mind, we change our branch model to support the following
*/
setRemoteTrackingBranchID: function(id) {
this.set('remoteTrackingBranchID', id);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
getRemoteTrackingBranchID: function() {
return this.get('remoteTrackingBranchID');
},
addLocalBranchThatTracksThis: function(localBranch) {
@ -9500,15 +9527,27 @@ var Branch = Ref.extend({
);
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
},
getRemoteBranchID: function() {
if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me');
}
return 'o/' + this.get('id');
return ORIGIN_PREFIX + this.get('id');
},
getRemoteBranchFromEngine: function(engine) {
return engine.refs[this.getRemoteBranchID()];
},
getIsRemote: function() {
return !!this.get('remote');
return this.get('id').slice(0, 2) === ORIGIN_PREFIX;
}
});
@ -22416,7 +22455,8 @@ require.define("/levels/mixed/jugglingCommits2.js",function(require,module,expor
require.define("/levels/rebase/manyRebases.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
"compareOnlyMasterHashAgnostic": true,
"disabledMap": {
"git revert": true
"git revert": true,
"git cherry-pick": true
},
"goalTreeString": "%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C7%27%22%2C%22id%22%3A%22master%22%7D%2C%22bugFix%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22bugFix%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C6%27%22%2C%22id%22%3A%22side%22%7D%2C%22another%22%3A%7B%22target%22%3A%22C7%27%22%2C%22id%22%3A%22another%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C4%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C4%22%7D%2C%22C5%22%3A%7B%22parents%22%3A%5B%22C4%22%5D%2C%22id%22%3A%22C5%22%7D%2C%22C6%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C6%22%7D%2C%22C7%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C7%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C3%27%22%7D%2C%22C4%27%22%3A%7B%22parents%22%3A%5B%22C3%27%22%5D%2C%22id%22%3A%22C4%27%22%7D%2C%22C5%27%22%3A%7B%22parents%22%3A%5B%22C4%27%22%5D%2C%22id%22%3A%22C5%27%22%7D%2C%22C6%27%22%3A%7B%22parents%22%3A%5B%22C5%27%22%5D%2C%22id%22%3A%22C6%27%22%7D%2C%22C7%27%22%3A%7B%22parents%22%3A%5B%22C6%27%22%5D%2C%22id%22%3A%22C7%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22master%22%2C%22id%22%3A%22HEAD%22%7D%7D",
"solutionCommand": "git checkout bugFix;git rebase master;git checkout side;git rebase bugFix;git checkout another;git rebase side;git rebase another master",
@ -25618,6 +25658,7 @@ var GitError = Errors.GitError;
var CommandResult = Errors.CommandResult;
var EventBaton = require('../util/eventBaton').EventBaton;
var ORIGIN_PREFIX = 'o/';
function GitEngine(options) {
this.rootCommit = null;
@ -25947,19 +25988,25 @@ GitEngine.prototype.makeOrigin = function(treeString) {
_.each(originTree.branches, function(branchJSON, branchName) {
var originTarget = branchJSON.target;
var originBranch = this.makeBranch(
'o/' + branchName,
ORIGIN_PREFIX + branchName,
this.getCommitFromRef(originTarget)
);
originBranch.set('remote', true);
// TODO
this.setLocalToTrackRemote();
this.setLocalToTrackRemote(this.refs[branchJSON.id], originBranch);
}, this);
};
GitEngine.prototype.setLocalToTrackRemote = function(localBranch, remoteBranch) {
this.command.addWarning(
'local branch set to track remote branch'
);
remoteBranch.addLocalBranchThatTracksThis(localBranch);
localBranch.setRemoteTrackingBranchID(remoteBranch.get('id'));
// same for local
var msg = 'local branch "' +
localBranch.get('id') +
'" set to track remote branch "' +
remoteBranch.get('id') +
'"';
this.command.addWarning(msg);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -26473,7 +26520,7 @@ GitEngine.prototype.push = function(options) {
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
// HAX HAX update o/master
// HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchID();
@ -26492,16 +26539,26 @@ GitEngine.prototype.fetch = function(options) {
var localBranch = this.refs['o/master'];
var remoteBranch = this.origin.refs['master'];
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
localBranch,
remoteBranch
);
// fetch all local branches
var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote();
});
console.log(allRemotes);
// first check if our local remote branch is upstream of the origin branch set.
// this check essentially pretends the local remote branch is in origin and
// could be fast forwarded (basic sanity check)
_.each(allRemotes, function(localRemoteBranch) {
this.checkUpstreamOfSource(
this,
this.origin,
localRemoteBranch,
localRemoteBranch.getRemoteBranchFromEngine(this.origin)
);
}, this);
// then we get the difference in commits between these two graphs, ordered by
// depth
// depth. TODO -- make work for all branches
var commitsToMake = this.getTargetGraphDifference(
this,
this.origin,
@ -27868,12 +27925,22 @@ var Branch = Ref.extend({
this.set('type', 'branch');
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
/**
* Here is the deal -- there are essentially three types of branches
* we deal with:
* 1) Normal local branches (that may track a remote branch)
* 2) Local remote branches (o/master) that track an origin branch
* 3) Origin branches (master) that exist in origin
*
* With that in mind, we change our branch model to support the following
*/
setRemoteTrackingBranchID: function(id) {
this.set('remoteTrackingBranchID', id);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
getRemoteTrackingBranchID: function() {
return this.get('remoteTrackingBranchID');
},
addLocalBranchThatTracksThis: function(localBranch) {
@ -27882,15 +27949,27 @@ var Branch = Ref.extend({
);
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
},
getRemoteBranchID: function() {
if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me');
}
return 'o/' + this.get('id');
return ORIGIN_PREFIX + this.get('id');
},
getRemoteBranchFromEngine: function(engine) {
return engine.refs[this.getRemoteBranchID()];
},
getIsRemote: function() {
return !!this.get('remote');
return this.get('id').slice(0, 2) === ORIGIN_PREFIX;
}
});
@ -41019,7 +41098,8 @@ require("/src/levels/rampup/reversingChanges.js");
require.define("/src/levels/rebase/manyRebases.js",function(require,module,exports,__dirname,__filename,process,global){exports.level = {
"compareOnlyMasterHashAgnostic": true,
"disabledMap": {
"git revert": true
"git revert": true,
"git cherry-pick": true
},
"goalTreeString": "%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C7%27%22%2C%22id%22%3A%22master%22%7D%2C%22bugFix%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22bugFix%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C6%27%22%2C%22id%22%3A%22side%22%7D%2C%22another%22%3A%7B%22target%22%3A%22C7%27%22%2C%22id%22%3A%22another%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C4%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C4%22%7D%2C%22C5%22%3A%7B%22parents%22%3A%5B%22C4%22%5D%2C%22id%22%3A%22C5%22%7D%2C%22C6%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C6%22%7D%2C%22C7%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C7%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C3%27%22%7D%2C%22C4%27%22%3A%7B%22parents%22%3A%5B%22C3%27%22%5D%2C%22id%22%3A%22C4%27%22%7D%2C%22C5%27%22%3A%7B%22parents%22%3A%5B%22C4%27%22%5D%2C%22id%22%3A%22C5%27%22%7D%2C%22C6%27%22%3A%7B%22parents%22%3A%5B%22C5%27%22%5D%2C%22id%22%3A%22C6%27%22%7D%2C%22C7%27%22%3A%7B%22parents%22%3A%5B%22C6%27%22%5D%2C%22id%22%3A%22C7%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22master%22%2C%22id%22%3A%22HEAD%22%7D%7D",
"solutionCommand": "git checkout bugFix;git rebase master;git checkout side;git rebase bugFix;git checkout another;git rebase side;git rebase another master",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
build/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -445,7 +445,7 @@
For a much easier time perusing the source, see the individual files at:
https://github.com/pcottle/learnGitBranching
-->
<script src="build/bundle.min.f6846e91.js"></script>
<script src="build/bundle.min.19698afc.js"></script>
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
The downside? No raw logs to parse for analytics, so I have to include

View file

@ -16,6 +16,7 @@ var GitError = Errors.GitError;
var CommandResult = Errors.CommandResult;
var EventBaton = require('../util/eventBaton').EventBaton;
var ORIGIN_PREFIX = 'o/';
function GitEngine(options) {
this.rootCommit = null;
@ -345,19 +346,25 @@ GitEngine.prototype.makeOrigin = function(treeString) {
_.each(originTree.branches, function(branchJSON, branchName) {
var originTarget = branchJSON.target;
var originBranch = this.makeBranch(
'o/' + branchName,
ORIGIN_PREFIX + branchName,
this.getCommitFromRef(originTarget)
);
originBranch.set('remote', true);
// TODO
this.setLocalToTrackRemote();
this.setLocalToTrackRemote(this.refs[branchJSON.id], originBranch);
}, this);
};
GitEngine.prototype.setLocalToTrackRemote = function(localBranch, remoteBranch) {
this.command.addWarning(
'local branch set to track remote branch'
);
remoteBranch.addLocalBranchThatTracksThis(localBranch);
localBranch.setRemoteTrackingBranchID(remoteBranch.get('id'));
// same for local
var msg = 'local branch "' +
localBranch.get('id') +
'" set to track remote branch "' +
remoteBranch.get('id') +
'"';
this.command.addWarning(msg);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -871,7 +878,7 @@ GitEngine.prototype.push = function(options) {
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
// HAX HAX update o/master
// HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchID();
@ -890,16 +897,26 @@ GitEngine.prototype.fetch = function(options) {
var localBranch = this.refs['o/master'];
var remoteBranch = this.origin.refs['master'];
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
localBranch,
remoteBranch
);
// fetch all local branches
var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote();
});
console.log(allRemotes);
// first check if our local remote branch is upstream of the origin branch set.
// this check essentially pretends the local remote branch is in origin and
// could be fast forwarded (basic sanity check)
_.each(allRemotes, function(localRemoteBranch) {
this.checkUpstreamOfSource(
this,
this.origin,
localRemoteBranch,
localRemoteBranch.getRemoteBranchFromEngine(this.origin)
);
}, this);
// then we get the difference in commits between these two graphs, ordered by
// depth
// depth. TODO -- make work for all branches
var commitsToMake = this.getTargetGraphDifference(
this,
this.origin,
@ -2266,12 +2283,22 @@ var Branch = Ref.extend({
this.set('type', 'branch');
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
/**
* Here is the deal -- there are essentially three types of branches
* we deal with:
* 1) Normal local branches (that may track a remote branch)
* 2) Local remote branches (o/master) that track an origin branch
* 3) Origin branches (master) that exist in origin
*
* With that in mind, we change our branch model to support the following
*/
setRemoteTrackingBranchID: function(id) {
this.set('remoteTrackingBranchID', id);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
getRemoteTrackingBranchID: function() {
return this.get('remoteTrackingBranchID');
},
addLocalBranchThatTracksThis: function(localBranch) {
@ -2280,15 +2307,27 @@ var Branch = Ref.extend({
);
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
},
getRemoteBranchID: function() {
if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me');
}
return 'o/' + this.get('id');
return ORIGIN_PREFIX + this.get('id');
},
getRemoteBranchFromEngine: function(engine) {
return engine.refs[this.getRemoteBranchID()];
},
getIsRemote: function() {
return !!this.get('remote');
return this.get('id').slice(0, 2) === ORIGIN_PREFIX;
}
});

View file

@ -1,7 +1,8 @@
exports.level = {
"compareOnlyMasterHashAgnostic": true,
"disabledMap": {
"git revert": true
"git revert": true,
"git cherry-pick": true
},
"goalTreeString": "%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C7%27%22%2C%22id%22%3A%22master%22%7D%2C%22bugFix%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22bugFix%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C6%27%22%2C%22id%22%3A%22side%22%7D%2C%22another%22%3A%7B%22target%22%3A%22C7%27%22%2C%22id%22%3A%22another%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C4%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C4%22%7D%2C%22C5%22%3A%7B%22parents%22%3A%5B%22C4%22%5D%2C%22id%22%3A%22C5%22%7D%2C%22C6%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C6%22%7D%2C%22C7%22%3A%7B%22parents%22%3A%5B%22C5%22%5D%2C%22id%22%3A%22C7%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C3%27%22%7D%2C%22C4%27%22%3A%7B%22parents%22%3A%5B%22C3%27%22%5D%2C%22id%22%3A%22C4%27%22%7D%2C%22C5%27%22%3A%7B%22parents%22%3A%5B%22C4%27%22%5D%2C%22id%22%3A%22C5%27%22%7D%2C%22C6%27%22%3A%7B%22parents%22%3A%5B%22C5%27%22%5D%2C%22id%22%3A%22C6%27%22%7D%2C%22C7%27%22%3A%7B%22parents%22%3A%5B%22C6%27%22%5D%2C%22id%22%3A%22C7%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22master%22%2C%22id%22%3A%22HEAD%22%7D%7D",
"solutionCommand": "git checkout bugFix;git rebase master;git checkout side;git rebase bugFix;git checkout another;git rebase side;git rebase another master",