From bf52d640d5d14bf751a5ce0080ecff8c0285fcb5 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Tue, 19 Nov 2013 10:00:38 -0800 Subject: [PATCH] mercurial commands fixed with new option parsing logic --- src/js/mercurial/commands.js | 19 +++++++++++-------- src/js/models/commandModel.js | 8 ++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/js/mercurial/commands.js b/src/js/mercurial/commands.js index df884939..c69d33c3 100644 --- a/src/js/mercurial/commands.js +++ b/src/js/mercurial/commands.js @@ -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({ @@ -109,21 +109,21 @@ var commandConfig = { var branchName; var rev; - var delegate = { vcs: 'git' }; + var delegate = {vcs: 'git'}; 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' diff --git a/src/js/models/commandModel.js b/src/js/models/commandModel.js index d565d69e..42ead747 100644 --- a/src/js/models/commandModel.js +++ b/src/js/models/commandModel.js @@ -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();