more push madness

This commit is contained in:
Peter Cottle 2013-10-14 18:33:56 -07:00
parent d3c0fc40a3
commit 3dd5102e2a
2 changed files with 16 additions and 1 deletions

View file

@ -177,5 +177,12 @@ describe('Git Remotes', function() {
); );
}); });
it('will prune the origin tree when deleting branches', function() {
expectTreeAsync(
'git checkout -b foo; git commit; git clone; git push :foo',
'{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master"},"foo":{"target":"C2","id":"foo","remoteTrackingBranchID":null},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"foo","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}}'
);
});
}); });

View file

@ -1011,6 +1011,7 @@ GitEngine.prototype.pushDeleteRemoteBranch = function(
}, this); }, this);
// animation needs to be triggered on origin directly // animation needs to be triggered on origin directly
this.origin.pruneTree();
this.origin.externalRefresh(); this.origin.externalRefresh();
}; };
@ -1562,7 +1563,9 @@ GitEngine.prototype.pruneTree = function() {
// the switch sync // the switch sync
return; return;
} }
this.command.addWarning(intl.str('hg-prune-tree')); if (this.command) {
this.command.addWarning(intl.str('hg-prune-tree'));
}
_.each(toDelete, function(commit) { _.each(toDelete, function(commit) {
commit.removeFromParents(); commit.removeFromParents();
@ -2241,6 +2244,11 @@ GitEngine.prototype.deleteBranch = function(branch) {
this.branchCollection.remove(branch); this.branchCollection.remove(branch);
this.refs[branch.get('id')] = undefined; this.refs[branch.get('id')] = undefined;
delete this.refs[branch.get('id')]; delete this.refs[branch.get('id')];
// also in some cases external engines call our delete, so
// verify integrity of HEAD here
if (this.HEAD.get('target') === branch) {
this.HEAD.set('target', this.refs['master']);
}
if (branch.get('visBranch')) { if (branch.get('visBranch')) {
branch.get('visBranch').remove(); branch.get('visBranch').remove();