mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 17:00:04 +02:00
mercurial commands fixed with new option parsing logic
This commit is contained in:
parent
1ba46f7705
commit
bf52d640d5
2 changed files with 19 additions and 8 deletions
|
@ -58,7 +58,7 @@ var commandConfig = {
|
||||||
'-r'
|
'-r'
|
||||||
],
|
],
|
||||||
delegate: function(engine, command) {
|
delegate: function(engine, command) {
|
||||||
command.appendOptionR();
|
command.prependOptionR();
|
||||||
var options = command.getOptionsMap();
|
var options = command.getOptionsMap();
|
||||||
if (!options['-r']) {
|
if (!options['-r']) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
|
@ -109,21 +109,21 @@ var commandConfig = {
|
||||||
var branchName;
|
var branchName;
|
||||||
var rev;
|
var rev;
|
||||||
|
|
||||||
var delegate = { vcs: 'git' };
|
var delegate = {vcs: 'git'};
|
||||||
|
|
||||||
if (options['-m'] && options['-d']) {
|
if (options['-m'] && options['-d']) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: '-m and -d are incompatible'
|
msg: intl.todo('-m and -d are incompatible')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (options['-d'] && options['-r']) {
|
if (options['-d'] && options['-r']) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: '-r is incompatible with -d'
|
msg: intl.todo('-r is incompatible with -d')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (options['-m'] && options['-r']) {
|
if (options['-m'] && options['-r']) {
|
||||||
throw new GitError({
|
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) +
|
if (generalArgs.length + (options['-r'] ? options['-r'].length : 0) +
|
||||||
|
@ -140,9 +140,12 @@ var commandConfig = {
|
||||||
if (options['-r']) {
|
if (options['-r']) {
|
||||||
// we specified a revision with -r but
|
// we specified a revision with -r but
|
||||||
// need to flip the order
|
// need to flip the order
|
||||||
branchName = options['-r'][1] || '';
|
var generalArgs = command.getGeneralArgs();
|
||||||
rev = options['-r'][0] || '';
|
branchName = generalArgs[0];
|
||||||
|
rev = options['-r'][0];
|
||||||
delegate.name = 'branch';
|
delegate.name = 'branch';
|
||||||
|
|
||||||
|
// transform to what git wants
|
||||||
command.setGeneralArgs([branchName, rev]);
|
command.setGeneralArgs([branchName, rev]);
|
||||||
} else if (generalArgs.length > 0) {
|
} else if (generalArgs.length > 0) {
|
||||||
command.setOptionsMap({'-b': [generalArgs[0]]});
|
command.setOptionsMap({'-b': [generalArgs[0]]});
|
||||||
|
@ -217,7 +220,7 @@ var commandConfig = {
|
||||||
'-r'
|
'-r'
|
||||||
],
|
],
|
||||||
delegate: function(engine, command) {
|
delegate: function(engine, command) {
|
||||||
command.appendOptionR();
|
command.prependOptionR();
|
||||||
return {
|
return {
|
||||||
vcs: 'git',
|
vcs: 'git',
|
||||||
name: 'revert'
|
name: 'revert'
|
||||||
|
|
|
@ -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() {
|
mapDotToHead: function() {
|
||||||
var generalArgs = this.getGeneralArgs();
|
var generalArgs = this.getGeneralArgs();
|
||||||
var options = this.getOptionsMap();
|
var options = this.getOptionsMap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue