9af83b8976fb

api: add support for text styles
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 18 Jun 2010 21:26:35 -0400
parents 802d01307f77
children bc5a004bfcca
branches/tags (none)
files review/api.py review/files.py

Changes

--- a/review/api.py	Fri Jun 18 21:12:56 2010 -0400
+++ b/review/api.py	Fri Jun 18 21:26:35 2010 -0400
@@ -338,7 +338,7 @@
     def signoffs_for_current_user(self):
         return self.signoffs_for_user(self.ui.username())
 
-    def add_signoff(self, message, opinion='', force=False):
+    def add_signoff(self, message, opinion='', force=False, style=''):
         """Add (and commit) a signoff for the given revision.
 
         The opinion argument should be 'yes', 'no', or ''.
@@ -355,10 +355,10 @@
             existing[0]._delete(self.ui, self.repo)
 
         signoff = ReviewSignoff(self.ui.username(), util.makedate(),
-            self.node, opinion, message)
+            self.node, opinion, message, style)
         signoff._commit(self.ui, self.repo)
 
-    def add_comment(self, message, filename='', lines=[]):
+    def add_comment(self, message, filename='', lines=[], style=''):
         """Add (and commit) a comment for the given file and lines.
 
         The filename should be normalized to the format Mercurial expects,
@@ -376,7 +376,7 @@
             raise FileNotInChangeset(filename)
 
         comment = ReviewComment(self.ui.username(), util.makedate(),
-            self.node, filename, lines, message)
+            self.node, filename, lines, message, style)
         comment._commit(self.ui, self.repo)
 
 
@@ -660,8 +660,9 @@
         comment.node
         comment.filename
         comment.lines
+        comment.local_datetime
         comment.message
-        comment.local_datetime
+        comment.style
         comment.identifier
 
     Each item is a string, except for lines, hgdate, and local_datetime.
@@ -676,7 +677,8 @@
     was added.
 
     """
-    def __init__(self, author, hgdate, node, filename, lines, message, identifier=None, **extra):
+    def __init__(self, author, hgdate, node, filename, lines, message,
+                 style='', identifier=None, **extra):
         """Initialize a ReviewComment.
 
         You shouldn't need to create these directly -- use a ReviewChangeset
@@ -697,6 +699,7 @@
         self.filename = filename
         self.lines = lines
         self.message = message
+        self.style = style
         self.identifier = identifier
 
     def _render_data(self):
@@ -709,7 +712,7 @@
         rendered_date = util.datestr(self.hgdate)
         lines = ','.join(self.lines)
         return files.COMMENT_FILE_TEMPLATE % ( self.author, rendered_date,
-            self.node, self.filename, lines, self.message )
+            self.node, self.filename, lines, self.style, self.message )
 
     def __str__(self):
         """Stringify this comment for easy printing (for debugging)."""
@@ -736,7 +739,9 @@
         signoff.hgdate
         signoff.node
         signoff.opinion
+        signoff.local_datetime
         signoff.message
+        signoff.style
         signoff.identifier
 
     Each item is a string, except for hgdate and local_datetime.
@@ -749,7 +754,8 @@
     was added.
 
     """
-    def __init__(self, author, hgdate, node, opinion, message, identifier=None, **extra):
+    def __init__(self, author, hgdate, node, opinion, message,
+                 style='', identifier=None, **extra):
         """Initialize a ReviewSignoff.
 
         You shouldn't need to create these directly -- use a ReviewChangeset
@@ -770,6 +776,7 @@
         self.node = node
         self.opinion = opinion
         self.message = message
+        self.style = style
         self.identifier = identifier
 
     def _render_data(self):
@@ -781,6 +788,6 @@
         """
         rendered_date = util.datestr(self.hgdate)
         return files.SIGNOFF_FILE_TEMPLATE % ( self.author, rendered_date,
-            self.node, self.opinion, self.message )
+            self.node, self.opinion, self.style, self.message )
 
 
--- a/review/files.py	Fri Jun 18 21:12:56 2010 -0400
+++ b/review/files.py	Fri Jun 18 21:26:35 2010 -0400
@@ -6,6 +6,7 @@
 node:%s
 filename:%s
 lines:%s
+style:%s
 
 %s"""
 
@@ -14,5 +15,6 @@
 hgdate:%s
 node:%s
 opinion:%s
+style:%s
 
-%s"""
\ No newline at end of file
+%s"""