{"record":{"id":"859162d70f24346c","repo":"pcottle/learnGitBranching","slug":"m-and-d-are-incompatible","errorCode":null,"errorMessage":"-m and -d are incompatible","messagePattern":"-m and -d are incompatible","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/mercurial/commands.js","lineNumber":108,"sourceCode":"  },\n\n  bookmark: {\n    regex: /^hg (bookmarks|bookmark|book)($|\\s)/,\n    options: [\n      '-r',\n      '-f',\n      '-d'\n    ],\n    delegate: function(engine, command) {\n      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      }","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/mercurial/commands.js#L90-L126","documentation":"`hg branch` in mercurial mode maps its options onto git's branch machinery, but -m (rename/move) and -d (delete) are mutually exclusive operations on a branch. If the parsed options map contains both, a GitError with intl.todo('-m and -d are incompatible') is thrown before any delegation.","triggerScenarios":"Executing `hg branch` with both -m and -d options in the options map, e.g. `hg branch -m foo -d`.","commonSituations":"Typos or copy-pasted command strings combining flags; automated command builders that concatenate user-chosen options without validating mutual exclusion.","solutions":["Use only one of -m or -d per command","If building commands programmatically, validate that -m and -d are not both set before dispatching","Split the operation into two sequential commands"],"exampleFix":"// before\nhg branch -m old -d\n// after\nhg branch -m old newname\nhg branch -d oldname","handlingStrategy":"validation","validationCode":"function validBranchOpts(o) { return !(o['-m'] && o['-d']); }\nif (!validBranchOpts(command.getOptionsMap())) { reject('pick -m or -d, not both'); }","typeGuard":"function hasExclusiveOpts(o, a, b) {\n  return !(Boolean(o[a]) && Boolean(o[b]));\n}","tryCatchPattern":"try { exec(cmd); } catch (e) { if (e instanceof GitError && /incompatible/.test(e.msg)) { showUsage(); } else throw e; }","preventionTips":["Never combine -m and -d in one hg branch invocation","Validate option exclusivity in command builders before dispatch"],"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"}