D2255: releasenotes: replace abort with warning while parsing (issue5775)

2018-03-07 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG658ed9c7442b: releasenotes: replace abort with warning 
while parsing (issue5775) (authored by rishabhmadan96, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2255?vs=6590=6694

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

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

CHANGE DETAILS

diff --git a/tests/test-releasenotes-parsing.t 
b/tests/test-releasenotes-parsing.t
--- a/tests/test-releasenotes-parsing.t
+++ b/tests/test-releasenotes-parsing.t
@@ -177,3 +177,26 @@
   paragraph: Bullet item 1
 bullet point:
   paragraph: Bullet item 2
+
+Warn user in case of unexpected block while parsing
+
+  $ hg init relnotes-warn
+  $ cd relnotes-warn
+  $ touch feature1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. feature::
+  > 
+  >new feature added.
+  > some words about the feature.
+  > EOF
+
+  $ hg releasenote -r .
+  unexpected block in release notes directive feature
+  New Features
+  
+  
+  * new feature added.  some words about the feature.
+
+  $ cd ..
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -325,8 +325,8 @@
 continue
 
 if pblock['type'] != 'paragraph':
-raise error.Abort(_('unexpected block in release notes '
-'directive %s') % directive)
+repo.ui.warn(_('unexpected block in release notes '
+'directive %s\n') % directive)
 
 if pblock['indent'] > 0:
 paragraphs.append(pblock['lines'])



To: rishabhmadan96, #hg-reviewers, durin42
Cc: durin42, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2254: releasenotes: allow notes for multiple directives in a single changeset

2018-03-07 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa5891e94bfe1: releasenotes: allow notes for multiple 
directives in a single changeset (authored by rishabhmadan96, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2254?vs=6592=6695

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

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
@@ -457,3 +457,35 @@
   --
   
   First paragraph of fix 1.
+
+  $ cd ..
+
+Using multiple admonitions in same changeset
+
+  $ hg init relnotes-multiadmon
+  $ cd relnotes-multiadmon
+
+  $ touch file1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. feature::
+  > 
+  >Details about new feature.
+  > 
+  > .. perf::
+  > 
+  >Improves the execution by 2x
+  > EOF
+
+  $ hg releasenotes -r . $TESTTMP/relnotes-multiple-admonitions
+  $ cat $TESTTMP/relnotes-multiple-admonitions
+  New Features
+  
+  
+  * Details about new feature.
+  
+  Performance Improvements
+  
+  
+  * Improves the execution by 2x
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -324,6 +324,9 @@
 if pblock['type'] == 'margin':
 continue
 
+if pblock['type'] == 'admonition':
+break
+
 if pblock['type'] != 'paragraph':
 repo.ui.warn(_('changeset %s: unexpected block in release '
 'notes directive %s\n') % (ctx, directive))



To: rishabhmadan96, #hg-reviewers, durin42
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2253: releasenotes: mention changeset with warning and abort

2018-03-07 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3fff6f30bd7f: releasenotes: mention changeset with warning 
and abort (authored by rishabhmadan96, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2253?vs=6591=6693

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

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

CHANGE DETAILS

diff --git a/tests/test-releasenotes-parsing.t 
b/tests/test-releasenotes-parsing.t
--- a/tests/test-releasenotes-parsing.t
+++ b/tests/test-releasenotes-parsing.t
@@ -193,7 +193,7 @@
   > EOF
 
   $ hg releasenote -r .
-  unexpected block in release notes directive feature
+  changeset a4251905c440: unexpected block in release notes directive feature
   New Features
   
   
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -311,8 +311,8 @@
 title = block['lines'][0].strip() if block['lines'] else None
 
 if i + 1 == len(blocks):
-raise error.Abort(_('release notes directive %s lacks content')
-  % directive)
+raise error.Abort(_('changeset %s: release notes directive %s '
+'lacks content') % (ctx, directive))
 
 # Now search ahead and find all paragraphs attached to this
 # admonition.
@@ -325,8 +325,8 @@
 continue
 
 if pblock['type'] != 'paragraph':
-repo.ui.warn(_('unexpected block in release notes '
-'directive %s\n') % directive)
+repo.ui.warn(_('changeset %s: unexpected block in release '
+'notes directive %s\n') % (ctx, directive))
 
 if pblock['indent'] > 0:
 paragraphs.append(pblock['lines'])



To: rishabhmadan96, #hg-reviewers, durin42
Cc: av6, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2254: releasenotes: allow notes for multiple directives in a single changeset

2018-03-04 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 6592.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2254?vs=5694=6592

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

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
@@ -457,3 +457,35 @@
   --
   
   First paragraph of fix 1.
+
+  $ cd ..
+
+Using multiple admonitions in same changeset
+
+  $ hg init relnotes-multiadmon
+  $ cd relnotes-multiadmon
+
+  $ touch file1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. feature::
+  > 
+  >Details about new feature.
+  > 
+  > .. perf::
+  > 
+  >Improves the execution by 2x
+  > EOF
+
+  $ hg releasenotes -r . $TESTTMP/relnotes-multiple-admonitions
+  $ cat $TESTTMP/relnotes-multiple-admonitions
+  New Features
+  
+  
+  * Details about new feature.
+  
+  Performance Improvements
+  
+  
+  * Improves the execution by 2x
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -324,6 +324,9 @@
 if pblock['type'] == 'margin':
 continue
 
+if pblock['type'] == 'admonition':
+break
+
 if pblock['type'] != 'paragraph':
 repo.ui.warn(_('changeset %s: unexpected block in release '
 'notes directive %s\n') % (ctx, directive))



To: rishabhmadan96, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2255: releasenotes: replace abort with warning while parsing (issue5775)

2018-03-04 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 6590.
rishabhmadan96 edited the summary of this revision.
rishabhmadan96 retitled this revision from "releasenotes: replace abort with 
warning while parsing" to "releasenotes: replace abort with warning while 
parsing (issue5775)".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2255?vs=5695=6590

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

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

CHANGE DETAILS

diff --git a/tests/test-releasenotes-parsing.t 
b/tests/test-releasenotes-parsing.t
--- a/tests/test-releasenotes-parsing.t
+++ b/tests/test-releasenotes-parsing.t
@@ -177,3 +177,26 @@
   paragraph: Bullet item 1
 bullet point:
   paragraph: Bullet item 2
+
+Warn user in case of unexpected block while parsing
+
+  $ hg init relnotes-warn
+  $ cd relnotes-warn
+  $ touch feature1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. feature::
+  > 
+  >new feature added.
+  > some words about the feature.
+  > EOF
+
+  $ hg releasenote -r .
+  unexpected block in release notes directive feature
+  New Features
+  
+  
+  * new feature added.  some words about the feature.
+
+  $ cd ..
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -325,8 +325,8 @@
 continue
 
 if pblock['type'] != 'paragraph':
-raise error.Abort(_('unexpected block in release notes '
-'directive %s') % directive)
+repo.ui.warn(_('unexpected block in release notes '
+'directive %s\n') % directive)
 
 if pblock['indent'] > 0:
 paragraphs.append(pblock['lines'])



To: rishabhmadan96, #hg-reviewers
Cc: durin42, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2253: releasenotes: mention changeset with warning and abort

2018-03-04 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 6591.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2253?vs=5693=6591

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

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

CHANGE DETAILS

diff --git a/tests/test-releasenotes-parsing.t 
b/tests/test-releasenotes-parsing.t
--- a/tests/test-releasenotes-parsing.t
+++ b/tests/test-releasenotes-parsing.t
@@ -193,7 +193,7 @@
   > EOF
 
   $ hg releasenote -r .
-  unexpected block in release notes directive feature
+  changeset a4251905c440: unexpected block in release notes directive feature
   New Features
   
   
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -311,8 +311,8 @@
 title = block['lines'][0].strip() if block['lines'] else None
 
 if i + 1 == len(blocks):
-raise error.Abort(_('release notes directive %s lacks content')
-  % directive)
+raise error.Abort(_('changeset %s: release notes directive %s '
+'lacks content') % (ctx, directive))
 
 # Now search ahead and find all paragraphs attached to this
 # admonition.
@@ -325,8 +325,8 @@
 continue
 
 if pblock['type'] != 'paragraph':
-repo.ui.warn(_('unexpected block in release notes '
-'directive %s\n') % directive)
+repo.ui.warn(_('changeset %s: unexpected block in release '
+'notes directive %s\n') % (ctx, directive))
 
 if pblock['indent'] > 0:
 paragraphs.append(pblock['lines'])



To: rishabhmadan96, #hg-reviewers
Cc: av6, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2255: releasenotes: replace abort with warning while parsing

2018-03-04 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  I totally forgot about this. I'll send them right away.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers
Cc: durin42, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-02-22 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  It'd be better if you could update the commit message with the necessary 
details that you mentioned in your previous comment.

REPOSITORY
  rHG Mercurial

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

To: sangeet259, durin42, #hg-reviewers
Cc: rishabhmadan96, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2255: releasenotes: replace abort with warning while parsing

2018-02-14 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  Yeah, my bad. I'll send an updated version with the suggested changes.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2253: releasenotes: mention changeset with warning and abort

2018-02-13 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Output the changeset hash with the warning/abort message just to know where 
things messed up.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -311,8 +311,8 @@
 title = block['lines'][0].strip() if block['lines'] else None
 
 if i + 1 == len(blocks):
-raise error.Abort(_('release notes directive %s lacks content')
-  % directive)
+raise error.Abort(_('changeset %s: release notes directive %s '
+'lacks content') % (node.hex(ctx.node()), directive))
 
 # Now search ahead and find all paragraphs attached to this
 # admonition.
@@ -325,8 +325,8 @@
 continue
 
 if pblock['type'] != 'paragraph':
-repo.ui.warn(_('unexpected block in release notes '
-'directive %s\n') % directive)
+repo.ui.warn(_('changeset %s: unexpected block in release '
+'notes directive %s\n') % (node.hex(ctx.node()), 
directive))
 
 if pblock['indent'] > 0:
 paragraphs.append(pblock['lines'])



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2254: releasenotes: allow notes for multiple directives in a single changeset

2018-02-13 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This problem was caught in 
https://phab.mercurial-scm.org/rHGda91e7309daf8ffc51bf3e6f4b2d8a16ef5af95a. 
This patch just makes sure there is no warning when we
  encounter such a case.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -324,6 +324,9 @@
 if pblock['type'] == 'margin':
 continue
 
+if pblock['type'] == 'admonition':
+break
+
 if pblock['type'] != 'paragraph':
 repo.ui.warn(_('changeset %s: unexpected block in release '
 'notes directive %s\n') % (node.hex(ctx.node()), 
directive))



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2255: releasenotes: replace abort with warning while parsing

2018-02-13 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  During the 4.5 development cycle, the extension broke on two different 
changesets. This change
  simply makes sure that it just throws a warning when encounters something 
instead of an abort
  action.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -325,8 +325,8 @@
 continue
 
 if pblock['type'] != 'paragraph':
-raise error.Abort(_('unexpected block in release notes '
-'directive %s') % directive)
+repo.ui.warn(_('unexpected block in release notes '
+'directive %s\n') % directive)
 
 if pblock['indent'] > 0:
 paragraphs.append(pblock['lines'])



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D877: releasenotes: display release notes when no filename is specified

2017-10-01 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG159a6f7e09a9: releasenotes: display release notes when no 
filename is specified (authored by rishabhmadan96, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D877?vs=2263=2289#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D877?vs=2263=2289

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

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
@@ -434,3 +434,26 @@
   $ hg releasenotes -l -c
   abort: cannot use both '--list' and '--check'
   [255]
+
+Display release notes for specified revs if no file is mentioned
+
+  $ hg init relnotes-nofile
+  $ cd relnotes-nofile
+
+  $ touch fix1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. fix:: Title of First Fix
+  > 
+  >First paragraph of fix 1.
+  > EOF
+
+  $ hg releasenote -r .
+  Bug Fixes
+  =
+  
+  Title of First Fix
+  --
+  
+  First paragraph of fix 1.
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -576,6 +576,9 @@
 
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
+if file_ is None:
+return ui.write(serializenotes(sections, incoming))
+
 try:
 with open(file_, 'rb') as fh:
 notes = parsereleasenotesfile(sections, fh.read())



To: rishabhmadan96, #hg-reviewers, pulkit, yuja
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D877: releasenotes: display release notes when no filename is specified

2017-10-01 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 2263.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D877?vs=2261=2263

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

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
@@ -435,42 +435,25 @@
   abort: cannot use both '--list' and '--check'
   [255]
 
-Raise error when no filename is specified with --rev
+Display release notes for specified revs if no file is mentioned
 
   $ hg init relnotes-nofile
   $ cd relnotes-nofile
+
+  $ touch fix1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. fix:: Title of First Fix
+  > 
+  >First paragraph of fix 1.
+  > EOF
+
   $ 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 
-  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 
-  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]
+  Bug Fixes
+  =
+  
+  Title of First Fix
+  --
+  
+  First paragraph of fix 1.
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -576,6 +576,9 @@
 
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
+if file_ is None:
+return ui.write(serializenotes(sections, incoming))
+
 try:
 with open(file_, 'rb') as fh:
 notes = parsereleasenotesfile(sections, fh.read())



To: rishabhmadan96, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D877: releasenotes: display release notes when no filename is specified

2017-10-01 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If the filename is not specified while using --rev, the notes for the 
specified
  revs will just be displayed on screen.

REPOSITORY
  rHG Mercurial

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

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
@@ -435,42 +435,25 @@
   abort: cannot use both '--list' and '--check'
   [255]
 
-Raise error when no filename is specified with --rev
+Display release notes for specified revs if no file is mentioned
 
   $ hg init relnotes-nofile
   $ cd relnotes-nofile
+
+  $ touch fix1
+  $ hg -q commit -A -l - << EOF
+  > commit 1
+  > 
+  > .. fix:: Title of First Fix
+  > 
+  >First paragraph of fix 1.
+  > EOF
+
   $ 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 
-  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 
-  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]
+  Bug Fixes
+  =
+  
+  Title of First Fix
+  --
+  
+  First paragraph of fix 1.
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -576,6 +576,9 @@
 
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
+if file_==None:
+return ui.write(serializenotes(sections, incoming))
+
 try:
 with open(file_, 'rb') as fh:
 notes = parsereleasenotesfile(sections, fh.read())



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D873: releasenotes: raise error when no filename specified

2017-10-01 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  In https://phab.mercurial-scm.org/D873#14703, @pulkit wrote:
  
  > Can't we just output the releasenotes using ui.write() if no file name is 
specified. I sometimes wanted to check what releasenotes my commit will produce 
and I needed to mention a file.
  
  
  Seems to be a good idea :). Maybe we can close this one and I'll just send a 
new patch right away.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D873: releasenotes: raise error when no filename specified

2017-10-01 Thread rishabhmadan96 (Rishabh Madan)
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 
-  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 
-  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
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D872: releasenotes: add test showing TypeError with no file specified

2017-10-01 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The releasenotes command throws a TypeError when no filename is specified with
  the --rev flag.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  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
@@ -434,3 +434,43 @@
   $ hg releasenotes -l -c
   abort: cannot use both '--list' and '--check'
   [255]
+
+Raise error when no filename is specified with --rev
+
+  $ 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 
+  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 
+  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]



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D831: releasenotes: raise error on simultaneous usage of flags

2017-09-30 Thread rishabhmadan96 (Rishabh Madan)
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=2168

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

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
@@ -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')



To: rishabhmadan96, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D544: releasenotes: update docstrings with information on additional flags

2017-09-30 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG01e8ab4b6573: releasenotes: update docstrings with 
information on additional flags (authored by rishabhmadan96, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D544?vs=2047=2169#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D544?vs=2047=2169

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -550,6 +550,12 @@
 this command and changes should not be lost when running this command on
 that file. A particular use case for this is to tweak the wording of a
 release note after it has been added to the release notes file.
+
+The -c/--check option checks the commit message for invalid admonitions.
+
+The -l/--list option, presents the user with a list of existing available
+admonitions along with their title. This also includes the custom
+admonitions (if any).
 """
 sections = releasenotessections(ui, repo)
 



To: rishabhmadan96, #hg-reviewers, krbullock, yuja
Cc: yuja, krbullock, dsp, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D831: releasenotes: raise error on simultaneous usage of flags

2017-09-28 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 2142.

REPOSITORY
  rHG Mercurial

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

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

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
@@ -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')



To: rishabhmadan96, #hg-reviewers
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D831: releasenotes: raise error on simultaneous usage of flags

2017-09-28 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The releasenotes command is supposed to raise an error when --list and
  --rev/--check flags are used together. This patch adds the above 
functionality.

REPOSITORY
  rHG Mercurial

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

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
@@ -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 '--rev' and '--list'
+  [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,6 +552,12 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+
+if opts.get('list') and opts.get('rev'):
+raise error.Abort(_('cannot use both \'--rev\' and \'--list\''))
+if opts.get('list') and opts.get('check'):
+raise error.Abort(_('cannot use both \'--list\' and \'--check\''))
+
 if opts.get('list'):
 return _getadmonitionlist(ui, sections)
 



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D544: releasenotes: update docstrings with information on additional flags

2017-09-22 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 2047.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D544?vs=1690=2047

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -550,6 +550,12 @@
 this command and changes should not be lost when running this command on
 that file. A particular use case for this is to tweak the wording of a
 release note after it has been added to the release notes file.
+
+The -c/--check option checks the commit message for invalid admonitions.
+
+The -l/--list option, presents the user with a list of existing available
+admonitions along with their title. This also includes the custom
+admonitions (if any).
 """
 sections = releasenotessections(ui, repo)
 if opts.get('list'):



To: rishabhmadan96, #hg-reviewers, krbullock
Cc: krbullock, dsp, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D544: releasenotes: update docstrings with information on additional flags

2017-09-10 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 1690.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D544?vs=1368=1690

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -550,6 +550,33 @@
 this command and changes should not be lost when running this command on
 that file. A particular use case for this is to tweak the wording of a
 release note after it has been added to the release notes file.
+
+The -c/--check option checks the commit message for invalid admonitions.
+In case of an invalid admonition, the flag returns the name of admonition
+along with the changeset ID. For example::
+
+   .. abcd::
+
+  First paragraph under this admonition
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+If an invalid admonition is similar to the available admonitions upto
+a certain threshold, the correct admonition will be suggested.
+For example::
+
+   .. fixes::
+
+  Fixes issue1234
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'fixes' present in changeset 687be3ff87c6
+(did you mean fix?)
+
+The -l/--list option, presents the user with a list of existing available
+admonitions along with their title. This also includes the custom
+admonitions (if any).
 """
 sections = releasenotessections(ui, repo)
 if opts.get('list'):



To: rishabhmadan96, #hg-reviewers
Cc: dsp, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D544: releasenotes: update docstrings with information on additional flags

2017-09-10 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added inline comments.

INLINE COMMENTS

> dsp wrote in releasenotes.py:554
> I think we usually don't address "you" directly. Maybe something like
> 
>   The -c/--check option checks the commit message for invalid admonitions. In 
> case of an invalid admonition, the flag returns the name of admonition along 
> with the changeset ID. For example::

I referred the patchbomb.py file while writing this part, and it made use of 
'you' and 'your'.
But I guess it's okay to have it without usage of 'you'. So I'll make the 
changes here.

> dsp wrote in releasenotes.py:563
> I think the colon at the end is invalid.

My bad! I'll correct this one.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers
Cc: dsp, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D544: releasenotes: update docstrings with information on additional flags

2017-08-28 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 1368.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D544?vs=1358=1368

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -550,6 +550,32 @@
 this command and changes should not be lost when running this command on
 that file. A particular use case for this is to tweak the wording of a
 release note after it has been added to the release notes file.
+
+With the -c/--check option, you can check the commit message for an invalid
+admonition. In case of an invalid admonition, the flag returns the name of
+admonition along with the changeset ID. For example::
+
+   .. abcd::
+
+  First paragraph under this admonition
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103:
+
+Incase the invalid admonition is similar to the available admonitions upto
+a certain threshold it suggests the correct admonition to you. For 
example::
+
+   .. fixes::
+
+  Fixes issue1234
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'fixes' present in changeset 687be3ff87c6
+(did you mean fix?)
+
+With the -l/--list option, you will be presented with a list of the
+existing available admonitions along with their title. This also includes
+the custom admonitions (if any).
 """
 sections = releasenotessections(ui, repo)
 if opts.get('list'):



To: rishabhmadan96, #hg-reviewers
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D545: releasenotes: update docstrings with information on additional flags

2017-08-28 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds documentation related to the two new flags --check and
  --list for releasenotes extension.
  
  https://phab.mercurial-scm.org/D544

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -550,6 +550,32 @@
 this command and changes should not be lost when running this command on
 that file. A particular use case for this is to tweak the wording of a
 release note after it has been added to the release notes file.
+
+With the -c/--check option, you can check the commit message for an invalid
+admonition. In case of an invalid admonition, the flag returns the name of
+admonition along with the changeset ID. For example::
+
+   .. abcd::
+
+  First paragraph under this admonition
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103:
+
+Incase the invalid admonition is similar to the available admonitions upto
+a certain threshold it suggests the correct admonition to you. For 
example::
+
+   .. fixes::
+
+  Fixes issue1234
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'fixes' present in changeset 687be3ff87c6
+(did you mean fix?)
+
+With the -l/--list option, you will be presented with a list of the
+existing available admonitions along with their title. This also includes
+the custom admonitions (if any).
 """
 sections = releasenotessections(ui, repo)
 if opts.get('list'):



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D544: releasenotes: update docstrings with information on additional flags

2017-08-28 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds documentation related to the two new flags --check and
  --list for releasenotes extension.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -550,6 +550,31 @@
 this command and changes should not be lost when running this command on
 that file. A particular use case for this is to tweak the wording of a
 release note after it has been added to the release notes file.
+
+With -c/--check option, you can check the commit message for any invalid
+admonition. In case of an invalid admonition, the flag returns the name
+of admonition along with the changeset ID. Incase the incorrect admonition
+is similar to the available admonitions upto a certain threshold, it
+suggests the correct admonition to you.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+.. fixes::
+
+   Fixes issue1234
+
+For the above commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'fixes' present in changeset 687be3ff87c6
+(did you mean fix?)
+
+With -l/--list option, you will be presented with a list of the existing
+available admonitions along with their title. This also includes the
+custom admonitions (if any).
 """
 sections = releasenotessections(ui, repo)
 if opts.get('list'):



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D454: releasenotes: view admonition titles using -l flag

2017-08-28 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2a37459aedf2: releasenotes: view admonition titles using -l 
flag (authored by rishabhmadan96).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D454?vs=1331=1352

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

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
@@ -407,3 +407,16 @@
   $ hg releasenotes -r . -c
   Invalid admonition 'fixes' present in changeset 0e7130d2705c
   (did you mean fix?)
+
+  $ cd ..
+
+Usage of --list flag
+
+  $ hg init relnotes-list
+  $ cd relnotes-list
+  $ hg releasenotes -l
+  feature: New Features
+  bc: Backwards Compatibility Changes
+  fix: Bug Fixes
+  perf: Performance Improvements
+  api: API Changes
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -275,6 +275,10 @@
 ss = ", ".join(sorted(similar))
 ui.write(_("(did you mean one of %s?)\n") % ss)
 
+def _getadmonitionlist(ui, sections):
+for section in sections:
+ui.write("%s: %s\n" % (section[0], section[1]))
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -467,7 +471,9 @@
 @command('releasenotes',
 [('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
 ('c', 'check', False, _('checks for validity of admonitions (if any)'),
-_('REV'))],
+_('REV')),
+('l', 'list', False, _('list the available admonitions with their title'),
+None)],
 _('hg releasenotes [-r REV] [-c] FILE'))
 def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
@@ -546,8 +552,10 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+if opts.get('list'):
+return _getadmonitionlist(ui, sections)
+
 rev = opts.get('rev')
-
 revs = scmutil.revrange(repo, [rev or 'not public()'])
 if opts.get('check'):
 return checkadmonitions(ui, repo, sections.names(), revs)



To: rishabhmadan96, #hg-reviewers, pulkit, yuja
Cc: yuja, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D454: releasenotes: view admonition titles using -l flag

2017-08-27 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 1331.
rishabhmadan96 edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D454?vs=1123=1331

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

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
@@ -407,3 +407,16 @@
   $ hg releasenotes -r . -c
   Invalid admonition 'fixes' present in changeset 0e7130d2705c
   (did you mean fix?)
+
+  $ cd ..
+
+Usage of --list flag
+
+  $ hg init relnotes-list
+  $ cd relnotes-list
+  $ hg releasenotes -l
+  feature: New Features
+  bc: Backwards Compatibility Changes
+  fix: Bug Fixes
+  perf: Performance Improvements
+  api: API Changes
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -275,6 +275,10 @@
 ss = ", ".join(sorted(similar))
 ui.write(_("(did you mean one of %s?)\n") % ss)
 
+def _getadmonitionlist(ui, sections):
+for section in sections:
+ui.write("%s: %s\n" % (section[0], section[1]))
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -467,7 +471,9 @@
 @command('releasenotes',
 [('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
 ('c', 'check', False, _('checks for validity of admonitions (if any)'),
-_('REV'))],
+_('REV')),
+('l', 'list', False, _('list the available admonitions with their title'),
+None)],
 _('hg releasenotes [-r REV] [-c] FILE'))
 def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
@@ -546,8 +552,10 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+if opts.get('list'):
+return _getadmonitionlist(ui, sections)
+
 rev = opts.get('rev')
-
 revs = scmutil.revrange(repo, [rev or 'not public()'])
 if opts.get('check'):
 return checkadmonitions(ui, repo, sections.names(), revs)



To: rishabhmadan96, #hg-reviewers, pulkit, yuja
Cc: yuja, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D454: releasenotes: view admonition titles using -l flag

2017-08-27 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  In https://phab.mercurial-scm.org/D454#8571, @pulkit wrote:
  
  > @rishabhmadan96 Also make sure a user cannot pass any other flag with the 
`--list` flag.
  
  
  I'm using `return` while calling the function. Wouldn't that be enough for 
this?

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers, pulkit, yuja
Cc: yuja, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D368: releasenotes: add check flag for use of admonitions and its validity

2017-08-23 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6a49c74b1e8f: releasenotes: add check flag for use of 
admonitions and its validity (authored by rishabhmadan96).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D368?vs=973=1200#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D368?vs=973=1200

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

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
@@ -378,3 +378,32 @@
   
   * Adds a new feature.
 
+  $ cd ..
+
+Testing output for the --check (-c) flag
+
+  $ hg init check-flag
+  $ cd check-flag
+
+  $ touch a
+  $ hg -q commit -A -l - << EOF
+  > .. asf::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+Suggest similar admonition in place of the invalid one.
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+
+  $ touch b
+  $ hg -q commit -A -l - << EOF
+  > .. fixes::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  (did you mean fix?)
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -13,6 +13,7 @@
 
 from __future__ import absolute_import
 
+import difflib
 import errno
 import re
 import sys
@@ -242,6 +243,38 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def checkadmonitions(ui, repo, directives, revs):
+"""
+Checks the commit messages for admonitions and their validity.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For this commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+As admonition 'abcd' is neither present in default nor custom admonitions
+"""
+for rev in revs:
+ctx = repo[rev]
+admonition = re.search(RE_DIRECTIVE, ctx.description())
+if admonition:
+if admonition.group(1) in directives:
+continue
+else:
+ui.write(_("Invalid admonition '%s' present in changeset %s"
+   "\n") % (admonition.group(1), ctx.hex()[:12]))
+sim = lambda x: difflib.SequenceMatcher(None,
+admonition.group(1), x).ratio()
+
+similar = [s for s in directives if sim(s) > 0.6]
+if len(similar) == 1:
+ui.write(_("(did you mean %s?)\n") % similar[0])
+elif similar:
+ss = ", ".join(sorted(similar))
+ui.write(_("(did you mean one of %s?)\n") % ss)
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +465,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('c', 'check', False, _('checks for validity of admonitions (if any)'),
+_('REV'))],
+_('hg releasenotes [-r REV] [-c] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,8 +546,12 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
+if opts.get('check'):
+return checkadmonitions(ui, repo, sections.names(), revs)
+
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
 try:



To: rishabhmadan96, #hg-reviewers, durin42, krbullock
Cc: krbullock, quark, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D454: releasenotes: view admonition titles using -l flag

2017-08-21 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 1123.
rishabhmadan96 edited the summary of this revision.
rishabhmadan96 retitled this revision from "releasenotes: view admonition 
titles using -a flag" to "releasenotes: view admonition titles using -l flag".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D454?vs=1106=1123

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

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
@@ -378,3 +378,15 @@
   
   * Adds a new feature.
 
+  $ cd ..
+
+Usage of --list flag
+
+  $ hg init relnotes-list
+  $ cd relnotes-list
+  $ hg releasenotes -l
+  feature: New Features
+  bc: Backwards Compatibility Changes
+  fix: Bug Fixes
+  perf: Performance Improvements
+  api: API Changes
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -242,6 +242,10 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def _getadmonitionlist(ui, sections):
+for section in sections._sections:
+ui.write(_(str(section[0]) + ": " + section[1] + "\n"))
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +436,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('l', 'list', False, _('list the available admonitions with their title'),
+None)],
+_('hg releasenotes [-r REV] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,6 +517,10 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+if opts.get('list'):
+return _getadmonitionlist(ui, sections)
+
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)



To: rishabhmadan96, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D454: releasenotes: view admonition titles using -a flag

2017-08-21 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added inline comments.

INLINE COMMENTS

> pulkit wrote in releasenotes.py:475
> I am not sure whether `-a` is the best choice of flag. Maybe we can have `-l` 
> and `--list`.
> 
> Also the help can be improved to "list the available admonitions with their 
> title".

`--list` sounds good to me. I'll make the changes.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers, pulkit
Cc: pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D454: releasenotes: view admonition titles using -a flag

2017-08-20 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Since this extension is fairly new for almost all the contributors, 
remembering
  the admonition (with titles) is difficult. The admonition (-a) flag provides
  a list of all the active admonitions along with titles.
  
  For usage, `hg releasenotes -a` returns the list.

REPOSITORY
  rHG Mercurial

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

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
@@ -407,3 +407,12 @@
   $ hg releasenotes -r . -c
   Invalid admonition 'fixes' present in changeset 0e7130d2705c
   (did you mean fix?)
+
+Usage of --admonition flag
+
+  $ hg releasenotes -a
+  feature: New Features
+  bc: Backwards Compatibility Changes
+  fix: Bug Fixes
+  perf: Performance Improvements
+  api: API Changes
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -275,6 +275,10 @@
 ss = ", ".join(sorted(similar))
 ui.write(_("(did you mean one of %s?)\n") % ss)
 
+def getadmonitionlist(ui, sections):
+for section in sections._sections:
+ui.write(_(str(section[0]) + ": " + section[1] + "\n"))
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -467,7 +471,8 @@
 @command('releasenotes',
 [('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
 ('c', 'check', False, _('checks for validity of admonitions (if any)'),
-_('REV'))],
+_('REV')),
+('a', 'admonition', False, _('returns admonition and its title'), None)],
 _('hg releasenotes [-r REV] [-c] FILE'))
 def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
@@ -546,6 +551,9 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+if opts.get('admonition'):
+return getadmonitionlist(ui, sections)
+
 rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D368: releasenotes: add check flag for use of admonitions and its validity

2017-08-15 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  Sorry I just edited the revision string. Will that work? Or should I update 
it again with "Differential Revision: https://phab.mercurial-scm.org/D368; at 
the end.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers, durin42
Cc: quark, durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D368: Differential Revision: https://phab.mercurial-scm.org/D368releasenotes: add check flag for use of admonitions and its validity

2017-08-15 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 updated this revision to Diff 973.
rishabhmadan96 retitled this revision from "releasenotes: add check flag for 
use of admonitions and its validity" to "Differential Revision: 
https://phab.mercurial-scm.org/D368
releasenotes: add check flag for use of admonitions and its validity".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D368?vs=846=973

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

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
@@ -378,3 +378,32 @@
   
   * Adds a new feature.
 
+  $ cd ..
+
+Testing output for the --check (-c) flag
+
+  $ hg init check-flag
+  $ cd check-flag
+
+  $ touch a
+  $ hg -q commit -A -l - << EOF
+  > .. asf::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+Suggest similar admonition in place of the invalid one.
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+
+  $ touch b
+  $ hg -q commit -A -l - << EOF
+  > .. fixes::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  (did you mean fix?)
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -13,6 +13,7 @@
 
 from __future__ import absolute_import
 
+import difflib
 import errno
 import re
 import sys
@@ -242,6 +243,39 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def checkadmonitions(ui, repo, directives, revs):
+"""
+Checks the commit messages for admonitions and their validity.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For this commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+As admonition 'abcd' is neither present in default nor custom admonitions
+"""
+for rev in revs:
+ctx = repo[rev]
+admonition = re.search(RE_DIRECTIVE, ctx.description())
+if admonition:
+if admonition.group(1) in directives:
+continue
+else:
+ui.write(_("Invalid admonition '%s' present in changeset %s"
+   "\n") % (admonition.group(1), ctx.hex()[:12]))
+sim = lambda x: difflib.SequenceMatcher(None,
+admonition.group(1), x).ratio()
+
+similar = [s for s in directives if sim(s) > 0.6]
+if len(similar) == 1:
+ui.write(_("(did you mean %s?)\n") % similar[0])
+elif similar:
+ss = ", ".join(sorted(similar))
+ui.write(_("(did you mean one of %s?)\n") % ss)
+
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +466,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('c', 'check', False, _('checks for validity of admonitions (if any)'),
+_('REV'))],
+_('hg releasenotes [-r REV] [-c] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,8 +547,12 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
+if opts.get('check'):
+return checkadmonitions(ui, repo, sections.names(), revs)
+
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
 try:



To: rishabhmadan96, #hg-reviewers, durin42
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D355: contrib: add check flag for use of admonitions and its validity

2017-08-15 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 abandoned this revision.
rishabhmadan96 marked an inline comment as done.
rishabhmadan96 added a comment.


  In https://phab.mercurial-scm.org/D355#6196, @durin42 wrote:
  
  > is this the same thing as https://phab.mercurial-scm.org/D368? Should we 
close this one in favor of that one?
  
  
  Yes. I'm abandoning this one.

REPOSITORY
  rHG Mercurial

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

To: rishabhmadan96, #hg-reviewers, pulkit
Cc: durin42, pulkit, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D368: releasenotes: add check flag for use of admonitions and its validity

2017-08-13 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While using releasenotes extension, we will be using admonitions in commit 
messages.
  The check (-c) flag will look for an admonition within the message. If it 
exists, it will
  verify if it is stated under default or custom admonition. The check fails if 
the
  admonition is not present in any of them. It also suggests similar admonitions
  in case the admonition is invalid.

REPOSITORY
  rHG Mercurial

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

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
@@ -378,3 +378,32 @@
   
   * Adds a new feature.
 
+  $ cd ..
+
+Testing output for the --check (-c) flag
+
+  $ hg init check-flag
+  $ cd check-flag
+
+  $ touch a
+  $ hg -q commit -A -l - << EOF
+  > .. asf::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+Suggest similar admonition in place of the invalid one.
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+
+  $ touch b
+  $ hg -q commit -A -l - << EOF
+  > .. fixes::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  (did you mean fix?)
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -13,6 +13,7 @@
 
 from __future__ import absolute_import
 
+import difflib
 import errno
 import re
 import sys
@@ -242,6 +243,39 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def checkadmonitions(ui, repo, directives, revs):
+"""
+Checks the commit messages for admonitions and their validity.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For this commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+As admonition 'abcd' is neither present in default nor custom admonitions
+"""
+for rev in revs:
+ctx = repo[rev]
+admonition = re.search(RE_DIRECTIVE, ctx.description())
+if admonition:
+if admonition.group(1) in directives:
+continue
+else:
+ui.write(_("Invalid admonition \'%s\' present in changeset %s\
+\n") % (admonition.group(1), ctx.hex()[:12]))
+sim = lambda x: difflib.SequenceMatcher(None,
+admonition.group(1), x).ratio()
+
+similar = [s for s in directives if sim(s) > 0.6]
+if len(similar) == 1:
+ui.write(_("(did you mean %s?)\n") % similar[0])
+elif similar:
+ss = ", ".join(sorted(similar))
+ui.write(_("(did you mean one of %s?)\n") % ss)
+
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +466,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('c', 'check', False, _('checks for validity of admonitions (if any)'),
+_('REV'))],
+_('hg releasenotes [-r REV] [-c] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,8 +547,12 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
+if opts.get('check'):
+return checkadmonitions(ui, repo, sections.names(), revs)
+
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
 try:



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D367: releasenotes: add check flag for use of admonitions and its validity

2017-08-13 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While using releasenotes extension, we will be using admonitions in commit 
messages.
  The check (-c) flag will look for an admonition within the message. If it 
exists, it will
  verify if it is stated under default or custom admonition. The check fails if 
the
  admonition is not present in any of them. It also suggests similar admonitions
  in case the admonition is invalid.

REPOSITORY
  rHG Mercurial

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

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
@@ -378,3 +378,32 @@
   
   * Adds a new feature.
 
+  $ cd ..
+
+Testing output for the --check (-c) flag
+
+  $ hg init check-flag
+  $ cd check-flag
+
+  $ touch a
+  $ hg -q commit -A -l - << EOF
+  > .. asf::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+Suggest similar admonition in place of the invalid one.
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'asf' present in changeset 4026fe9e1c20
+
+  $ touch b
+  $ hg -q commit -A -l - << EOF
+  > .. fixes::
+  > 
+  >First paragraph under this admonition.
+  > EOF
+
+  $ hg releasenotes -r . -c
+  Invalid admonition 'fixes' present in changeset 0e7130d2705c
+  (did you mean fix?)
diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -13,6 +13,7 @@
 
 from __future__ import absolute_import
 
+import difflib
 import errno
 import re
 import sys
@@ -242,6 +243,39 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def checkadmonitions(ui, repo, directives, revs):
+"""
+Checks the commit messages for admonitions and their validity.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For this commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+As admonition 'abcd' is neither present in default nor custom admonitions
+"""
+for rev in revs:
+ctx = repo[rev]
+admonition = re.search(RE_DIRECTIVE, ctx.description())
+if admonition:
+if admonition.group(1) in directives:
+continue
+else:
+ui.write(_("Invalid admonition \'%s\' present in changeset %s\
+\n") % (admonition.group(1), ctx.hex()[:12]))
+sim = lambda x: difflib.SequenceMatcher(None,
+admonition.group(1), x).ratio()
+
+similar = [s for s in directives if sim(s) > 0.6]
+if len(similar) == 1:
+ui.write(_("(did you mean %s?)\n") % similar[0])
+elif similar:
+ss = ", ".join(sorted(similar))
+ui.write(_("(did you mean one of %s?)\n") % ss)
+
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +466,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('c', 'check', False, _('checks for validity of admonitions (if any)'),
+_('REV')),('a', 'admn', None, _('get list of admonitions'), None)],
+_('hg releasenotes [-r REV] [-c] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,8 +547,12 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
+if opts.get('check'):
+return checkadmonitions(ui, repo, sections.names(), revs)
+
 incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
 try:



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D356: releasenotes: minor bug fix for index error while serializing

2017-08-13 Thread rishabhmadan96 (Rishabh Madan)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG589fda7895da: releasenotes: minor bug fix for index error 
while serializing (authored by rishabhmadan96).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D356?vs=817=843

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -426,7 +426,7 @@
 
 lines.append('')
 
-if lines[-1]:
+if lines and lines[-1]:
 lines.append('')
 
 return '\n'.join(lines)



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D356: releasenotes: minor bug fix for index error while serializing

2017-08-11 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -426,7 +426,7 @@
 
 lines.append('')
 
-if lines[-1]:
+if lines and lines[-1]:
 lines.append('')
 
 return '\n'.join(lines)



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D355: contrib: add check flag for use of admonitions and its validity

2017-08-11 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  While using releasenotes extension, we will be using admonitions in commit 
messages.
  The check (-c) flag will look for an admonition within the message. If it 
exists, it will
  verify if it is stated under default or custom admonition. The check fails if 
the
  admonition is not present in any of them.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/releasenotes.py

CHANGE DETAILS

diff --git a/hgext/releasenotes.py b/hgext/releasenotes.py
--- a/hgext/releasenotes.py
+++ b/hgext/releasenotes.py
@@ -242,6 +242,29 @@
 read('.hgreleasenotes')
 return p['sections']
 
+def checkadmonitions(ui, repo, directives, revs):
+"""
+Checks the commit messages for admonitions and their validity.
+
+.. abcd::
+
+   First paragraph under this admonition
+
+For this commit message, using `hg releasenotes -r . --check`
+returns: Invalid admonition 'abcd' present in changeset 3ea92981e103
+
+As admonition 'abcd' is neither present in default nor custom admonitions
+"""
+for rev in revs:
+ctx = repo[rev]
+admonition = re.search(RE_DIRECTIVE, ctx.description())
+if admonition:
+if admonition.group(1) in directives:
+continue
+else:
+ui.write(_("Invalid admonition \'%s\' present in changeset %s\
+\n") % (admonition.group(1), ctx.hex()[:12]))
+
 def parsenotesfromrevisions(repo, directives, revs):
 notes = parsedreleasenotes()
 
@@ -432,9 +455,11 @@
 return '\n'.join(lines)
 
 @command('releasenotes',
-[('r', 'rev', '', _('revisions to process for release notes'), _('REV'))],
-_('[-r REV] FILE'))
-def releasenotes(ui, repo, file_, rev=None):
+[('r', 'rev', '', _('revisions to process for release notes'), _('REV')),
+('c', 'check', False, _('checks for validity of admonitions (if any)'),
+_('REV'))],
+_('hg releasenotes [-r REV] [-c] FILE'))
+def releasenotes(ui, repo, file_=None, **opts):
 """parse release notes from commit messages into an output file
 
 Given an output file and set of revisions, this command will parse commit
@@ -511,23 +536,28 @@
 release note after it has been added to the release notes file.
 """
 sections = releasenotessections(ui, repo)
+rev = opts.get('rev')
 
 revs = scmutil.revrange(repo, [rev or 'not public()'])
-incoming = parsenotesfromrevisions(repo, sections.names(), revs)
+if opts.get('check'):
+checkadmonitions(ui, repo, sections.names(), revs)
+
+if not opts.get('check'):
+incoming = parsenotesfromrevisions(repo, sections.names(), revs)
 
-try:
-with open(file_, 'rb') as fh:
-notes = parsereleasenotesfile(sections, fh.read())
-except IOError as e:
-if e.errno != errno.ENOENT:
-raise
+try:
+with open(file_, 'rb') as fh:
+notes = parsereleasenotesfile(sections, fh.read())
+except IOError as e:
+if e.errno != errno.ENOENT:
+raise
 
-notes = parsedreleasenotes()
+notes = parsedreleasenotes()
 
-notes.merge(ui, incoming)
+notes.merge(ui, incoming)
 
-with open(file_, 'wb') as fh:
-fh.write(serializenotes(sections, notes))
+with open(file_, 'wb') as fh:
+fh.write(serializenotes(sections, notes))
 
 @command('debugparsereleasenotes', norepo=True)
 def debugparsereleasenotes(ui, path, repo=None):



To: rishabhmadan96, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D354: merge with stable

2017-08-11 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  .hgsigs
  .hgtags
  hgext/fsmonitor/__init__.py
  mercurial/cmdutil.py
  mercurial/dirstate.py
  mercurial/localrepo.py
  mercurial/pathutil.py
  mercurial/posix.py
  mercurial/scmutil.py
  mercurial/sshpeer.py
  mercurial/subrepo.py
  mercurial/util.py
  mercurial/vfs.py
  mercurial/windows.py
  tests/test-audit-path.t
  tests/test-clone.t
  tests/test-commandserver.t
  tests/test-pull.t
  tests/test-push.t
  tests/test-ssh-bundle1.t
  tests/test-ssh.t
  tests/test-subrepo-git.t
  tests/test-subrepo-svn.t
  tests/test-subrepo.t

CHANGE DETAILS

diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1789,3 +1789,77 @@
   +bar
 
   $ cd ..
+
+test for ssh exploit 2017-07-25
+
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > ssh = sh -c "read l; read l; read l"
+  > EOF
+
+  $ hg init malicious-proxycommand
+  $ cd malicious-proxycommand
+  $ echo 's = [hg]ssh://-oProxyCommand=touch${IFS}owned/path' > .hgsub
+  $ hg init s
+  $ cd s
+  $ echo init > init
+  $ hg add
+  adding init
+  $ hg commit -m init
+  $ cd ..
+  $ hg add .hgsub
+  $ hg ci -m 'add subrepo'
+  $ cd ..
+  $ hg clone malicious-proxycommand malicious-proxycommand-clone
+  updating to branch default
+  abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path' 
(in subrepository "s")
+  [255]
+
+also check that a percent encoded '-' (%2D) doesn't work
+
+  $ cd malicious-proxycommand
+  $ echo 's = [hg]ssh://%2DoProxyCommand=touch${IFS}owned/path' > .hgsub
+  $ hg ci -m 'change url to percent encoded'
+  $ cd ..
+  $ rm -r malicious-proxycommand-clone
+  $ hg clone malicious-proxycommand malicious-proxycommand-clone
+  updating to branch default
+  abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path' 
(in subrepository "s")
+  [255]
+
+also check for a pipe
+
+  $ cd malicious-proxycommand
+  $ echo 's = [hg]ssh://fakehost|touch${IFS}owned/path' > .hgsub
+  $ hg ci -m 'change url to pipe'
+  $ cd ..
+  $ rm -r malicious-proxycommand-clone
+  $ hg clone malicious-proxycommand malicious-proxycommand-clone
+  updating to branch default
+  abort: no suitable response from remote hg!
+  [255]
+  $ [ ! -f owned ] || echo 'you got owned'
+
+also check that a percent encoded '|' (%7C) doesn't work
+
+  $ cd malicious-proxycommand
+  $ echo 's = [hg]ssh://fakehost%7Ctouch%20owned/path' > .hgsub
+  $ hg ci -m 'change url to percent encoded pipe'
+  $ cd ..
+  $ rm -r malicious-proxycommand-clone
+  $ hg clone malicious-proxycommand malicious-proxycommand-clone
+  updating to branch default
+  abort: no suitable response from remote hg!
+  [255]
+  $ [ ! -f owned ] || echo 'you got owned'
+
+and bad usernames:
+  $ cd malicious-proxycommand
+  $ echo 's = [hg]ssh://-oProxyCommand=touch ow...@example.com/path' > .hgsub
+  $ hg ci -m 'owned username'
+  $ cd ..
+  $ rm -r malicious-proxycommand-clone
+  $ hg clone malicious-proxycommand malicious-proxycommand-clone
+  updating to branch default
+  abort: potentially unsafe url: 'ssh://-oProxyCommand=touch 
ow...@example.com/path' (in subrepository "s")
+  [255]
diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t
--- a/tests/test-subrepo-svn.t
+++ b/tests/test-subrepo-svn.t
@@ -639,3 +639,43 @@
   $ hg update -q -C '.^1'
 
   $ cd ../..
+
+SEC: test for ssh exploit
+
+  $ hg init ssh-vuln
+  $ cd ssh-vuln
+  $ echo "s = [svn]$SVNREPOURL/src" >> .hgsub
+  $ svn co --quiet "$SVNREPOURL"/src s
+  $ hg add .hgsub
+  $ hg ci -m1
+  $ echo "s = [svn]svn+ssh://-oProxyCommand=touch%20owned%20nested" > .hgsub
+  $ hg ci -m2
+  $ cd ..
+  $ hg clone ssh-vuln ssh-vuln-clone
+  updating to branch default
+  abort: potentially unsafe url: 'svn+ssh://-oProxyCommand=touch owned nested' 
(in subrepository "s")
+  [255]
+
+also check that a percent encoded '-' (%2D) doesn't work
+
+  $ cd ssh-vuln
+  $ echo "s = [svn]svn+ssh://%2DoProxyCommand=touch%20owned%20nested" > .hgsub
+  $ hg ci -m3
+  $ cd ..
+  $ rm -r ssh-vuln-clone
+  $ hg clone ssh-vuln ssh-vuln-clone
+  updating to branch default
+  abort: potentially unsafe url: 'svn+ssh://-oProxyCommand=touch owned nested' 
(in subrepository "s")
+  [255]
+
+also check that hiding the attack in the username doesn't work:
+
+  $ cd ssh-vuln
+  $ echo "s = 
[svn]svn+ssh://%2DoProxyCommand=touch%20owned%20...@example.com/nested" > .hgsub
+  $ hg ci -m3
+  $ cd ..
+  $ rm -r ssh-vuln-clone
+  $ hg clone ssh-vuln ssh-vuln-clone
+  updating to branch default
+  abort: potentially unsafe url: 'svn+ssh://-oProxyCommand=touch owned 
f...@example.com/nested' (in subrepository "s")
+  [255]
diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
--- a/tests/test-subrepo-git.t
+++ b/tests/test-subrepo-git.t
@@ -1182,3 +1182,34 @@
   pwned: you asked