pcottle/learnGitBranching · error · GitError
-r is incompatible with -m
Error message
-r is incompatible with -m
What it means
The third mutual-exclusion check in the `hg branch` shim: -m (rename) combined with -r (rev) throws intl.todo('-r is incompatible with -m'). Renaming a branch takes old/new names, not a revision, so the combination is rejected before delegating to git's branch command.
Source
Thrown at src/js/mercurial/commands.js:118
var options = command.getOptionsMap();
var generalArgs = command.getGeneralArgs();
var branchName;
var rev;
var delegate = {vcs: 'git'};
if (options['-m'] && options['-d']) {
throw new GitError({
msg: intl.todo('-m and -d are incompatible')
});
}
if (options['-d'] && options['-r']) {
throw new GitError({
msg: intl.todo('-r is incompatible with -d')
});
}
if (options['-m'] && options['-r']) {
throw new GitError({
msg: intl.todo('-r is incompatible with -m')
});
}
if (generalArgs.length + (options['-r'] ? options['-r'].length : 0) +
(options['-d'] ? options['-d'].length : 0) === 0) {
delegate.name = 'branch';
return delegate;
}
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
generalArgs = command.getGeneralArgs();View on GitHub (pinned to 5b09d0ff96)
Solutions
- Remove -r when renaming; supply the new name as a general argument
- Sanity-check flag combinations if commands are generated programmatically
Example fix
// before hg branch -m -r . // after hg branch -m oldname newname
Defensive patterns
Strategy: validation
Validate before calling
if (options['-m'] && options['-r']) { reject('drop -r when renaming (-m)'); } Try / catch
try { exec(cmd); } catch (e) { if (e instanceof GitError) { showMsg(e.msg); } else throw e; } Prevention
- Pass old/new names as positional args when renaming
- Don't carry over -r flags from other hg subcommands
When it happens
Trigger: Executing `hg branch` with both -m and -r in the options map.
Common situations: Mirroring real-hg syntax where some commands accept -r; combining flags while experimenting in hg mode.
Related errors
- -m and -d are incompatible
- -r is incompatible with -d
- hg-error-no-status
- hg-error-log-no-follow
- git-error-options
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/c575cd42f7976fa4.
Report an issue: GitHub.