diff --git a/src/js/git/commands.js b/src/js/git/commands.js index bf697806..42235a04 100644 --- a/src/js/git/commands.js +++ b/src/js/git/commands.js @@ -425,6 +425,7 @@ var commandConfig = { return; } + console.log(generalArgs); command.validateArgBounds(generalArgs, 1, 1); engine.checkout(engine.crappyUnescape(generalArgs[0])); diff --git a/src/js/mercurial/commands.js b/src/js/mercurial/commands.js index ae8c2ebb..6cd7b9c9 100644 --- a/src/js/mercurial/commands.js +++ b/src/js/mercurial/commands.js @@ -99,7 +99,6 @@ var commandConfig = { regex: /^hg (bookmarks|bookmark|book)($|\s)/, options: [ '-r', - '-m', '-f', '-d' ], @@ -109,59 +108,52 @@ var commandConfig = { var branchName; var rev; - if (options['-r']) { - // we specified a revision with -r but - // need to flip the order - branchName = options['-r'][1] || ''; - rev = options['-r'][0] || ''; - command.setSupportedMap({ - '-b': [branchName, rev] + var delegate = { vcs: 'git' }; + + if (options['-m'] && options['-d']) { + throw new GitError({ + msg: '-m and -d are incompatible' }); - return { - vcs: 'git', - name: 'checkout' - }; - } else if (options['-f']) { - // TODO sid0 -- also assuming that - // bookmark -f is - // the order here - branchName = options['-f'][1] || ''; - rev = options['-f'][0] || ''; - command.setSupportedMap({ - '-f': [branchName, rev] + } + if (options['-d'] && options['-r']) { + throw new GitError({ + msg: '-r is incompatible with -d' + }); + } + if (options['-m'] && options['-r']) { + throw new GitError({ + msg: '-r is incompatible with -m' + }); + } + if (generalArgs.length + (options['-r'] ? options['-r'].length : 0) + + (options['-d'] ? options['-d'].length : 0) === 0) { + throw new GitError({ + msg: 'bookmark name required' }); - return { - vcs: 'git', - name: 'branch' - }; - } else if (options['-d']) { - return { - vcs: 'git', - name: 'branch' - }; - } else if (options['-m']) { - // TODO sid0 -- order is -r - var oldName = options['-m'][0] || ''; - var newName = options['-m'][1] || ''; - return {multiDelegate: [{ - vcs: 'git', - name: 'checkout', - options: { - '-b': [newName, oldName] - } - }, { - vcs: 'git', - name: 'branch', - options: { - '-d': [oldName] - } - }]}; } - return { - vcs: 'git', - name: 'branch' - }; + if (options['-d']) { + options['-D'] = options['-d']; + delete options['-d']; + delegate.name = 'branch'; + } else { + if (options['-r']) { + // we specified a revision with -r but + // need to flip the order + branchName = options['-r'][1] || ''; + rev = options['-r'][0] || ''; + delegate.name = 'branch'; + command.setGeneralArgs([branchName, rev]); + } else if (generalArgs.length > 0) { + command.setSupportedMap({'-b': [generalArgs[0]]}); + delegate.name = 'checkout'; + command.setGeneralArgs([]); + } else { + delegate.name = 'branch'; + } + } + + return delegate; } },