D873: releasenotes: raise error when no filename specified

rishabhmadan96 (Rishabh Madan) phabricator at mercurial-scm.org
Sun Oct 1 11:22:58 UTC 2017


rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Earlier, not specifying filename with --rev raised a really long TypeError.
  This patch just raises a small error to specify the filename.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

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
@@ -440,37 +440,5 @@
   $ hg init relnotes-nofile
   $ cd relnotes-nofile
   $ hg releasenote -r .
-  ** unknown exception encountered, please report by visiting
-  ** https://mercurial-scm.org/wiki/BugTracker
-  ** Python 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
-  ** Mercurial Distributed SCM (version 4.3.3+701-c4594d38b2da+20171001)
-  ** Extensions loaded: releasenotes
-  Traceback (most recent call last):
-    File "/tmp/hgtests.5N93rp/install/bin/hg", line 47, in <module>
-      dispatch.run()
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 81, in run
-      status = (dispatch(req) or 0) & 255
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 163, in dispatch
-      ret = _runcatch(req)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 303, in _runcatch
-      return _callcatch(ui, _runcatchfunc)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 311, in _callcatch
-      return scmutil.callcatch(ui, func)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/scmutil.py", line 151, in callcatch
-      return func()
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 293, in _runcatchfunc
-      return _dispatch(req)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 929, in _dispatch
-      cmdpats, cmdoptions)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 691, in runcommand
-      ret = _runcommand(ui, options, cmd, d)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 937, in _runcommand
-      return cmdfunc()
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/dispatch.py", line 926, in <lambda>
-      d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
-    File "/tmp/hgtests.5N93rp/install/lib/python/mercurial/util.py", line 1180, in check
-      return func(*args, **kwargs)
-    File "/tmp/hgtests.5N93rp/install/lib/python/hgext/releasenotes.py", line 580, in releasenotes
-      with open(file_, 'rb') as fh:
-  TypeError: coercing to Unicode: need string or buffer, NoneType found
-  [1]
+  abort: Specify release notes filename
+  [255]
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -573,6 +573,8 @@
     revs = scmutil.revrange(repo, [rev or 'not public()'])
     if opts.get('check'):
         return checkadmonitions(ui, repo, sections.names(), revs)
+    if opts.get('rev') and file_==None:
+        raise error.Abort(_('Specify release notes filename'))
 
     incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 



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


More information about the Mercurial-devel mailing list