8d14fdcfb92d

Add signoff messages into the review output.

fixes issue 5
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 10 Oct 2009 18:54:06 -0400
parents 7fef894ba429
children 8b8dee73f936
branches/tags (none)
files review/extension_ui.py review/messages.py review/tests/test_signoff.py

Changes

--- a/review/extension_ui.py	Sat Oct 10 18:28:33 2009 -0400
+++ b/review/extension_ui.py	Sat Oct 10 18:54:06 2009 -0400
@@ -106,7 +106,7 @@
         author_part = messages.REVIEW_LOG_COMMENT_AUTHOR % author
         
         age = templatefilters.age(comment.hgdate)
-        age_part = messages.REVIEW_LOG_COMMENT_AGE % age 
+        age_part = messages.REVIEW_LOG_AGE % age 
         
         spacing = ' ' * (80 - (len(author_part) + len(age_part)))
         
@@ -116,12 +116,38 @@
         
         ui.write(after)
     
+    def _print_signoff(signoff, before='', after=''):
+        ui.write(before)
+        
+        author = templatefilters.person(signoff.author)
+        opinion = signoff.opinion or 'neutral'
+        author_part = messages.REVIEW_LOG_SIGNOFF_AUTHOR % (author, opinion)
+        
+        age = templatefilters.age(signoff.hgdate)
+        age_part = messages.REVIEW_LOG_AGE % age
+        
+        spacing = ' ' * (80 - (len(author_part) + len(age_part)))
+        
+        ui.write(author_part + spacing + age_part + '\n')
+        for line in signoff.message.splitlines():
+            ui.write(messages.REVIEW_LOG_SIGNOFF_LINE % line)
+        
+        ui.write(after)
+    
+    if rcset.signoffs:
+        ui.write('\n')
+    for signoff in rcset.signoffs:
+        _print_signoff(signoff, before='\n')
+        
     review_level_comments = filter(lambda c: not c.filename, rcset.comments)
     if review_level_comments:
         ui.write('\n')
     for comment in review_level_comments:
         _print_comment(comment, before='\n')
     
+    if ui.quiet:
+        return
+    
     fnames = [sanitize_path(fname, repo) for fname in fnames]
     diffs = rcset.diffs(fnames, context)
     
--- a/review/messages.py	Sat Oct 10 18:28:33 2009 -0400
+++ b/review/messages.py	Sat Oct 10 18:54:06 2009 -0400
@@ -69,15 +69,21 @@
 comments:  %d comments from %d authors
 """
 
-REVIEW_LOG_FILE_HEADER = """changes in %s"""
-
 REVIEW_LOG_COMMENT_AUTHOR = """# %s said:"""
-REVIEW_LOG_COMMENT_AGE = """(%s ago)"""
 
 REVIEW_LOG_COMMENT_LINE = """\
 #     %s
 """
 
+REVIEW_LOG_SIGNOFF_AUTHOR = """$ %s signed off as %s, saying:"""
+
+REVIEW_LOG_SIGNOFF_LINE = """\
+$     %s
+"""
+
+REVIEW_LOG_AGE = """(%s ago)"""
+REVIEW_LOG_FILE_HEADER = """changes in %s"""
+
 REVIEW_LOG_SKIPPED = """\
 ... skipped %d lines ...
 """
--- a/review/tests/test_signoff.py	Sat Oct 10 18:28:33 2009 -0400
+++ b/review/tests/test_signoff.py	Sat Oct 10 18:54:06 2009 -0400
@@ -6,6 +6,10 @@
 from mercurial import util as hgutil
 
 
+s1, s2 = (messages.REVIEW_LOG_SIGNOFF_AUTHOR % ('|', 'neutral')).split('|')
+sy1, sy2 = (messages.REVIEW_LOG_SIGNOFF_AUTHOR % ('|', 'yes')).split('|')
+sn1, sn2 = (messages.REVIEW_LOG_SIGNOFF_AUTHOR % ('|', 'no')).split('|')
+
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
 def test_no_signoffs():
     sandbox = get_sandbox_repo()
@@ -35,6 +39,10 @@
     
     output = review()
     assert messages.REVIEW_LOG_SIGNOFFS % (1, 0, 0, 1) in output
+    
+    assert s1 in output
+    assert s1 in output
+    assert messages.REVIEW_LOG_SIGNOFF_LINE % 'Test signoff one.' in output
 
 
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
@@ -78,6 +86,10 @@
     
     output = review()
     assert messages.REVIEW_LOG_SIGNOFFS % (1, 1, 0, 0) in output
+    
+    assert sy1 in output
+    assert sy1 in output
+    assert messages.REVIEW_LOG_SIGNOFF_LINE % 'Test signoff one.' in output
 
 
 @with_setup(setup_reviewed_sandbox, teardown_sandbox)
@@ -88,4 +100,8 @@
     
     output = review()
     assert messages.REVIEW_LOG_SIGNOFFS % (1, 0, 1, 0) in output
+    
+    assert sn1 in output
+    assert sn1 in output
+    assert messages.REVIEW_LOG_SIGNOFF_LINE % 'Test signoff one.' in output