mozreview: make instance path argument optional
authorGregory Szorc <>
Fri, 24 Oct 2014 16:16:19 -0700
changeset 359825 7f1dd03aa08d9cdee4e9152ce0fdaa52f51af29a
parent 359824 31fe6451e47b073382498d4fb226a4b880194344
child 359826 ed05413a04c2ef673c2bb0123d2d38d974ae3f23
push id16998
push dateMon, 02 May 2016 19:42:03 +0000
mozreview: make instance path argument optional While we were here, the documentation for `mozreview help` has been improved.
--- a/docs/hacking-mozreview.rst
+++ b/docs/hacking-mozreview.rst
@@ -49,24 +49,32 @@ Now, you can create and start a MozRevie
   $ ./mozrevew start /path/to/instance
   Bugzilla URL:
   Review Board URL: http://localhost:57486/
   Mercurial URL: http://localhost:57487/
   Admin username:
   Admin password: password
-The argument in that command is the path where we will create and store
-MozReview data and state. It can be anywhere on the filesystem. You may
-want to put it outside of the Mercurial clone so ``hg status`` doesn't
-report hundreds of untracked files.
 You should be able to load the printed URLs in your browser and see a
 working site. If you don't, file a bug!
+.. warning::
+   Storing MozReview instances inside a Mercurial repository will
+   introduce many untracked files. It is recommended to store your
+   instances outside of a repository checkout.
+.. hint::
+   All ``mozreview`` commands take a positional argument defining the
+   path to the instance they should operate on. If you define the
+   ``MOZREVIEW_PATH`` environment variable, you do not need to define
+   this argument.
 Creating Repositories
 MozReview instances are initially empty. They don't have any
 repositories you can push to.
 To create an empty repository to hold reviews, use mozreview::
--- a/mozreview
+++ b/mozreview
@@ -15,15 +15,15 @@ def main(args):
     sys.path.insert(0, os.path.join(HERE, 'testing'))
     from mach.main import Mach
     m = Mach(os.getcwd())
     m.define_category('mozreview', 'MozReview',
-        'Mozilla Code Review Service', 50)
+        'Control and Interact with the Mozilla Code Review Service', 50)
     import vcttesting.mozreview_mach_commands
 if __name__ == '__main__':
--- a/testing/vcttesting/
+++ b/testing/vcttesting/
@@ -36,16 +36,18 @@ def kill(pid):
 class MozReview(object):
     """Interface to MozService service.
     This class can be used to create and control MozReview instances.
     def __init__(self, path):
+        if not path:
+            raise Exception('You must specify a path to create an instance')
         path = os.path.abspath(path)
         self._path = path
         self._name = os.path.dirname(path)
         if not os.path.exists(path):
--- a/testing/vcttesting/
+++ b/testing/vcttesting/
@@ -7,27 +7,28 @@ import socket
 from mach.decorators import (
-class ServerCommands(object):
-    def __init__(self, context):
-        self.context = context
+class MozReviewCommands(object):
+    def _get_mozreview(self, where):
+        if not where and 'MOZREVIEW_PATH' in os.environ:
+            where = os.environ['MOZREVIEW_PATH']
-    def _get_mozreview(self, where):
         from vcttesting.mozreview import MozReview
         return MozReview(where)
     @Command('start', category='mozreview',
         description='Start a MozReview instance')
-    @CommandArgument('where', help='Directory for data')
+    @CommandArgument('where', nargs='?',
+        help='Directory of MozReview instance')
     @CommandArgument('--bugzilla-port', type=int,
         help='Port Bugzilla HTTP server should listen on.')
     @CommandArgument('--reviewboard-port', type=int,
         help='Port Review Board HTTP server should listen on.')
     @CommandArgument('--mercurial_port', type=int,
         help='Port Mercurial HTTP server should listen on.')
     def start(self, where, bugzilla_port, reviewboard_port,
@@ -40,32 +41,35 @@ class ServerCommands(object):
         print('Bugzilla URL: %s' % mr.bugzilla_url)
         print('Review Board URL: %s' % mr.reviewboard_url)
         print('Mercurial URL: %s' % mr.mercurial_url)
         print('Admin username: %s' % mr.admin_username)
         print('Admin password: %s' % mr.admin_password)
     @Command('stop', category='mozreview',
         description='Stop a MozReview instance')
-    @CommandArgument('where', help='Directory of MozReview instance')
+    @CommandArgument('where', nargs='?',
+        help='Directory of MozReview instance')
     def stop(self, where):
         mr = self._get_mozreview(where)
     @Command('create-repo', category='mozreview',
         description='Add a repository to a MozReview instance')
-    @CommandArgument('where', help='Directory of MozReview instance')
+    @CommandArgument('where', nargs='?',
+        help='Directory of MozReview instance')
     @CommandArgument('path', help='Relative path of repository')
     def create_repo(self, where, path):
         mr = self._get_mozreview(where)
         url, rbid = mr.create_repository(path)
         print('URL: %s' % url)
     @Command('create-user', category='mozreview',
         description='Create a user in a MozReview instance')
-    @CommandArgument('where', help='Directory of MozReview instance')
+    @CommandArgument('where', nargs='?',
+        help='Directory of MozReview instance')
     @CommandArgument('email', help='Email address for user')
     @CommandArgument('password', help='Password for user')
     @CommandArgument('fullname', help='Full name for user')
     def create_user(self, where, email, password, fullname):
         mr = self._get_mozreview(where)
         u = mr.create_user(email, password, fullname)
         print('Created user %s' % u['id'])