# HG changeset patch # User Rishabh Madan # Date 2017-09-28 07:52:58 # Node ID 741a511492d34e074ca5df00dd7309028179f1bb # Parent ec769bba34d377503f42308dea5ddcb8ce4c0ade releasenotes: raise error on simultaneous usage of flags The releasenotes command is supposed to raise an error when --list and --rev/--check flags are used together. This patch adds the above functionality. Differential Revision: https://phab.mercurial-scm.org/D831 diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py --- a/hgext/releasenotes.py +++ b/hgext/releasenotes.py @@ -552,7 +552,15 @@ def releasenotes(ui, repo, file_=None, * release note after it has been added to the release notes file. """ sections = releasenotessections(ui, repo) - if opts.get('list'): + + listflag = opts.get('list') + + if listflag and opts.get('rev'): + raise error.Abort(_('cannot use both \'--list\' and \'--rev\'')) + if listflag and opts.get('check'): + raise error.Abort(_('cannot use both \'--list\' and \'--check\'')) + + if listflag: return _getadmonitionlist(ui, sections) rev = opts.get('rev') diff --git a/tests/test-releasenotes-formatting.t b/tests/test-releasenotes-formatting.t --- a/tests/test-releasenotes-formatting.t +++ b/tests/test-releasenotes-formatting.t @@ -420,3 +420,17 @@ Usage of --list flag fix: Bug Fixes perf: Performance Improvements api: API Changes + + $ cd .. + +Raise error on simultaneous usage of flags + + $ hg init relnotes-raise-error + $ cd relnotes-raise-error + $ hg releasenotes -r . -l + abort: cannot use both '--list' and '--rev' + [255] + + $ hg releasenotes -l -c + abort: cannot use both '--list' and '--check' + [255]