mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 01:10:04 +02:00
wip
This commit is contained in:
parent
e4209c708b
commit
37a9fccec0
9 changed files with 796 additions and 699 deletions
|
@ -3,6 +3,7 @@ var Backbone = require('backbone');
|
|||
|
||||
var constants = require('../util/constants');
|
||||
var util = require('../util');
|
||||
var intl = require('../intl');
|
||||
|
||||
/**
|
||||
* Globals
|
||||
|
@ -41,11 +42,27 @@ var init = function() {
|
|||
});
|
||||
|
||||
events.on('localeChanged', intlRefresh);
|
||||
events.on('vcsModeChange', vcsModeRefresh);
|
||||
|
||||
initRootEvents(eventBaton);
|
||||
initDemo(sandbox);
|
||||
};
|
||||
|
||||
var vcsModeRefresh = function(eventData) {
|
||||
if (!window.$) { return; }
|
||||
|
||||
var mode = eventData.mode;
|
||||
var displayMode = mode.slice(0, 1).toUpperCase() + mode.slice(1);
|
||||
var otherMode = (displayMode === 'Git') ? 'Hg' : 'Git';
|
||||
var regex = new RegExp(otherMode, 'g');
|
||||
|
||||
document.title = intl.str('learn-git-branching').replace(regex, displayMode);
|
||||
$('span.vcs-mode-aware').each(function(i, el) {
|
||||
var text = $(el).text().replace(regex, displayMode);
|
||||
$(el).text(text);
|
||||
});
|
||||
};
|
||||
|
||||
var intlRefresh = function() {
|
||||
if (!window.$) { return; }
|
||||
$('span.intl-aware').each(function(i, el) {
|
||||
|
|
|
@ -70,6 +70,10 @@ GitEngine.prototype.handleModeChange = function(vcs, callback) {
|
|||
chain.then(callback);
|
||||
};
|
||||
|
||||
GitEngine.prototype.getIsHg = function() {
|
||||
return this.mode === 'hg';
|
||||
};
|
||||
|
||||
GitEngine.prototype.setMode = function(vcs) {
|
||||
var switchedToHg = (this.mode === 'git' && vcs === 'hg');
|
||||
this.mode = vcs;
|
||||
|
@ -1214,10 +1218,12 @@ GitEngine.prototype.setTargetLocation = function(ref, target) {
|
|||
|
||||
GitEngine.prototype.pruneTree = function() {
|
||||
var set = this.getUpstreamBranchSet();
|
||||
// dont prune dangling commits if we are on head
|
||||
var underHeadID = this.getCommitFromRef('HEAD').get('id');
|
||||
set[underHeadID] = set[underHeadID] || [];
|
||||
set[underHeadID].push('HEAD');
|
||||
// dont prune commits that HEAD depends on
|
||||
var headSet = this.getUpstreamSet('HEAD');
|
||||
console.log(headSet);
|
||||
_.each(headSet, function(val, commitID) {
|
||||
set[commitID] = true;
|
||||
});
|
||||
|
||||
var toDelete = [];
|
||||
this.commitCollection.each(function(commit) {
|
||||
|
@ -1227,9 +1233,12 @@ GitEngine.prototype.pruneTree = function() {
|
|||
}
|
||||
}, this);
|
||||
|
||||
if (toDelete.length) {
|
||||
this.command.addWarning(intl.str('hg-prune-tree'));
|
||||
if (!toDelete.length) {
|
||||
// returning nothing will perform
|
||||
// the switch sync
|
||||
return;
|
||||
}
|
||||
this.command.addWarning(intl.str('hg-prune-tree'));
|
||||
|
||||
_.each(toDelete, function(commit) {
|
||||
commit.removeFromParents();
|
||||
|
|
|
@ -19,7 +19,6 @@ var commandConfig = {
|
|||
],
|
||||
delegate: function(engine, command) {
|
||||
var options = command.getSupportedMap();
|
||||
console.log(options);
|
||||
if (options['-A']) {
|
||||
command.addWarning(intl.str('hg-a-option'));
|
||||
}
|
||||
|
|
|
@ -352,6 +352,11 @@ var VisBranch = VisBase.extend({
|
|||
var name = this.get('branch').getName();
|
||||
var selected = this.get('branch') === this.gitEngine.HEAD.get('target');
|
||||
var isRemote = this.getIsRemote();
|
||||
var isHg = this.gitEngine.getIsHg();
|
||||
|
||||
if (name === 'HEAD' && isHg) {
|
||||
name = '.';
|
||||
}
|
||||
|
||||
var after = (selected && !this.getIsInOrigin() && !isRemote) ? '*' : '';
|
||||
return name + after;
|
||||
|
@ -393,10 +398,13 @@ var VisBranch = VisBase.extend({
|
|||
this.gitVisuals.removeVisBranch(this);
|
||||
},
|
||||
|
||||
handleModeChange: function() {
|
||||
|
||||
},
|
||||
|
||||
genGraphics: function(paper) {
|
||||
var textPos = this.getTextPosition();
|
||||
var name = this.getName();
|
||||
var text;
|
||||
|
||||
// when from a reload, we dont need to generate the text
|
||||
text = paper.text(textPos.x, textPos.y, String(name));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue