2f87e72fa84e

Refactor out helps.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 11 Jun 2010 21:44:34 -0400
parents 5c05c7aced32
children fee142eef88d
branches/tags (none)
files review/extension_ui.py review/helps.py

Changes

--- a/review/extension_ui.py	Fri Jun 11 21:31:09 2010 -0400
+++ b/review/extension_ui.py	Fri Jun 11 21:44:34 2010 -0400
@@ -6,7 +6,7 @@
 """
 
 import re
-import messages
+import helps, messages
 from api import *
 from mercurial import help, templatefilters, util
 from mercurial.node import short
@@ -301,19 +301,25 @@
 
 cmdtable = {
     'review': (review, [
+        ('U', 'unified',     '5',   'number of lines of context to show'),
+        ('m', 'message',     '',    'use <text> as the comment or signoff message'),
+        ('r', 'rev',         '.',   'the revision to review'),
+
+        ('',  'check',       False, 'check the review status of the given revision'),
+
         ('i', 'init',        False, 'start code reviewing this repository'),
         ('',  'remote-path', '',    'the remote path to code review data'),
+
         ('c', 'comment',     False, 'add a comment'),
+        ('l', 'lines',       '',    'the line(s) of the file to comment on'),
+
         ('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'),
         ('',  'force',       False, 'overwrite an existing signoff'),
-        ('r', 'rev',         '.',   'the revision to review'),
-        ('l', 'lines',       '',    'the line(s) of the file to comment on'),
-        ('U', 'unified',     '5',   'number of lines of context to show'),
-        ('w', 'web',         False, 'launch the web interface'),
-        ('',  'read-only',   False, 'make the web interface read-only'),
+
+        ('w', 'web',         False,       'launch the web interface'),
+        ('',  'read-only',   False,       'make the web interface read-only'),
         ('',  'address',     '127.0.0.1', 'run the web interface on the specified address'),
         ('',  'port',        '8080',      'run the web interface on the specified port'),
     ],
@@ -321,106 +327,8 @@
 }
 
 help.helptable += (
-    (['review-init'],
-     ('Initializing code review for a repository'),
-     (r"""
-hg review --init --remote-path PATH
-
-    Initialize code review for the current repository.
-
-    When run for the first time in a project, it will do two things:
-
-        * Create a new Mercurial repository to hold the review data at .hg/review/
-
-        * Create and 'hg add' a .hgreview file in the current repository. You
-          will need to commit this file yourself with:
-          hg commmit .hgreview -m 'Initialize code review data.'
-
-    This repository contains code review data such as comments and signoffs.
-    It is a normal Mercurial repository, so you can push and pull review data
-    to and from other clones of it to share your comments and signoffs.
-
-    The --remote-path option is required, and specifies the path where the
-    canonical code review data for this project will live.  This is the path
-    that will be cloned when someone else runs 'hg review --init' on the
-    project.
-
-    Examples:
-
-        hg review --init --remote-path 'http://bitbucket.org/u/project-review'
-        hg review --init --remote-path '../project-review'
-
-    """)),
-    (['review-review'],
-     ('Viewing code review data for changesets'),
-     (r"""
-hg review [-r REV] [-U CONTEXT] [--quiet] [FILE]
-
-    Show code review information about a specific revision. Diffs of all
-    changed files will be shown, and the line numbers printed are the ones
-    that should be used with 'hg review --comment --lines LINES FILE'.
-
-    If no revision is given, the current parent of the working directory
-    will be shown.
-
-    The number of lines of context in diffs can be changed with the -U option.
-    If any FILEs are given, only those diffs will be shown. If --quiet is used
-    no diffs will be shown.
-
-    If --verbose is used the short identifier of each comment/signoff will
-    also be shown.
-
-    If --debug is used the full identifier of each comment/signoff will also
-    be shown.
-
-    """)),
-    (['review-comment'],
-     ('Adding code review comments for changesets'),
-     (r"""
-hg review --comment -m MESSAGE [-r REV] [-l LINES] [FILE]
-
-    If no revision is given, the current parent of the working directory
-    will be used.
-
-    If no FILEs are given, the comment will be attached to the changeset
-    as a whole.
-
-    If one or more FILEs are given but no LINES are given, the comment will
-    be attached to the each file as a whole.
-
-    If a FILE is given and LINES is given the comment will be attached to
-    those specific lines.  LINES should be a comma-separated list of line
-    numbers (as numbered in the output of 'hg review'), such as '3' or '2,3'
-
-    Examples:
-
-        hg review --comment -m 'This changeset needs to go in branch X.'
-        hg review --comment -m 'This file should just be deleted.' script.py
-        hg review --comment -m 'Trailing whitespace!' --lines 1,2,30 utils.py
-
-    """)),
-    (['review-signoff'],
-     ('Adding code review signoffs for changesets'),
-     (r"""
-hg review --signoff -m MESSAGE [--yes | --no] [-r REV] [--force]
-
-    If no revision is given, the current parent of the working directory
-    will be used.
-
-    The --yes and --no options can be used to indicate whether you think
-    the changeset is "good" or "bad".  It's up to the collaborators of each
-    individual project to decide exactly what that means.  If neither option
-    is given the signoff will be marked as "neutral".
-
-    If you've already signed off on a changeset, you can use --force to
-    overwrite your previous signoff with a new one.
-
-    Examples:
-
-        hg review --signoff -m 'I do not work on this part of the code.'
-        hg review --signoff --yes -m 'Thanks, this change looks good.'
-        hg review --signoff --no -m 'This would break backwards compatibility!'
-        hg review --signoff --yes --force -m 'Nevermind, this is fine.'
-
-    """)),
+    (['review-init'], ('Initializing code review for a repository'), (helps.INIT)),
+    (['review-review'], ('Viewing code review data for changesets'), (helps.REVIEW)),
+    (['review-comment'], ('Adding code review comments for changesets'), (helps.COMMENT)),
+    (['review-signoff'], ('Adding code review signoffs for changesets'), (helps.SIGNOFF)),
 )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/review/helps.py	Fri Jun 11 21:44:34 2010 -0400
@@ -0,0 +1,103 @@
+"""Help text used by the command-line UI of hg-review.
+
+These string are kept in a separate module to make diffs easier to read and
+declutter the main extension ui module.
+"""
+
+INIT = r"""
+hg review --init --remote-path PATH
+
+Initialize code review for the current repository.
+
+When run for the first time in a project, it will do two things:
+
+    * Create a new Mercurial repository to hold the review data at .hg/review/
+
+    * Create and 'hg add' a .hgreview file in the current repository. You
+      will need to commit this file yourself with:
+      hg commmit .hgreview -m 'Initialize code review data.'
+
+This repository contains code review data such as comments and signoffs.
+It is a normal Mercurial repository, so you can push and pull review data
+to and from other clones of it to share your comments and signoffs.
+
+The --remote-path option is required, and specifies the path where the
+canonical code review data for this project will live.  This is the path
+that will be cloned when someone else runs 'hg review --init' on the
+project.
+
+Examples:
+
+    hg review --init --remote-path 'http://bitbucket.org/u/project-review'
+    hg review --init --remote-path '../project-review'
+
+"""
+
+REVIEW = r"""
+hg review [-r REV] [-U CONTEXT] [--quiet] [FILE]
+
+Show code review information about a specific revision. Diffs of all
+changed files will be shown, and the line numbers printed are the ones
+that should be used with 'hg review --comment --lines LINES FILE'.
+
+If no revision is given, the current parent of the working directory
+will be shown.
+
+The number of lines of context in diffs can be changed with the -U option.
+If any FILEs are given, only those diffs will be shown. If --quiet is used
+no diffs will be shown.
+
+If --verbose is used the short identifier of each comment/signoff will
+also be shown.
+
+If --debug is used the full identifier of each comment/signoff will also
+be shown.
+
+"""
+
+COMMENT = r"""
+hg review --comment -m MESSAGE [-r REV] [-l LINES] [FILE]
+
+If no revision is given, the current parent of the working directory
+will be used.
+
+If no FILEs are given, the comment will be attached to the changeset
+as a whole.
+
+If one or more FILEs are given but no LINES are given, the comment will
+be attached to the each file as a whole.
+
+If a FILE is given and LINES is given the comment will be attached to
+those specific lines.  LINES should be a comma-separated list of line
+numbers (as numbered in the output of 'hg review'), such as '3' or '2,3'
+
+Examples:
+
+    hg review --comment -m 'This changeset needs to go in branch X.'
+    hg review --comment -m 'This file should just be deleted.' script.py
+    hg review --comment -m 'Trailing whitespace!' --lines 1,2,30 utils.py
+
+"""
+
+SIGNOFF = r"""
+hg review --signoff -m MESSAGE [--yes | --no] [-r REV] [--force]
+
+If no revision is given, the current parent of the working directory
+will be used.
+
+The --yes and --no options can be used to indicate whether you think
+the changeset is "good" or "bad".  It's up to the collaborators of each
+individual project to decide exactly what that means.  If neither option
+is given the signoff will be marked as "neutral".
+
+If you've already signed off on a changeset, you can use --force to
+overwrite your previous signoff with a new one.
+
+Examples:
+
+    hg review --signoff -m 'I do not work on this part of the code.'
+    hg review --signoff --yes -m 'Thanks, this change looks good.'
+    hg review --signoff --no -m 'This would break backwards compatibility!'
+    hg review --signoff --yes --force -m 'Nevermind, this is fine.'
+
+"""