# HG changeset patch # User Steve Losh # Date 1258077249 18000 # Node ID 666bc8af55a3f82b1c1fa44b3be76108cdd66da6 # Parent 91bd7fd0bd9828cefdabbc975b18c59af7a2d105 Add push and pull buttons on every page. diff -r 91bd7fd0bd98 -r 666bc8af55a3 review/api.py --- 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']: diff -r 91bd7fd0bd98 -r 666bc8af55a3 review/web_media/style.css --- 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; diff -r 91bd7fd0bd98 -r 666bc8af55a3 review/web_templates/base.html --- 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 @@

${ basename(rd.target.root) } $:{ title }

+
+ +

Push comments to:

+ $for name, path in rd.repo.ui.configitems("paths"): +
+ + +
+
+ +

Pull comments from:

+ $for name, path in rd.repo.ui.configitems("paths"): +
+ + +
+
+
$:{ content }
diff -r 91bd7fd0bd98 -r 666bc8af55a3 review/web_ui.py --- 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: