4ede1c231525

Require a remote path.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 11 Oct 2009 11:11:09 -0400
parents 6930dfc9918a
children 0071e116bfb4
branches/tags (none)
files review/extension_ui.py review/messages.py review/tests/test_init.py review/tests/util.py

Changes

--- a/review/extension_ui.py	Sun Oct 11 10:37:57 2009 -0400
+++ b/review/extension_ui.py	Sun Oct 11 11:11:09 2009 -0400
@@ -13,6 +13,9 @@
 
 
 def _init_command(ui, repo, **opts):
+    if not opts['remote_path']:
+        raise util.Abort(messages.INIT_REQUIRES_REMOTE_PATH)
+    
     ui.note(messages.INIT_START)
     try:
         ReviewDatastore(ui, repo, lpath=opts.pop('local_path'),
@@ -252,7 +255,7 @@
     (['review-init', 'review-init'],
      ('Initializing code review for a repository'),
      (r"""
-    
+hg review --init --remote-path PATH [--local-path PATH]
     """)),
     (['review-review', 'review-review'],
      ('Viewing code review data for changesets'),
--- a/review/messages.py	Sun Oct 11 10:37:57 2009 -0400
+++ b/review/messages.py	Sun Oct 11 11:11:09 2009 -0400
@@ -15,6 +15,10 @@
 run "hg commit .hgreview -m'initialize code review'" to record it permanently
 """
 
+INIT_REQUIRES_REMOTE_PATH ="""\
+you must provide a remote path (see 'hg help review-init')!
+"""
+
 INIT_EXISTS_COMMITTED = """\
 the review data was already initialized by someone else
 """
--- a/review/tests/test_init.py	Sun Oct 11 10:37:57 2009 -0400
+++ b/review/tests/test_init.py	Sun Oct 11 11:11:09 2009 -0400
@@ -11,7 +11,7 @@
 def test_init():
     sandbox = get_sandbox_repo()
     
-    output = review(init=True)
+    output = review(init=True, remote_path='../sandbox-review')
     assert messages.INIT_SUCCESS in output
     
     assert '.hgreview' not in sandbox['tip']
@@ -29,64 +29,41 @@
 def test_init_with_local_path():
     sandbox = get_sandbox_repo()
     
-    output = review(init=True, local_path='NEW_PATH')
-    assert messages.INIT_SUCCESS in output
-    
-    assert '.hgreview' not in sandbox['tip']
-    assert os.path.exists('.hgreview')
-    assert os.path.isdir('NEW_PATH')
-    assert get_datastore_repo('NEW_PATH')
-    
-    with open('.hgreview', 'r') as hgrf:
-        hgr = hgrf.read()
-        assert 'local = NEW_PATH' in hgr
-        assert 'remote = ../sandbox-review' in hgr
-
-
-@with_setup(setup_sandbox, teardown_sandbox)
-def test_init_with_remote_path():
-    sandbox = get_sandbox_repo()
-    
-    output = review(init=True, remote_path='../code-review')
+    output = review(init=True, local_path='NEW', remote_path='../sandbox-review')
     assert messages.INIT_SUCCESS in output
     
     assert '.hgreview' not in sandbox['tip']
     assert os.path.exists('.hgreview')
-    assert os.path.isdir(api.DEFAULT_DATASTORE_DIRNAME)
-    assert get_datastore_repo(api.DEFAULT_DATASTORE_DIRNAME)
+    assert os.path.isdir('NEW')
+    assert get_datastore_repo('NEW')
     
     with open('.hgreview', 'r') as hgrf:
         hgr = hgrf.read()
-        assert 'local = %s' % api.DEFAULT_DATASTORE_DIRNAME in hgr
-        assert 'remote = ../code-review' in hgr
+        assert 'local = NEW' in hgr
+        assert 'remote = ../sandbox-review' in hgr
 
 
 @with_setup(setup_sandbox, teardown_sandbox)
-def test_init_with_both_paths():
+def test_init_without_remote_path():
     sandbox = get_sandbox_repo()
     
-    output = review(init=True, local_path='codereview', remote_path='../code-review')
-    assert messages.INIT_SUCCESS in output
-    
-    assert '.hgreview' not in sandbox['tip']
-    assert os.path.exists('.hgreview')
-    assert os.path.isdir('codereview')
-    assert get_datastore_repo('codereview')
-    
-    with open('.hgreview', 'r') as hgrf:
-        hgr = hgrf.read()
-        assert 'local = codereview' in hgr
-        assert 'remote = ../code-review' in hgr
+    try:
+        review(init=True)
+    except hgutil.Abort, e:
+        error = str(e)
+        assert messages.INIT_REQUIRES_REMOTE_PATH in error
+    else:
+        assert False, 'The correct error message was not printed.'
 
 
 @with_setup(setup_sandbox, teardown_sandbox)
 def test_init_twice():
     sandbox = get_sandbox_repo()
     
-    review(init=True)
+    review(init=True, remote_path='../sandbox-review')
     
     try:
-        review(init=True)
+        review(init=True, remote_path='../sandbox-review')
     except hgutil.Abort, e:
         error = str(e)
         assert messages.INIT_EXISTS_UNCOMMITTED in error
--- a/review/tests/util.py	Sun Oct 11 10:37:57 2009 -0400
+++ b/review/tests/util.py	Sun Oct 11 11:11:09 2009 -0400
@@ -57,7 +57,7 @@
     setup_sandbox()
     sandbox = get_sandbox_repo()
     
-    review(init=True)
+    review(init=True, remote_path='../sandbox-review')
     
     opts = { 'addremove': True, 'date': None, 'user': 'Review Tester',
              'logfile': None, 'message': "Add the code review.", }