--- a/review/api.py Sun Oct 11 17:28:23 2009 -0400
+++ b/review/api.py Sun Oct 11 21:22:38 2009 -0400
@@ -204,7 +204,7 @@
try:
hg.repository(ui, self.lpath)
- except error.RepoError:
+ except error.RepoError:
hg.clone(cmdutil.remoteui(self.ui, {}), self.rpath, self.lpath)
else:
raise PreexistingDatastore(True)
--- a/review/tests/test_init.py Sun Oct 11 17:28:23 2009 -0400
+++ b/review/tests/test_init.py Sun Oct 11 21:22:38 2009 -0400
@@ -71,3 +71,21 @@
else:
assert False, 'The correct error message was not printed.'
+
+@with_setup(setup_reviewed_sandbox, teardown_sandbox)
+def test_init_clone():
+ review(comment=True, message='Test comment one.')
+ review(comment=True, rev='0', message='Test comment two.')
+
+ clone_sandbox_repo()
+ os.chdir(sandbox_clone_path)
+
+ review(init=True)
+
+ output = review()
+ assert messages.REVIEW_LOG_COMMENT_LINE % 'Test comment one.' in output
+ assert messages.REVIEW_LOG_COMMENT_LINE % 'Test comment two.' not in output
+
+ output = review(rev='0')
+ assert messages.REVIEW_LOG_COMMENT_LINE % 'Test comment one.' not in output
+ assert messages.REVIEW_LOG_COMMENT_LINE % 'Test comment two.' in output
--- a/review/tests/util.py Sun Oct 11 17:28:23 2009 -0400
+++ b/review/tests/util.py Sun Oct 11 21:22:38 2009 -0400
@@ -2,7 +2,7 @@
import os, shutil
import sample_data
-from mercurial import commands, hg, ui
+from mercurial import cmdutil, commands, hg, ui
from .. import api, extension_ui
@@ -25,11 +25,16 @@
sandbox_path = os.path.join(os.path.realpath('.'), 'sandbox')
+sandbox_repo_path = os.path.join(sandbox_path, 'original')
+sandbox_clone_path = os.path.join(sandbox_path, 'clone')
def setup_sandbox():
os.mkdir(sandbox_path)
os.chdir(sandbox_path)
+ os.mkdir(sandbox_repo_path)
+ os.chdir(sandbox_repo_path)
+
commands.init(_ui)
sandbox = get_sandbox_repo()
@@ -70,7 +75,13 @@
def get_sandbox_repo():
- return hg.repository(_ui, sandbox_path)
+ return hg.repository(_ui, sandbox_repo_path)
+
+def get_sandbox_clone():
+ return hg.repository(_ui, sandbox_clone_path)
+
+def clone_sandbox_repo():
+ hg.clone(cmdutil.remoteui(_ui, {}), sandbox_repo_path, sandbox_clone_path)
def get_datastore_repo(path):
return hg.repository(_ui, path)