--- a/review/api.py Tue Nov 10 19:08:11 2009 -0500
+++ b/review/api.py Thu Nov 12 20:54:09 2009 -0500
@@ -6,6 +6,7 @@
import file_templates, messages
from mercurial import cmdutil, error, hg, patch, util
from mercurial.node import hex
+from mercurial import ui as _ui
DEFAULT_DATASTORE_DIRNAME = 'code-review'
@@ -191,7 +192,7 @@
datastore_root = os.path.join(self.target.root, self.lpath)
try:
- self.repo = hg.repository(ui, datastore_root)
+ self.repo = hg.repository(_ui.ui(), datastore_root)
except error.RepoError:
raise UninitializedDatastore(True)
elif '.hgreview' in repo['tip']:
--- a/review/web_media/style.css Tue Nov 10 19:08:11 2009 -0500
+++ b/review/web_media/style.css Thu Nov 12 20:54:09 2009 -0500
@@ -20,6 +20,20 @@
div#head-wrap h1 a, div#head-wrap h1 {
font-weight: normal;
}
+div#remote-wrap {
+ text-align: center;
+ padding-top: 1.5em;
+ margin-bottom: -1.5em;
+}
+div#remote-wrap span.remote-section h3 {
+ display: inline;
+}
+div#remote-wrap span.remote-section {
+ margin: 0em 1em;
+}
+div#remote-wrap form {
+ display: inline;
+}
div#footer {
border-top: 6px solid #666;
color: #fff;
--- a/review/web_templates/base.html Tue Nov 10 19:08:11 2009 -0500
+++ b/review/web_templates/base.html Thu Nov 12 20:54:09 2009 -0500
@@ -18,6 +18,24 @@
<h1><a href="/">${ basename(rd.target.root) }</a> $:{ title }</a></h1>
</div>
<div id="content-wrap">
+ <div id="remote-wrap">
+ <span id="remote-push" class="remote-section">
+ <h3>Push comments to:</h3>
+ $for name, path in rd.repo.ui.configitems("paths"):
+ <form action="/push/" method="get">
+ <input type="hidden" name="path" value="${ name }" />
+ <input type="submit" value="${ name }" />
+ </form>
+ </span>
+ <span id="remote-pull" class="remote-section">
+ <h3>Pull comments from:</h3>
+ $for name, path in rd.repo.ui.configitems("paths"):
+ <form action="/pull/" method="get">
+ <input type="hidden" name="path" value="${ name }" />
+ <input type="submit" value="${ name }" />
+ </form>
+ </span>
+ </div>
<div id="main-wrap">
$:{ content }
</div>
--- a/review/web_ui.py Tue Nov 10 19:08:11 2009 -0500
+++ b/review/web_ui.py Thu Nov 12 20:54:09 2009 -0500
@@ -2,7 +2,7 @@
import sys, os
import api
-from mercurial import cmdutil
+from mercurial import cmdutil, hg
package_path = os.path.split(os.path.realpath(__file__))[0]
template_path = os.path.join(package_path, 'web_templates')
@@ -20,6 +20,8 @@
'/', 'index',
'/media/([^/]*)', 'media',
'/review/([\da-f]{12})/?', 'review',
+ '/push/', 'push',
+ '/pull/', 'pull',
)
@@ -76,6 +78,31 @@
raise web.seeother('/review/%s/' % node_short)
+class push:
+ def GET(self):
+ path = web.input()['path']
+ dest, revs, checkout = hg.parseurl(_rd.repo.ui.expandpath(path, path), None)
+ other = hg.repository(cmdutil.remoteui(_rd.repo, {}), dest)
+
+ _rd.repo.push(other, True, revs=revs)
+
+ raise web.seeother('/')
+
+
+class pull:
+ def GET(self):
+ path = web.input()['path']
+ source, revs, checkout = hg.parseurl(_rd.repo.ui.expandpath(path, path), None)
+ other = hg.repository(cmdutil.remoteui(_rd.repo, {}), source)
+
+ modheads = _rd.repo.pull(other, heads=revs, force=True)
+
+ if modheads:
+ hg.update(_rd.repo, 'tip')
+
+ raise web.seeother('/')
+
+
class media:
def GET(self, fname):
if '..' in fname: