This commit is contained in:
Siddharth Agarwal 2013-08-01 11:52:50 -07:00
parent 3246649cb6
commit f507ceb152
2 changed files with 43 additions and 50 deletions

View file

@ -425,6 +425,7 @@ var commandConfig = {
return;
}
console.log(generalArgs);
command.validateArgBounds(generalArgs, 1, 1);
engine.checkout(engine.crappyUnescape(generalArgs[0]));

View file

@ -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;
var delegate = { vcs: 'git' };
if (options['-m'] && options['-d']) {
throw new GitError({
msg: '-m and -d are incompatible'
});
}
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'
});
}
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] || '';
command.setSupportedMap({
'-b': [branchName, rev]
});
return {
vcs: 'git',
name: 'checkout'
};
} else if (options['-f']) {
// TODO sid0 -- also assuming that
// bookmark -f <REV> <name> is
// the order here
branchName = options['-f'][1] || '';
rev = options['-f'][0] || '';
command.setSupportedMap({
'-f': [branchName, rev]
});
return {
vcs: 'git',
name: 'branch'
};
} else if (options['-d']) {
return {
vcs: 'git',
name: 'branch'
};
} else if (options['-m']) {
// TODO sid0 -- order is -r <oldname> <newname>
var oldName = options['-m'][0] || '';
var newName = options['-m'][1] || '';
return {multiDelegate: [{
vcs: 'git',
name: 'checkout',
options: {
'-b': [newName, oldName]
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';
}
}, {
vcs: 'git',
name: 'branch',
options: {
'-d': [oldName]
}
}]};
}
return {
vcs: 'git',
name: 'branch'
};
return delegate;
}
},