--- a/review/api.py Sun Oct 04 20:25:24 2009 -0400
+++ b/review/api.py Sun Oct 04 20:36:49 2009 -0400
@@ -119,9 +119,11 @@
{ 'message': 'Initialize review data for changeset %s' % self.node,
'addremove': True, })
- def add_signoff(self, message, rev='.'):
+ def add_signoff(self, message, opinion=''):
'''Add (and commit) a signoff for the given revision.'''
- pass
+ signoff = ReviewSignoff(self.ui.username(), datetime.utcnow(),
+ self.node, opinion, message)
+ signoff.commit(self.ui, self.repo)
def add_comment(self, message, filename='', lines=[]):
'''Add (and commit) a comment for the given file and lines.'''
--- a/review/extension_ui.py Sun Oct 04 20:25:24 2009 -0400
+++ b/review/extension_ui.py Sun Oct 04 20:36:49 2009 -0400
@@ -30,6 +30,22 @@
rcset.add_comment(message=message)
return
+def _signoff_command(ui, repo, **opts):
+ rd = ReviewDatastore(ui, repo)
+ rcset = rd[opts.pop('rev')]
+ message = opts.pop('message')
+
+ if not message:
+ raise util.Abort(messages.SIGNOFF_REQUIRES_MESSAGE)
+
+ yes, no = opts.pop('yes'), opts.pop('no')
+ if yes and no:
+ raise util.Abort(messages.SIGNOFF_OPINION_CONFLICT)
+ opinion = 'yes' if yes else ('no' if no else '')
+
+ rcset.add_signoff(message=message, opinion=opinion)
+ return
+
def _review_command(ui, repo, **opts):
rev = opts.pop('rev')
rd = ReviewDatastore(ui, repo)
@@ -50,10 +66,13 @@
def review(ui, repo, *fnames, **opts):
'''code review a changeset in the current repository
'''
+ print opts
if opts.pop('init'):
return _init_command(ui, repo, **opts)
elif opts.pop('comment'):
return _comment_command(ui, repo, **opts)
+ elif opts.pop('signoff'):
+ return _signoff_command(ui, repo, **opts)
else:
return _review_command(ui, repo, **opts)
@@ -64,6 +83,9 @@
('', 'local-path', '', 'the local path to the code review data'),
('', 'remote-path', '', 'the remote path to code review data'),
('c', 'comment', False, 'add a comment'),
+ ('s', 'signoff', False, 'sign off'),
+ ('', 'yes', False, 'sign off as stating the changeset is good'),
+ ('', 'no', False, 'sign off as stating the changeset is bad'),
('m', 'message', '', 'use <text> as the comment or signoff message'),
('r', 'rev', '.', 'the revision to review'),
],
--- a/review/messages.py Sun Oct 04 20:25:24 2009 -0400
+++ b/review/messages.py Sun Oct 04 20:36:49 2009 -0400
@@ -22,6 +22,14 @@
a message must be provided to add a comment!
'''
+SIGNOFF_REQUIRES_MESSAGE = '''\
+a message must be provided to sign off!
+'''
+
+SIGNOFF_OPINION_CONFLICT = '''\
+cannot sign off as both --yes and --no!
+'''
+
REVIEW_LOG_CSET = '''\
changeset: %d:%s
'''
--- a/review/tests/util.py Sun Oct 04 20:25:24 2009 -0400
+++ b/review/tests/util.py Sun Oct 04 20:36:49 2009 -0400
@@ -5,11 +5,12 @@
_ui = ui.ui()
-def review(init=False, comment=False, message='', rev='.',
- local_path='', remote_path=''):
+def review(init=False, comment=False, signoff=False, yes=False, no=False,
+ message='', rev='.', local_path='', remote_path=''):
return extension_ui.review(_ui, get_sandbox_repo(),
- init=init, comment=comment, message=message, rev=rev,
- local_path=local_path, remote_path=remote_path)
+ init=init, comment=comment, signoff=signoff, yes=yes, no=no,
+ message=message, rev=rev, local_path=local_path,
+ remote_path=remote_path)
sandbox_path = os.path.join(os.path.realpath('.'), 'sandbox')