#
#
# add_file "templates/branchchoosehead.html"
# content [797652bd041e66b5a2a2569c9c88896040d3e51d]
#
# patch "viewmtn.py"
# from [b7505915964d790e9c43161a9997245a5a8c5610]
# to [799f97ff9d48c4db23fa2308194e247752df2ddc]
#
============================================================
--- templates/branchchoosehead.html 797652bd041e66b5a2a2569c9c88896040d3e51d
+++ templates/branchchoosehead.html 797652bd041e66b5a2a2569c9c88896040d3e51d
@@ -0,0 +1,23 @@
+#extends branch
+
+#def body
+
+
+There are multiple head revisions of the branch $branch. You can access the method '$proxy_to' on
+each of these revisions by clicking on the links provided below. If you are attempting to access
+this method in a script, perhaps consider using this
+#filter Filter
+$anyhead
+#filter WebSafe
+which will always go directly to one of the head revisions.
+
+
+
+#for $head_link in $head_links
+ #filter Filter
+ - $head_link
+ #filter WebSafe
+#end for
+
+
+#end def
============================================================
--- viewmtn.py b7505915964d790e9c43161a9997245a5a8c5610
+++ viewmtn.py 799f97ff9d48c4db23fa2308194e247752df2ddc
@@ -755,6 +755,33 @@ class Json:
def GET(self, method, data):
print "Bah."
+class BranchHead:
+ def GET(self, head_method, proxy_to, branch):
+ debug("here we are, ladies and gents")
+ valid = ('browse', 'file', 'downloadfile', 'info', 'tar', 'graph')
+ if not proxy_to in valid:
+ return web.notfound()
+ heads = [head for head in ops.heads(branch)]
+ if len(heads) == 0:
+ return web.notfound()
+ def proxyurl(revision):
+ return dynamic_join('/revision/' + proxy_to + '/' + revision)
+ if len(heads) == 1 or head_method == 'anyhead':
+ debug(proxyurl(heads[0]))
+ web.redirect(proxyurl(heads[0]))
+ else:
+ # present an option to the user to choose the head
+ anyhead = dynamic_join('/branch/anyhead/' + proxy_to + '/' + branch)
+ head_links = []
+ for revision in heads:
+ head_links.append('%s' % (proxyurl(revision), revision))
+ renderer.render('branchchoosehead.html',
+ page_title="Branch %s" % branch.name,
+ branch=branch,
+ proxy_to=proxy_to,
+ anyhead=anyhead,
+ head_links=head_links)
+
branch_re = r''
urls = (
r'/', 'Index', #done
@@ -777,7 +804,13 @@ urls = (
r'/branch/changes/([^/]+)()()', 'HTMLBranchChanges',
r'/branch/changes/(.*)/from/(\d+)/to/(\d+)/rss', 'RSSBranchChanges',
r'/branch/changes/([^/]+)()()/rss', 'RSSBranchChanges',
- r'/branch/head/([^/]+)', 'BranchHead',
+
+ # let's make it possible to access any function on the head revision
+ # through this proxy method; it'll return a redirect to the head revision
+ # with the specified function
+ r'/branch/(head)/([A-Za-z]+)/([^/]+)', 'BranchHead',
+ r'/branch/(anyhead)/([A-Za-z]+)/([^/]+)', 'BranchHead',
+
r'/branch/tar/([^/]+)', 'BranchTar',
r'/static/(.*)', 'Static'