# HG changeset patch # User Steve Losh # Date 1254699718 14400 # Node ID 467dacbab7d6ef1704af96e95150de8bfe8e8d30 # Parent 35fbbd1bbd26bdeeb79b55c0c28568fe7f004cee Move the review output into messages, and add a no-comments test. diff -r 35fbbd1bbd26 -r 467dacbab7d6 review/extension_ui.py --- a/review/extension_ui.py Sun Oct 04 19:31:52 2009 -0400 +++ b/review/extension_ui.py Sun Oct 04 19:41:58 2009 -0400 @@ -37,16 +37,16 @@ cset = repo[rev] rcset = rd[rev] + comment_count = len(rcset.comments) author_count = len(set(comment.author for comment in rcset.comments)) - ui.write('changeset: %d:%s\n' % (cset.rev(), short(cset.node()))) - ui.write('author: %s\n' % cset.user()) - ui.write('summary: %s\n\n' % cset.description().split('\n')[0]) + ui.write(messages.REVIEW_LOG_CSET % (cset.rev(), short(cset.node()))) + ui.write(messages.REVIEW_LOG_AUTHOR % cset.user()) + ui.write(messages.REVIEW_LOG_SUMMARY % cset.description().split('\n')[0]) - ui.write('signoffs: %d signoffs\n' % len(rcset.signoffs)) - ui.write('comments: %d comments from %d authors\n\n' % ( - len(rcset.comments), author_count)) + ui.write(messages.REVIEW_LOG_SIGNOFFS % len(rcset.signoffs)) + ui.write(messages.REVIEW_LOG_COMMENTS % (comment_count, author_count)) cmdtable = { diff -r 35fbbd1bbd26 -r 467dacbab7d6 review/messages.py --- a/review/messages.py Sun Oct 04 19:31:52 2009 -0400 +++ b/review/messages.py Sun Oct 04 19:41:58 2009 -0400 @@ -20,4 +20,26 @@ COMMENT_REQUIRES_MESSAGE = '''\ a message must be provided to add a comment! -''' \ No newline at end of file +''' + +REVIEW_LOG_CSET = '''\ +changeset: %d:%s +''' + +REVIEW_LOG_AUTHOR = '''\ +author: %s +''' + +REVIEW_LOG_SUMMARY = '''\ +summary: %s + +''' + +REVIEW_LOG_SIGNOFFS = '''\ +signoffs: %d signoffs +''' + +REVIEW_LOG_COMMENTS = '''\ +comments: %d comments from %d authors + +''' diff -r 35fbbd1bbd26 -r 467dacbab7d6 review/tests/test_comment.py --- a/review/tests/test_comment.py Sun Oct 04 19:31:52 2009 -0400 +++ b/review/tests/test_comment.py Sun Oct 04 19:41:58 2009 -0400 @@ -18,3 +18,13 @@ else: assert False, 'The correct error message was not printed.' + +@with_setup(setup_reviewed_sandbox, teardown_sandbox) +def test_no_comments(): + sandbox = get_sandbox_repo() + + gather_output() + review() + output = grab_output() + + assert messages.REVIEW_LOG_COMMENTS % (0, 0) in output diff -r 35fbbd1bbd26 -r 467dacbab7d6 review/tests/util.py --- a/review/tests/util.py Sun Oct 04 19:31:52 2009 -0400 +++ b/review/tests/util.py Sun Oct 04 19:41:58 2009 -0400 @@ -54,4 +54,7 @@ _ui.pushbuffer() def grab_output(): - return _ui.popbuffer() + output = _ui.popbuffer() + print output + + return output