{"record":{"id":"c575cd42f7976fa4","repo":"pcottle/learnGitBranching","slug":"r-is-incompatible-with-m","errorCode":null,"errorMessage":"-r is incompatible with -m","messagePattern":"-r is incompatible with -m","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/mercurial/commands.js","lineNumber":118,"sourceCode":"      var options = command.getOptionsMap();\n      var generalArgs = command.getGeneralArgs();\n      var branchName;\n      var rev;\n\n      var delegate = {vcs: 'git'};\n\n      if (options['-m'] && options['-d']) {\n        throw new GitError({\n          msg: intl.todo('-m and -d are incompatible')\n        });\n      }\n      if (options['-d'] && options['-r']) {\n        throw new GitError({\n          msg: intl.todo('-r is incompatible with -d')\n        });\n      }\n      if (options['-m'] && options['-r']) {\n        throw new GitError({\n          msg: intl.todo('-r is incompatible with -m')\n        });\n      }\n      if (generalArgs.length + (options['-r'] ? options['-r'].length : 0) +\n          (options['-d'] ? options['-d'].length : 0) === 0) {\n        delegate.name = 'branch';\n        return delegate;\n      }\n\n      if (options['-d']) {\n        options['-D'] = options['-d'];\n        delete options['-d'];\n        delegate.name = 'branch';\n      } else {\n        if (options['-r']) {\n          // we specified a revision with -r but\n          // need to flip the order\n          generalArgs = command.getGeneralArgs();","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/mercurial/commands.js#L100-L136","documentation":"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.","triggerScenarios":"Executing `hg branch` with both -m and -r in the options map.","commonSituations":"Mirroring real-hg syntax where some commands accept -r; combining flags while experimenting in hg mode.","solutions":["Remove -r when renaming; supply the new name as a general argument","Sanity-check flag combinations if commands are generated programmatically"],"exampleFix":"// before\nhg branch -m -r .\n// after\nhg branch -m oldname newname","handlingStrategy":"validation","validationCode":"if (options['-m'] && options['-r']) { reject('drop -r when renaming (-m)'); }","typeGuard":null,"tryCatchPattern":"try { exec(cmd); } catch (e) { if (e instanceof GitError) { showMsg(e.msg); } else throw e; }","preventionTips":["Pass old/new names as positional args when renaming","Don't carry over -r flags from other hg subcommands"],"tags":["mercurial","hg-branch","mutually-exclusive-options"],"backgroundTag":"conflicting-command-options","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}