# HG changeset patch # User Steve Losh # Date 1254700623 14400 # Node ID adce24d241764c3b0e023984491a2e8ba20538fd # Parent 467dacbab7d6ef1704af96e95150de8bfe8e8d30 Fix bugs, add tests. diff -r 467dacbab7d6 -r adce24d24176 review/api.py --- a/review/api.py Sun Oct 04 19:41:58 2009 -0400 +++ b/review/api.py Sun Oct 04 19:57:03 2009 -0400 @@ -95,17 +95,6 @@ node = hex(self.target[rev].node()) return ReviewChangeset(self.ui, self.repo, node) - def add_signoff(self, rev): - '''Add (and commit) a signoff for the given revision.''' - pass - - def add_comment(self, message, rev='.', filename='', lines=[]): - '''Add (and commit) a comment for the given revision, file, and lines.''' - node = hex(self.target[rev].node()) - comment = ReviewComment(self.ui.username(), datetime.utcnow(), node, - filename, lines, message) - comment.commit(self.ui, self.repo) - class ReviewChangeset(object): @@ -141,6 +130,15 @@ { 'message': 'Initialize review data for changeset %s' % self.node, 'addremove': True, }) + def add_signoff(self, message, rev='.'): + '''Add (and commit) a signoff for the given revision.''' + pass + + def add_comment(self, message, filename='', lines=[]): + '''Add (and commit) a comment for the given file and lines.''' + comment = ReviewComment(self.ui.username(), datetime.utcnow(), + self.node, filename, lines, message) + comment.commit(self.ui, self.repo) class ReviewComment(object): '''A single review comment.''' diff -r 467dacbab7d6 -r adce24d24176 review/extension_ui.py --- a/review/extension_ui.py Sun Oct 04 19:41:58 2009 -0400 +++ b/review/extension_ui.py Sun Oct 04 19:57:03 2009 -0400 @@ -23,12 +23,13 @@ return elif opts.pop('comment'): rd = ReviewDatastore(ui, repo) + rcset = rd[opts.pop('rev')] message = opts.pop('message') if not message: raise util.Abort(messages.COMMENT_REQUIRES_MESSAGE) - rd.add_comment(message=message) + rcset.add_comment(message=message) return # No other options matched, so we're at the basic review command. diff -r 467dacbab7d6 -r adce24d24176 review/tests/test_comment.py --- a/review/tests/test_comment.py Sun Oct 04 19:41:58 2009 -0400 +++ b/review/tests/test_comment.py Sun Oct 04 19:57:03 2009 -0400 @@ -7,6 +7,17 @@ @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 + + +@with_setup(setup_reviewed_sandbox, teardown_sandbox) def test_blank_comment(): sandbox = get_sandbox_repo() @@ -20,11 +31,49 @@ @with_setup(setup_reviewed_sandbox, teardown_sandbox) -def test_no_comments(): +def test_add_comments_to_parent_rev(): sandbox = get_sandbox_repo() + review(comment=True, message='Test comment one.') + + gather_output() + review() + output = grab_output() + + assert messages.REVIEW_LOG_COMMENTS % (1, 1) in output + + review(comment=True, message='Test comment two.') + + gather_output() + review() + output = grab_output() + + assert messages.REVIEW_LOG_COMMENTS % (2, 1) in output + + +@with_setup(setup_reviewed_sandbox, teardown_sandbox) +def test_add_comments_to_specific_rev(): + sandbox = get_sandbox_repo() + + review(comment=True, message='Test comment one.', rev='0') + + gather_output() + review(rev='0') + output = grab_output() + + assert messages.REVIEW_LOG_COMMENTS % (1, 1) in output + gather_output() review() output = grab_output() assert messages.REVIEW_LOG_COMMENTS % (0, 0) in output + + review(comment=True, message='Test comment two.', rev='0') + + gather_output() + review(rev='0') + output = grab_output() + + assert messages.REVIEW_LOG_COMMENTS % (2, 1) in output +