--- a/review/api.py Sat Jun 19 17:42:23 2010 -0400
+++ b/review/api.py Tue Jun 29 20:00:12 2010 -0400
@@ -243,7 +243,7 @@
try:
hg.repository(ui, self.lpath)
except error.RepoError:
- hg.clone(cmdutil.remoteui(self.ui, {}), self.rpath, self.lpath)
+ hg.clone(hg.remoteui(self.ui, {}), self.rpath, self.lpath)
else:
raise PreexistingDatastore(True)
elif os.path.exists(os.path.join(self.target.root, '.hgreview')):
@@ -259,7 +259,7 @@
with open(os.path.join(self.target.root, '.hgreview'), 'w') as hgrf:
hgrf.write('remote = %s\n' % self.rpath)
- self.target.add(['.hgreview'])
+ self.target[None].add(['.hgreview'])
self.repo = hg.repository(ui, self.lpath, create)
def __getitem__(self, rev):
--- a/review/cli.py Sat Jun 19 17:42:23 2010 -0400
+++ b/review/cli.py Tue Jun 29 20:00:12 2010 -0400
@@ -5,9 +5,8 @@
"""
-import re
import api, helps, messages
-from mercurial import extensions, help, templatefilters, util
+from mercurial import help, templatefilters, util
from mercurial.node import short
@@ -216,10 +215,11 @@
def _print_comment(comment, before='', after=''):
ui.write(before)
- ui.write(_build_item_header(comment, messages.REVIEW_LOG_COMMENT_AUTHOR))
+ ui.write(_build_item_header(comment, messages.REVIEW_LOG_COMMENT_AUTHOR),
+ label='review.comment')
for line in comment.message.splitlines():
- ui.write(messages.REVIEW_LOG_COMMENT_LINE % line)
+ ui.write(messages.REVIEW_LOG_COMMENT_LINE % line, label='review.comment')
ui.write(after)
@@ -227,10 +227,12 @@
ui.write(before)
opinion = signoff.opinion or 'neutral'
- ui.write(_build_item_header(signoff, messages.REVIEW_LOG_SIGNOFF_AUTHOR, (opinion,)))
+ label = 'review.signoff.%s' % opinion
+ header = _build_item_header(signoff, messages.REVIEW_LOG_SIGNOFF_AUTHOR, (opinion,))
+ ui.write(header, label=label)
for line in signoff.message.splitlines():
- ui.write(messages.REVIEW_LOG_SIGNOFF_LINE % line)
+ ui.write(messages.REVIEW_LOG_SIGNOFF_LINE % line, label=label)
ui.write(after)
@@ -270,8 +272,14 @@
for comment in line['comments']:
_print_comment(comment)
continue
-
- ui.write('%s %s\n' % (prefix % line['number'], line['content']))
+
+ ui.write('%s ' % (prefix % line['number']))
+ if line['content'].startswith('+'):
+ ui.write('%s\n' % line['content'], label='diff.inserted')
+ elif line['content'].startswith('-'):
+ ui.write('%s\n' % line['content'], label='diff.deleted')
+ else:
+ ui.write('%s\n' % line['content'])
for comment in line['comments']:
_print_comment(comment)
@@ -312,63 +320,6 @@
_edit_signoff(rd, item, **opts)
-_review_effects = {
- 'deleted': ['red'],
- 'inserted': ['green'],
- 'comments': ['cyan'],
- 'signoffs': ['yellow'],
-}
-_review_re = [
- (re.compile(r'^(?P<rest> *\d+: )(?P<colorized>[-].*)'), 'deleted'),
- (re.compile(r'^(?P<rest> *\d+: )(?P<colorized>[+].*)'), 'inserted'),
- (re.compile(r'^(?P<colorized>#.*)'), 'comments'),
- (re.compile(r'^(?P<colorized>\$.*)'), 'signoffs'),
-]
-
-def colorwrap(orig, *args):
- '''wrap ui.write for colored diff output'''
- def _colorize(s):
- lines = s.split('\n')
- for i, line in enumerate(lines):
- if not line:
- continue
- else:
- for r, style in _review_re:
- m = r.match(line)
- if m:
- lines[i] = "%s%s" % (
- m.groupdict().get('rest', ''),
- render_effects(m.group('colorized'), _review_effects[style]))
- break
- return '\n'.join(lines)
-
- orig(*[_colorize(s) for s in args])
-
-def colorreview(orig, ui, repo, *fnames, **opts):
- '''colorize review command output'''
- oldwrite = extensions.wrapfunction(ui, 'write', colorwrap)
- try:
- orig(ui, repo, *fnames, **opts)
- finally:
- ui.write = oldwrite
-
-
-_ui = None
-def uisetup(ui):
- global _ui
- _ui = ui
-
-def extsetup():
- try:
- color = extensions.find('color')
- color._setupcmd(_ui, 'review', cmdtable, colorreview,
- _review_effects)
- global render_effects
- render_effects = color.render_effects
- except KeyError:
- pass
-
-
def review(ui, repo, *args, **opts):
"""code review changesets in the current repository
@@ -452,3 +403,10 @@
(['review-signoff'], ('Adding code review signoffs for changesets'), (helps.SIGNOFF)),
(['review-check'], ('Checking the review status of changesets'), (helps.CHECK)),
)
+
+colortable = {
+ 'review.comment': 'cyan',
+ 'review.signoff.yes': 'green',
+ 'review.signoff.neutral': 'cyan',
+ 'review.signoff.no': 'red',
+}
--- a/review/tests/util.py Sat Jun 19 17:42:23 2010 -0400
+++ b/review/tests/util.py Tue Jun 29 20:00:12 2010 -0400
@@ -103,7 +103,7 @@
return hg.repository(_ui, sandbox_clone_path)
def clone_sandbox_repo():
- hg.clone(cmdutil.remoteui(_ui, {}), sandbox_repo_path, sandbox_clone_path)
+ hg.clone(hg.remoteui(_ui, {}), sandbox_repo_path, sandbox_clone_path)
def get_datastore_repo(path=api.DEFAULT_DATASTORE_DIRNAME):
return hg.repository(_ui, path)