add an hg command config

This commit is contained in:
Siddharth Agarwal 2013-07-31 01:38:55 -07:00
parent 9f7fa32820
commit 1402136bb2
2 changed files with 64 additions and 34 deletions

View file

@ -9876,17 +9876,18 @@ var GitError = Errors.GitError;
var Warning = Errors.Warning; var Warning = Errors.Warning;
var CommandResult = Errors.CommandResult; var CommandResult = Errors.CommandResult;
var commandConfig; var commandConfig, hgCommandConfig;
var commands = { var commands = {
execute: function(vcs, name, engine, commandObj) { execute: function(vcs, name, engine, commandObj) {
if (!commandConfig[name]) { if (!commandConfigs[vcs][name]) {
throw new Error('i dont have a command for ' + name); throw new Error('i dont have a command for ' + name);
} }
commandConfig[name].execute.call(this, engine, commandObj); commandConfigs[vcs][name].execute.call(this, engine, commandObj);
}, },
getShortcutMap: function() { getShortcutMap: function() {
var map = {'git': {}}; var map = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
if (!config.sc) { if (!config.sc) {
return; return;
@ -9897,7 +9898,7 @@ var commands = {
}, },
getOptionMap: function() { getOptionMap: function() {
var optionMap = {'git': {}}; var optionMap = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
var thisMap = {}; var thisMap = {};
@ -9911,7 +9912,7 @@ var commands = {
}, },
getRegexMap: function() { getRegexMap: function() {
var map = {'git': {}}; var map = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
map[vcs][displayName] = config.regex; map[vcs][displayName] = config.regex;
@ -9923,7 +9924,7 @@ var commands = {
* which commands count for the git golf game * which commands count for the git golf game
*/ */
getCommandsThatCount: function() { getCommandsThatCount: function() {
var counted = {'git': {}}; var counted = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
if (config.dontCountForGolf) { if (config.dontCountForGolf) {
return; return;
@ -9934,13 +9935,17 @@ var commands = {
}, },
loop: function(callback, context) { loop: function(callback, context) {
_.each(commandConfig, function (config, name) { callback(config, name, 'git'); }); _.each(commandConfigs, function(commandConfig, vcs) {
_.each(commandConfig, function(config, name) {
callback(config, name, vcs);
});
});
} }
}; };
commandConfig = { hgCommandConfig = {
hgcommit: { commit: {
regex: /^(hg +commit|hg +ci)($|\s)/, regex: /^hg +commit($|\s)/,
options: [ options: [
'--amend', '--amend',
'-m' '-m'
@ -9949,6 +9954,9 @@ commandConfig = {
return commandConfig.commit.execute(engine, command); return commandConfig.commit.execute(engine, command);
} }
}, },
};
commandConfig = {
commit: { commit: {
sc: /^(gc|git ci)($|\s)/, sc: /^(gc|git ci)($|\s)/,
regex: /^git +commit($|\s)/, regex: /^git +commit($|\s)/,
@ -10386,6 +10394,8 @@ commandConfig = {
} }
}; };
var commandConfigs = {'git': commandConfig, 'hg': hgCommandConfig};
var instantCommands = [ var instantCommands = [
[/^(git help($|\s)|git$)/, function() { [/^(git help($|\s)|git$)/, function() {
var lines = [ var lines = [
@ -23763,17 +23773,18 @@ var GitError = Errors.GitError;
var Warning = Errors.Warning; var Warning = Errors.Warning;
var CommandResult = Errors.CommandResult; var CommandResult = Errors.CommandResult;
var commandConfig; var commandConfig, hgCommandConfig;
var commands = { var commands = {
execute: function(vcs, name, engine, commandObj) { execute: function(vcs, name, engine, commandObj) {
if (!commandConfig[name]) { if (!commandConfigs[vcs][name]) {
throw new Error('i dont have a command for ' + name); throw new Error('i dont have a command for ' + name);
} }
commandConfig[name].execute.call(this, engine, commandObj); commandConfigs[vcs][name].execute.call(this, engine, commandObj);
}, },
getShortcutMap: function() { getShortcutMap: function() {
var map = {'git': {}}; var map = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
if (!config.sc) { if (!config.sc) {
return; return;
@ -23784,7 +23795,7 @@ var commands = {
}, },
getOptionMap: function() { getOptionMap: function() {
var optionMap = {'git': {}}; var optionMap = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
var thisMap = {}; var thisMap = {};
@ -23798,7 +23809,7 @@ var commands = {
}, },
getRegexMap: function() { getRegexMap: function() {
var map = {'git': {}}; var map = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
map[vcs][displayName] = config.regex; map[vcs][displayName] = config.regex;
@ -23810,7 +23821,7 @@ var commands = {
* which commands count for the git golf game * which commands count for the git golf game
*/ */
getCommandsThatCount: function() { getCommandsThatCount: function() {
var counted = {'git': {}}; var counted = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
if (config.dontCountForGolf) { if (config.dontCountForGolf) {
return; return;
@ -23821,13 +23832,17 @@ var commands = {
}, },
loop: function(callback, context) { loop: function(callback, context) {
_.each(commandConfig, function (config, name) { callback(config, name, 'git'); }); _.each(commandConfigs, function(commandConfig, vcs) {
_.each(commandConfig, function(config, name) {
callback(config, name, vcs);
});
});
} }
}; };
commandConfig = { hgCommandConfig = {
hgcommit: { commit: {
regex: /^(hg +commit|hg +ci)($|\s)/, regex: /^hg +commit($|\s)/,
options: [ options: [
'--amend', '--amend',
'-m' '-m'
@ -23836,6 +23851,9 @@ commandConfig = {
return commandConfig.commit.execute(engine, command); return commandConfig.commit.execute(engine, command);
} }
}, },
};
commandConfig = {
commit: { commit: {
sc: /^(gc|git ci)($|\s)/, sc: /^(gc|git ci)($|\s)/,
regex: /^git +commit($|\s)/, regex: /^git +commit($|\s)/,
@ -24273,6 +24291,8 @@ commandConfig = {
} }
}; };
var commandConfigs = {'git': commandConfig, 'hg': hgCommandConfig};
var instantCommands = [ var instantCommands = [
[/^(git help($|\s)|git$)/, function() { [/^(git help($|\s)|git$)/, function() {
var lines = [ var lines = [

View file

@ -7,17 +7,18 @@ var GitError = Errors.GitError;
var Warning = Errors.Warning; var Warning = Errors.Warning;
var CommandResult = Errors.CommandResult; var CommandResult = Errors.CommandResult;
var commandConfig; var commandConfig, hgCommandConfig;
var commands = { var commands = {
execute: function(vcs, name, engine, commandObj) { execute: function(vcs, name, engine, commandObj) {
if (!commandConfig[name]) { if (!commandConfigs[vcs][name]) {
throw new Error('i dont have a command for ' + name); throw new Error('i dont have a command for ' + name);
} }
commandConfig[name].execute.call(this, engine, commandObj); commandConfigs[vcs][name].execute.call(this, engine, commandObj);
}, },
getShortcutMap: function() { getShortcutMap: function() {
var map = {'git': {}}; var map = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
if (!config.sc) { if (!config.sc) {
return; return;
@ -28,7 +29,7 @@ var commands = {
}, },
getOptionMap: function() { getOptionMap: function() {
var optionMap = {'git': {}}; var optionMap = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
var thisMap = {}; var thisMap = {};
@ -42,7 +43,7 @@ var commands = {
}, },
getRegexMap: function() { getRegexMap: function() {
var map = {'git': {}}; var map = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
var displayName = config.displayName || name; var displayName = config.displayName || name;
map[vcs][displayName] = config.regex; map[vcs][displayName] = config.regex;
@ -54,7 +55,7 @@ var commands = {
* which commands count for the git golf game * which commands count for the git golf game
*/ */
getCommandsThatCount: function() { getCommandsThatCount: function() {
var counted = {'git': {}}; var counted = {'git': {}, 'hg': {}};
this.loop(function(config, name, vcs) { this.loop(function(config, name, vcs) {
if (config.dontCountForGolf) { if (config.dontCountForGolf) {
return; return;
@ -65,13 +66,17 @@ var commands = {
}, },
loop: function(callback, context) { loop: function(callback, context) {
_.each(commandConfig, function (config, name) { callback(config, name, 'git'); }); _.each(commandConfigs, function(commandConfig, vcs) {
_.each(commandConfig, function(config, name) {
callback(config, name, vcs);
});
});
} }
}; };
commandConfig = { hgCommandConfig = {
hgcommit: { commit: {
regex: /^(hg +commit|hg +ci)($|\s)/, regex: /^hg +commit($|\s)/,
options: [ options: [
'--amend', '--amend',
'-m' '-m'
@ -79,7 +84,10 @@ commandConfig = {
execute: function(engine, command) { execute: function(engine, command) {
return commandConfig.commit.execute(engine, command); return commandConfig.commit.execute(engine, command);
} }
}, }
};
commandConfig = {
commit: { commit: {
sc: /^(gc|git ci)($|\s)/, sc: /^(gc|git ci)($|\s)/,
regex: /^git +commit($|\s)/, regex: /^git +commit($|\s)/,
@ -517,6 +525,8 @@ commandConfig = {
} }
}; };
var commandConfigs = {'git': commandConfig, 'hg': hgCommandConfig};
var instantCommands = [ var instantCommands = [
[/^(git help($|\s)|git$)/, function() { [/^(git help($|\s)|git$)/, function() {
var lines = [ var lines = [