now multi origin fetch works

This commit is contained in:
Peter Cottle 2013-09-01 11:55:28 -07:00
parent d6c89f913f
commit 7cec1bcaab
5 changed files with 91 additions and 60 deletions

View file

@ -8101,7 +8101,7 @@ GitEngine.prototype.push = function(options) {
// HAX HAX update master and remote tracking for master // HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch); var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchID(); var remoteBranchID = ORIGIN_PREFIX + localBranch.getID();
// less hacks hax // less hacks hax
this.setTargetLocation(this.refs[remoteBranchID], localCommit); this.setTargetLocation(this.refs[remoteBranchID], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
@ -8115,13 +8115,11 @@ GitEngine.prototype.push = function(options) {
GitEngine.prototype.fetch = function(options) { GitEngine.prototype.fetch = function(options) {
options = options || {}; options = options || {};
var localBranch = this.refs['o/master']; var localBranch = this.refs['o/master'];
var remoteBranch = this.origin.refs['master'];
// fetch all local branches // fetch all local branches
var allRemotes = this.branchCollection.filter(function(branch) { var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote(); return branch.getIsRemote();
}); });
console.log(allRemotes);
// first check if our local remote branch is upstream of the origin branch set. // 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 // this check essentially pretends the local remote branch is in origin and
@ -8131,19 +8129,22 @@ GitEngine.prototype.fetch = function(options) {
this, this,
this.origin, this.origin,
localRemoteBranch, localRemoteBranch,
localRemoteBranch.getRemoteBranchFromEngine(this.origin) this.origin.refs[localRemoteBranch.getBaseID()]
); );
}, this); }, this);
// then we get the difference in commits between these two graphs, ordered by // then we get the difference in commits between these two graphs, ordered by
// depth. TODO -- make work for all branches // depth. TODO -- make work for all branches
var commitsToMake = this.getTargetGraphDifference( var commitsToMake = [];
this, _.each(allRemotes, function(localRemoteBranch) {
this.origin, commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
localBranch, this,
remoteBranch, this.origin,
options localRemoteBranch,
); this.origin.refs[localRemoteBranch.getBaseID()],
options
));
}, this);
if (commitsToMake.length === 0) { if (commitsToMake.length === 0) {
this.command.addWarning(intl.str( this.command.addWarning(intl.str(
@ -8195,10 +8196,17 @@ GitEngine.prototype.fetch = function(options) {
}, this); }, this);
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var originLocationID = remoteBranch.get('target').get('id'); // update all the remote branches
var localCommit = this.refs[originLocationID]; _.each(allRemotes, function(localRemoteBranch) {
this.setTargetLocation(localBranch, localCommit); var remoteBranch = this.origin.refs[localRemoteBranch.getBaseID()];
// unhighlight origin var remoteLocationID = remoteBranch.get('target').get('id');
// by definition we just made the commit with this id,
// so we can grab it now
var localCommit = this.refs[remoteLocationID];
this.setTargetLocation(localRemoteBranch, localCommit);
}, this);
// unhighlight origin by refreshing
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals); this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }, this));
@ -9535,15 +9543,18 @@ var Branch = Ref.extend({
return this.get('localBranchesThatTrackThis') || []; return this.get('localBranchesThatTrackThis') || [];
}, },
getRemoteBranchID: function() { getPrefixedID: function() {
if (this.getIsRemote()) { if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me'); throw new Error('im already remote');
} }
return ORIGIN_PREFIX + this.get('id'); return ORIGIN_PREFIX + this.get('id');
}, },
getRemoteBranchFromEngine: function(engine) { getBaseID: function() {
return engine.refs[this.getRemoteBranchID()]; if (!this.getIsRemote()) {
throw new Error('im not remote so cant get base');
}
return this.get('id').replace(ORIGIN_PREFIX, '');
}, },
getIsRemote: function() { getIsRemote: function() {
@ -26523,7 +26534,7 @@ GitEngine.prototype.push = function(options) {
// HAX HAX update master and remote tracking for master // HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch); var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchID(); var remoteBranchID = ORIGIN_PREFIX + localBranch.getID();
// less hacks hax // less hacks hax
this.setTargetLocation(this.refs[remoteBranchID], localCommit); this.setTargetLocation(this.refs[remoteBranchID], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
@ -26537,13 +26548,11 @@ GitEngine.prototype.push = function(options) {
GitEngine.prototype.fetch = function(options) { GitEngine.prototype.fetch = function(options) {
options = options || {}; options = options || {};
var localBranch = this.refs['o/master']; var localBranch = this.refs['o/master'];
var remoteBranch = this.origin.refs['master'];
// fetch all local branches // fetch all local branches
var allRemotes = this.branchCollection.filter(function(branch) { var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote(); return branch.getIsRemote();
}); });
console.log(allRemotes);
// first check if our local remote branch is upstream of the origin branch set. // 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 // this check essentially pretends the local remote branch is in origin and
@ -26553,19 +26562,22 @@ GitEngine.prototype.fetch = function(options) {
this, this,
this.origin, this.origin,
localRemoteBranch, localRemoteBranch,
localRemoteBranch.getRemoteBranchFromEngine(this.origin) this.origin.refs[localRemoteBranch.getBaseID()]
); );
}, this); }, this);
// then we get the difference in commits between these two graphs, ordered by // then we get the difference in commits between these two graphs, ordered by
// depth. TODO -- make work for all branches // depth. TODO -- make work for all branches
var commitsToMake = this.getTargetGraphDifference( var commitsToMake = [];
this, _.each(allRemotes, function(localRemoteBranch) {
this.origin, commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
localBranch, this,
remoteBranch, this.origin,
options localRemoteBranch,
); this.origin.refs[localRemoteBranch.getBaseID()],
options
));
}, this);
if (commitsToMake.length === 0) { if (commitsToMake.length === 0) {
this.command.addWarning(intl.str( this.command.addWarning(intl.str(
@ -26617,10 +26629,17 @@ GitEngine.prototype.fetch = function(options) {
}, this); }, this);
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var originLocationID = remoteBranch.get('target').get('id'); // update all the remote branches
var localCommit = this.refs[originLocationID]; _.each(allRemotes, function(localRemoteBranch) {
this.setTargetLocation(localBranch, localCommit); var remoteBranch = this.origin.refs[localRemoteBranch.getBaseID()];
// unhighlight origin var remoteLocationID = remoteBranch.get('target').get('id');
// by definition we just made the commit with this id,
// so we can grab it now
var localCommit = this.refs[remoteLocationID];
this.setTargetLocation(localRemoteBranch, localCommit);
}, this);
// unhighlight origin by refreshing
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals); this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }, this));
@ -27957,15 +27976,18 @@ var Branch = Ref.extend({
return this.get('localBranchesThatTrackThis') || []; return this.get('localBranchesThatTrackThis') || [];
}, },
getRemoteBranchID: function() { getPrefixedID: function() {
if (this.getIsRemote()) { if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me'); throw new Error('im already remote');
} }
return ORIGIN_PREFIX + this.get('id'); return ORIGIN_PREFIX + this.get('id');
}, },
getRemoteBranchFromEngine: function(engine) { getBaseID: function() {
return engine.refs[this.getRemoteBranchID()]; if (!this.getIsRemote()) {
throw new Error('im not remote so cant get base');
}
return this.get('id').replace(ORIGIN_PREFIX, '');
}, },
getIsRemote: function() { getIsRemote: function() {

File diff suppressed because one or more lines are too long

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

View file

@ -881,7 +881,7 @@ GitEngine.prototype.push = function(options) {
// HAX HAX update master and remote tracking for master // HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch); var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchID(); var remoteBranchID = ORIGIN_PREFIX + localBranch.getID();
// less hacks hax // less hacks hax
this.setTargetLocation(this.refs[remoteBranchID], localCommit); this.setTargetLocation(this.refs[remoteBranchID], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
@ -895,13 +895,11 @@ GitEngine.prototype.push = function(options) {
GitEngine.prototype.fetch = function(options) { GitEngine.prototype.fetch = function(options) {
options = options || {}; options = options || {};
var localBranch = this.refs['o/master']; var localBranch = this.refs['o/master'];
var remoteBranch = this.origin.refs['master'];
// fetch all local branches // fetch all local branches
var allRemotes = this.branchCollection.filter(function(branch) { var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote(); return branch.getIsRemote();
}); });
console.log(allRemotes);
// first check if our local remote branch is upstream of the origin branch set. // 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 // this check essentially pretends the local remote branch is in origin and
@ -911,19 +909,22 @@ GitEngine.prototype.fetch = function(options) {
this, this,
this.origin, this.origin,
localRemoteBranch, localRemoteBranch,
localRemoteBranch.getRemoteBranchFromEngine(this.origin) this.origin.refs[localRemoteBranch.getBaseID()]
); );
}, this); }, this);
// then we get the difference in commits between these two graphs, ordered by // then we get the difference in commits between these two graphs, ordered by
// depth. TODO -- make work for all branches // depth. TODO -- make work for all branches
var commitsToMake = this.getTargetGraphDifference( var commitsToMake = [];
this, _.each(allRemotes, function(localRemoteBranch) {
this.origin, commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
localBranch, this,
remoteBranch, this.origin,
options localRemoteBranch,
); this.origin.refs[localRemoteBranch.getBaseID()],
options
));
}, this);
if (commitsToMake.length === 0) { if (commitsToMake.length === 0) {
this.command.addWarning(intl.str( this.command.addWarning(intl.str(
@ -975,10 +976,17 @@ GitEngine.prototype.fetch = function(options) {
}, this); }, this);
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var originLocationID = remoteBranch.get('target').get('id'); // update all the remote branches
var localCommit = this.refs[originLocationID]; _.each(allRemotes, function(localRemoteBranch) {
this.setTargetLocation(localBranch, localCommit); var remoteBranch = this.origin.refs[localRemoteBranch.getBaseID()];
// unhighlight origin var remoteLocationID = remoteBranch.get('target').get('id');
// by definition we just made the commit with this id,
// so we can grab it now
var localCommit = this.refs[remoteLocationID];
this.setTargetLocation(localRemoteBranch, localCommit);
}, this);
// unhighlight origin by refreshing
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals); this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }, this));
@ -2315,15 +2323,18 @@ var Branch = Ref.extend({
return this.get('localBranchesThatTrackThis') || []; return this.get('localBranchesThatTrackThis') || [];
}, },
getRemoteBranchID: function() { getPrefixedID: function() {
if (this.getIsRemote()) { if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me'); throw new Error('im already remote');
} }
return ORIGIN_PREFIX + this.get('id'); return ORIGIN_PREFIX + this.get('id');
}, },
getRemoteBranchFromEngine: function(engine) { getBaseID: function() {
return engine.refs[this.getRemoteBranchID()]; if (!this.getIsRemote()) {
throw new Error('im not remote so cant get base');
}
return this.get('id').replace(ORIGIN_PREFIX, '');
}, },
getIsRemote: function() { getIsRemote: function() {