Patchwork D831: releasenotes: raise error on simultaneous usage of flags

login
register
mail settings
Submitter phabricator
Date Sept. 30, 2017, 6:27 a.m.
Message ID <7bc164ae85fd65edd6cef1ca8e8ece93@localhost.localdomain>
Download mbox | patch
Permalink /patch/24225/
State Not Applicable
Headers show

Comments

phabricator - Sept. 30, 2017, 6:27 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG741a511492d3: releasenotes: raise error on simultaneous usage of flags (authored by rishabhmadan96, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D831?vs=2142&id=2168

REVISION DETAIL
  https://phab.mercurial-scm.org/D831

AFFECTED FILES
  hgext/releasenotes.py
  tests/test-releasenotes-formatting.t

CHANGE DETAILS




To: rishabhmadan96, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel

Patch

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 @@ 
   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]
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -552,7 +552,15 @@ 
     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')