# # # add_file "branch.psp" # content [dee26545ddf622a6929cdca3d57ecc994702c283] # # add_file "template.py" # content [5fa8881d0de41240ce269ee7c872954e93781c15] # # patch "index.psp" # from [8530dda4f3e1ec795d5959af3e8ff8b927e85811] # to [cc99e564d6cd74b36e6f02933716835ef785d73f] # # patch "monotone.py" # from [bf4c3ac8e895b6e5000f3a805c0d4c17295acf31] # to [af6a530e9a3782c715975ece4705dff54efc8f23] # ============================================================ --- branch.psp dee26545ddf622a6929cdca3d57ecc994702c283 +++ branch.psp dee26545ddf622a6929cdca3d57ecc994702c283 @@ -0,0 +1,61 @@ +<% + +import config +import monotone +import common +import urllib +import template +from template import header,footer +from monotone import Monotone + +reload(template) +reload(monotone) + +psp.set_error_page("error.psp") + +if not form.has_key('branch'): + raise Exception("No branch specified.") +branch = form['branch'] + +mt = Monotone(config.monotone, config.dbfile) + +# +# ok, what are we going to show to the user. +# we need a revision. if none has been provided, then we +# look if there is a single HEAD. If so, display that. +# Otherwise, display list of heads and offer the choice +# to choose them or another revision. +# +revision = None +if not form.has_key('revision'): + heads = mt.heads(branch) + if len(heads) == 0: + raise Exception("No head revision can be determined for this branch.") + elif len(heads) == 1: + revision = heads[0] + else: +%> +

+The following head revisions are available. Please select one to view. +

+<% + for revision in heads: + req.write('%s
' % (urllib.quote(branch), urllib.quote(revision), hq(revision))) +else: + revision = form['revision'] + +hq = common.html_escape() +info = {'title' : "Branch details for %s" % (hq(branch))} +req.write(header(info)) + +%> + +

+Viewing revision: <%=hq(revision)%> +

+ + +<% +req.write(footer(info)) +%> + ============================================================ --- template.py 5fa8881d0de41240ce269ee7c872954e93781c15 +++ template.py 5fa8881d0de41240ce269ee7c872954e93781c15 @@ -0,0 +1,24 @@ + +def header(info): + if not info.has_key("title"): info['title'] = "untitled" + return """\ + + + + +ViewMTN: %(title)s + + + + + + +

%(title)s

+
""" % (info) + +def footer(info): + return "
" ============================================================ --- index.psp 8530dda4f3e1ec795d5959af3e8ff8b927e85811 +++ index.psp cc99e564d6cd74b36e6f02933716835ef785d73f @@ -12,13 +12,14 @@ reload(monotone) psp.set_error_page("error.psp") -req.write(header({'title' : "List of branches"})) +info = { 'title' : "List of branches" } +req.write(header(info)) hq = common.html_escape() mt = Monotone(config.monotone, config.dbfile) -branches = mt.get_branches() +branches = mt.branches() %> @@ -41,7 +42,11 @@

<% - for branch in mt.get_branches(): + for branch in branches: req.write('%s
' % (urllib.quote(branch), hq(branch))) %> +<% +req.write(template.footer(info)) +%> + ============================================================ --- monotone.py bf4c3ac8e895b6e5000f3a805c0d4c17295acf31 +++ monotone.py af6a530e9a3782c715975ece4705dff54efc8f23 @@ -7,11 +7,17 @@ self.mt = mt self.dbfile = dbfile self.base_command = "%s --db=%s" % (self.mt, pipes.quote(self.dbfile)) - def get_branches(self): + def branches(self): result = utility.run_command(self.base_command + " ls branches") if result['exitcode'] != 0: raise Exception("Unable to list branches: %s" % (result['childerr'])) else: return filter(None, result['fromchild'].split('\n')) + def heads(self, branch): + result = utility.run_command(self.base_command + " automate heads %s" % (pipes.quote(branch))) + if result['exitcode'] != 0: + raise Exception("Unable to get list of heads: %s" (result['childerr'])) + else: + return filter(None, result['fromchild'].split('\n'))