--- a/review/api.py Tue Mar 02 19:04:41 2010 -0500
+++ b/review/api.py Tue Mar 02 19:35:19 2010 -0500
@@ -31,7 +31,7 @@
return join(*rel_list)
-DEFAULT_DATASTORE_DIRNAME = 'code-review'
+DEFAULT_DATASTORE_DIRNAME = os.path.join('.hg', 'review')
class PreexistingDatastore(Exception):
"""Raised when trying to initialize a datastore when one seems to exist."""
@@ -116,9 +116,7 @@
lines = [line for line in hgrd if line.strip()]
for line in lines:
label, _, path = [i.strip() for i in line.partition('=')]
- if label == 'local':
- data['lpath'] = path
- elif label == 'remote':
+ if label == 'remote':
data['rpath'] = path
return data
@@ -197,29 +195,32 @@
review_data = ReviewDatastore(ui, repo, create=True)
+ If you want to specify your own path to the code review repository for
+ this repo, pass the FULL path to the repository as the lpath parameter.
+
Error handling is a bit tricky at the moment. I need to refactor
and/or document this.
"""
self.ui = ui
self.target = repo
+ self.lpath = lpath or os.path.join(
+ self.target.root, DEFAULT_DATASTORE_DIRNAME
+ )
if not create:
if not '.hgreview' in repo['tip']:
raise UninitializedDatastore(False)
data = _parse_hgrf(repo)
- self.lpath = data['lpath']
self.rpath = data['rpath']
- datastore_root = os.path.join(self.target.root, self.lpath)
try:
- self.repo = hg.repository(_ui.ui(), datastore_root)
+ self.repo = hg.repository(_ui.ui(), self.lpath)
except error.RepoError:
raise UninitializedDatastore(True)
elif '.hgreview' in repo['tip']:
data = _parse_hgrf(self.target)
- self.lpath = data['lpath']
self.rpath = data['rpath']
if self.rpath.startswith('.'):
@@ -241,15 +242,11 @@
else:
self.rpath = rpath
- self.lpath = lpath or DEFAULT_DATASTORE_DIRNAME
-
with open(os.path.join(self.target.root, '.hgreview'), 'w') as hgrf:
- hgrf.write('local = %s\n' % self.lpath)
hgrf.write('remote = %s\n' % self.rpath)
self.target.add(['.hgreview'])
- self.repo = hg.repository(ui,
- os.path.join(self.target.root, self.lpath), create)
+ self.repo = hg.repository(ui, self.lpath, create)
def __getitem__(self, rev):
"""Return a ReviewChangeset for the given revision."""
--- a/review/extension_ui.py Tue Mar 02 19:04:41 2010 -0500
+++ b/review/extension_ui.py Tue Mar 02 19:35:19 2010 -0500
@@ -23,8 +23,7 @@
ui.note(messages.INIT_START)
try:
- ReviewDatastore(ui, repo, lpath=opts.pop('local_path'),
- rpath=opts.pop('remote_path'), create=True)
+ ReviewDatastore(ui, repo, rpath=opts.pop('remote_path'), create=True)
if '.hgreview' not in repo['tip'].files():
ui.status(messages.INIT_SUCCESS_UNCOMMITTED)
else:
@@ -302,7 +301,6 @@
cmdtable = {
'review': (review, [
('i', 'init', False, 'start code reviewing this repository'),
- ('', 'local-path', '', 'the local path to the code review data'),
('', 'remote-path', '', 'the remote path to code review data'),
('c', 'comment', False, 'add a comment'),
('s', 'signoff', False, 'sign off'),
@@ -322,15 +320,13 @@
(['review-init'],
('Initializing code review for a repository'),
(r"""
-hg review --init --remote-path PATH [--local-path PATH]
+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 called "code-review" in the root
- of the current repository. This name can be changed with the
- --local-path option.
+ * 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:
@@ -349,7 +345,6 @@
hg review --init --remote-path 'http://bitbucket.org/u/project-review'
hg review --init --remote-path '../project-review'
- hg review --init --local-path 'review_data' --remote_path '../project-review-data'
""")),
(['review-review'],
--- a/review/tests/test_init.py Tue Mar 02 19:04:41 2010 -0500
+++ b/review/tests/test_init.py Tue Mar 02 19:35:19 2010 -0500
@@ -22,26 +22,6 @@
with open('.hgreview', 'r') as hgrf:
hgr = hgrf.read()
- assert 'local = %s' % api.DEFAULT_DATASTORE_DIRNAME in hgr
- assert 'remote = /sandbox-review' in hgr
-
-
-@with_setup(setup_sandbox, teardown_sandbox)
-def test_init_with_local_path():
- sandbox = get_sandbox_repo()
-
- output = review(init=True, local_path='NEW', remote_path='/sandbox-review')
- assert messages.INIT_SUCCESS_UNCOMMITTED in output
-
- assert '.hgreview' not in sandbox['tip']
- assert os.path.exists('.hgreview')
- assert os.path.isdir('NEW')
- assert get_datastore_repo('NEW')
-
- with open('.hgreview', 'r') as hgrf:
- hgr = hgrf.read()
- print hgr
- assert 'local = NEW' in hgr
assert 'remote = /sandbox-review' in hgr
--- a/review/tests/util.py Tue Mar 02 19:04:41 2010 -0500
+++ b/review/tests/util.py Tue Mar 02 19:35:19 2010 -0500
@@ -8,17 +8,21 @@
_ui = ui.ui()
def review(init=False, comment=False, signoff=False, yes=False, no=False,
- force=False, message='', rev='.', local_path='', remote_path='', lines='',
- files=None, unified='5', web=False):
+ force=False, message='', rev='.', remote_path='', lines='', files=None,
+ unified='5', web=False):
if not files:
files = []
_ui.pushbuffer()
- extension_ui.review(_ui, get_sandbox_repo(), *files,
- **dict(init=init, comment=comment, signoff=signoff, yes=yes, no=no,
- force=force, message=message, rev=rev, local_path=local_path,
- remote_path=remote_path, lines=lines, unified=unified, web=web))
+ extension_ui.review(
+ _ui, get_sandbox_repo(), *files,
+ **dict(
+ init=init, comment=comment, signoff=signoff, yes=yes, no=no,
+ force=force, message=message, rev=rev, remote_path=remote_path,
+ lines=lines, unified=unified, web=web
+ )
+ )
output = _ui.popbuffer()
print output