mercurial commands fixed with new option parsing logic

This commit is contained in:
Peter Cottle 2013-11-19 10:00:38 -08:00
parent 1ba46f7705
commit bf52d640d5
2 changed files with 19 additions and 8 deletions

View file

@ -58,7 +58,7 @@ var commandConfig = {
'-r'
],
delegate: function(engine, command) {
command.appendOptionR();
command.prependOptionR();
var options = command.getOptionsMap();
if (!options['-r']) {
throw new GitError({
@ -113,17 +113,17 @@ var commandConfig = {
if (options['-m'] && options['-d']) {
throw new GitError({
msg: '-m and -d are incompatible'
msg: intl.todo('-m and -d are incompatible')
});
}
if (options['-d'] && options['-r']) {
throw new GitError({
msg: '-r is incompatible with -d'
msg: intl.todo('-r is incompatible with -d')
});
}
if (options['-m'] && options['-r']) {
throw new GitError({
msg: '-r is incompatible with -m'
msg: intl.todo('-r is incompatible with -m')
});
}
if (generalArgs.length + (options['-r'] ? options['-r'].length : 0) +
@ -140,9 +140,12 @@ var commandConfig = {
if (options['-r']) {
// we specified a revision with -r but
// need to flip the order
branchName = options['-r'][1] || '';
rev = options['-r'][0] || '';
var generalArgs = command.getGeneralArgs();
branchName = generalArgs[0];
rev = options['-r'][0];
delegate.name = 'branch';
// transform to what git wants
command.setGeneralArgs([branchName, rev]);
} else if (generalArgs.length > 0) {
command.setOptionsMap({'-b': [generalArgs[0]]});
@ -217,7 +220,7 @@ var commandConfig = {
'-r'
],
delegate: function(engine, command) {
command.appendOptionR();
command.prependOptionR();
return {
vcs: 'git',
name: 'revert'

View file

@ -67,6 +67,14 @@ var Command = Backbone.Model.extend({
);
},
// if order is important
prependOptionR: function() {
var rOptions = this.getOptionsMap()['-r'] || [];
this.setGeneralArgs(
rOptions.concat(this.getGeneralArgs())
);
},
mapDotToHead: function() {
var generalArgs = this.getGeneralArgs();
var options = this.getOptionsMap();