# # # add_file "fileinbranch.psp" # content [edc84448ac7e5f385c9bdd38dcf8845f0ed35b52] # # patch "branch.psp" # from [a7d9fdaea138ee6ff579414103bc3b4cf5fd30d3] # to [6aa1b9028b1c1488f21d17d84172af75d1f059bb] # ============================================================ --- fileinbranch.psp edc84448ac7e5f385c9bdd38dcf8845f0ed35b52 +++ fileinbranch.psp edc84448ac7e5f385c9bdd38dcf8845f0ed35b52 @@ -0,0 +1,78 @@ +<% + +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.") +if not form.has_key('path'): + raise Exception("No path specified.") +branch = form['branch'] +path = form['path'] + +# fileinbranch.psp +# +# determine the latest version of the file +# in a branch (and present a choice iff there +# are multiple heads and the files difer in them) + +mt = Monotone(config.monotone, config.dbfile) + +heads = mt.heads(branch) +if len(heads) == 0: + raise Exception("No head ID can be determined for this branch.") + +# build a hash with a list of all files in each head which +# match PATH and their file ID. +file_version = {} +for id in heads: + revision = mt.revision(id) + manifest_id = revision['new_manifest'][0][0][1] + file_revisions = filter(lambda x: x[1] == path, mt.manifest(manifest_id)) + if len(file_revisions) > 1: + raise Exception("More than one file matches path?") + elif len(file_revisions) == 1: + file_version[id] = file_revisions[0][0] +if len(file_version.values()) == 0: + raise Exception("No file such file found in this branch.") + +unique = True +last = None +values = file_version.values() +for file_revision in values: + if last != None and file_revision != last: + unique = False + break + last = file_revision +if unique: + psp.redirect("getfile.py?id=%s" % (urllib.quote(values[0]))) +else: + hq = common.html_escape() + info = {'title' : "Latest version of %s in branch %s" % (hq(path), hq(branch))} + req.write(header(info)) +%> +

+The branch you have selected has multiple head revisions, and the file you are attempting +to access differs between them. The head revisions are listed below, along with +links to download "<%=hq(path)%>" from that revision. +

+ + +<% + for id in file_version.keys(): + req.write('' % (urllib.quote(id), hq(id), urllib.quote(file_version[id]))) + req.write(template.footer(info)) +%> + + + ============================================================ --- branch.psp a7d9fdaea138ee6ff579414103bc3b4cf5fd30d3 +++ branch.psp 6aa1b9028b1c1488f21d17d84172af75d1f059bb @@ -47,5 +47,5 @@ <% for id in heads: req.write('%s
' % (urllib.quote(id), hq(id))) - + req.write(template.footer(info)) %>
Revision IDView file
%sview