yay got multiple remotes fetching working

This commit is contained in:
Peter Cottle 2013-10-06 18:09:38 -07:00
parent a16204fea3
commit 9fa8c1383d
8 changed files with 203 additions and 27 deletions

View file

@ -334,6 +334,7 @@ GitEngine.prototype.makeOrigin = function(treeString) {
originVis.customEvents.on('gitEngineReady', function() {
this.origin = originVis.gitEngine;
originVis.gitEngine.assignLocalRepo(this);
this.syncRemoteBranchFills();
// and then here is the crazy part -- we need the ORIGIN to refresh
// itself in a separate animation. @_____@
this.origin.externalRefresh();
@ -943,15 +944,16 @@ GitEngine.prototype.push = function(options) {
GitEngine.prototype.fetch = function(options) {
options = options || {};
// fetch all local branches
// get all remotes
var allRemotes = this.branchCollection.filter(function(branch) {
return branch.getIsRemote();
});
var branchesToFetch = options.branches || 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) {
_.each(branchesToFetch, function(localRemoteBranch) {
this.checkUpstreamOfSource(
this,
this.origin,
@ -962,7 +964,8 @@ GitEngine.prototype.fetch = function(options) {
// then we get the difference in commits between these two graphs
var commitsToMake = [];
_.each(allRemotes, function(localRemoteBranch) {
_.each(branchesToFetch, function(localRemoteBranch) {
options.dontThrowOnNoFetch = true;
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
this,
this.origin,
@ -971,6 +974,12 @@ GitEngine.prototype.fetch = function(options) {
options
));
}, this);
if (!commitsToMake.length) {
throw new GitError({
msg: intl.str('git-error-origin-fetch-uptodate')
});
}
// we did this for each remote branch, but we still need to reduce to unique
// and sort. in this particular app we can never have unfected remote
// commits that are upstream of multiple branches (since the fakeTeamwork
@ -1035,7 +1044,7 @@ GitEngine.prototype.fetch = function(options) {
chain = chain.then(_.bind(function() {
// update all the remote branches
_.each(allRemotes, function(localRemoteBranch) {
_.each(branchesToFetch, function(localRemoteBranch) {
var remoteBranch = this.origin.refs[localRemoteBranch.getBaseID()];
var remoteLocationID = remoteBranch.get('target').get('id');
// by definition we just made the commit with this id,
@ -1376,6 +1385,17 @@ GitEngine.prototype.updateAllBranchesForHg = function() {
return this.updateBranchesForHg(branchList);
};
GitEngine.prototype.syncRemoteBranchFills = function() {
this.branchCollection.each(function(branch) {
if (!branch.getIsRemote()) {
return;
}
var originBranch = this.origin.refs[branch.getBaseID()];
var originFill = originBranch.get('visBranch').get('fill');
branch.get('visBranch').set('fill', originFill);
}, this);
};
GitEngine.prototype.updateBranchesForHg = function(branchList) {
var hasUpdated = false;
_.each(branchList, function(branchID) {