# # # patch "mtn.py" # from [5d4b39dca29ba0424ee0960951b19ae25641a4dd] # to [ef35d2dfd3db51e1dfe9231c0afd315570fab28e] # # patch "static/viewmtn.css" # from [86b42ee85d6360f44f94a5e2a0da26007246345c] # to [8981409323f375efedb9599c206ac0b34bdad739] # # patch "templates/revisionbrowse.html" # from [45348e21f3fc76b5cfa945ec4be8fbba1af7a267] # to [6b09eeedff5f706aeec8cc0372596cf537550fcb] # # patch "viewmtn.py" # from [5c41506fafddfc5f74233a652edda92f89be421e] # to [78f8a8a5059ca314bea367c341c121db7bbddb84] # ============================================================ --- mtn.py 5d4b39dca29ba0424ee0960951b19ae25641a4dd +++ mtn.py ef35d2dfd3db51e1dfe9231c0afd315570fab28e @@ -197,6 +197,12 @@ class File(MtnObject): self.name = name self.in_revision = in_revision +class Dir(MtnObject): + def __init__(self, name, in_revision): + MtnObject.__init__(self, "dir") + self.name = name + self.in_revision = in_revision + basic_io_name_tok = re.compile(r'^(\S+)') def basic_io_from_stream(gen): ============================================================ --- static/viewmtn.css 86b42ee85d6360f44f94a5e2a0da26007246345c +++ static/viewmtn.css 8981409323f375efedb9599c206ac0b34bdad739 @@ -47,11 +47,11 @@ TABLE.pretty TH { padding-right: 0.5em; } -TR.odd { +TR.even { background-color: #eeeeee; } -TR.even { +TR.odd { background-color: #ffffff; } ============================================================ --- templates/revisionbrowse.html 45348e21f3fc76b5cfa945ec4be8fbba1af7a267 +++ templates/revisionbrowse.html 6b09eeedff5f706aeec8cc0372596cf537550fcb @@ -1,15 +1,21 @@ #extends revision #def body #filter Filter

-Path [$path] in revision $link($revision).html() +Current directory: +#for $l in $path_links +$link($l).html() +#end for +

+ +These files are in a revision of #if len($branches) == 1 -of branch +branch #end if #if len($branches) > 1 -of branches +branches #end if #if $branches $branch_links ============================================================ --- viewmtn.py 5c41506fafddfc5f74233a652edda92f89be421e +++ viewmtn.py 78f8a8a5059ca314bea367c341c121db7bbddb84 @@ -113,6 +113,17 @@ class DiffLink(Link): self.relative_uri += '/'+urllib.quote(diff.fname) self.description = "diff" +class DirLink(Link): + def __init__(self, file, **kwargs): + Link.__init__(*(self, ), **kwargs) + # handle the root directory + if file.name == '/': + fn = '' + else: + fn = file.name + self.relative_uri = 'revision/browse/' + file.in_revision + '/' + urllib.quote(fn) + self.description = hq(file.name) + class FileLink(Link): def __init__(self, file, **kwargs): Link.__init__(*(self, ), **kwargs) @@ -206,6 +217,7 @@ type_to_link_class = { 'branch' : BranchLink, 'diff' : DiffLink, 'file' : FileLink, + 'dir' : DirLink, 'revision' : RevisionLink, 'tag' : TagLink, } @@ -481,7 +493,7 @@ class RevisionBrowse(RevisionPage): path_components = components(path) normalised_path = '/'.join(path_components) # TODO: detect whether or not this exists and skip the following if it doesn't. - page_title = "Browsing revision %s [%s]" % (revision.abbrev(), normalised_path or '') + page_title = "Browsing revision %s: dir %s/" % (revision.abbrev(), normalised_path or '') if len(branches) > 0: if len(branches) == 1: @@ -532,14 +544,16 @@ class RevisionBrowse(RevisionPage): certs = {} certinfo = {} - def get_cert(cert): - if not certs.has_key(cert): - certs[cert] = ops.certs(cert) - return certs[cert] + def get_cert(revision): + if not certs.has_key(revision): + # subtle bug slipped in here; ops.cert() is a generator + # so we can't just store it in a cache! + certs[revision] = map(None, ops.certs(revision)) + return certs[revision] - def _get_certinfo(cert): + def _get_certinfo(revision): author, ago, shortlog = None, None, None - for cert in get_cert(cert): + for cert in get_cert(revision): if cert[4] != 'name': continue name, value = cert[5], cert[7] @@ -553,10 +567,10 @@ class RevisionBrowse(RevisionPage): to_return = (author, ago, shortlog) return [t or "" for t in to_return] - def get_certinfo(cert): - if not certinfo.has_key(cert): - certinfo[cert] = _get_certinfo(cert) - return certinfo[cert] + def get_certinfo(revision): + if not certinfo.has_key(revision): + certinfo[revision] = _get_certinfo(revision) + return certinfo[revision] for stanza_type, this_path in entry_iter: # determine the most recent of the content marks @@ -569,20 +583,24 @@ class RevisionBrowse(RevisionPage): author, ago, shortlog = get_certinfo(content_mark) else: author, ago, shortlog, content_mark = "", "", "", None - yield (stanza_type, mtn.File(this_path, revision), nbhq(author), ago, content_mark, shortlog) + if stanza_type == "file": + file_obj = mtn.File(this_path, revision) + else: + file_obj = mtn.Dir(this_path, revision) + yield (stanza_type, file_obj, nbhq(author), ago, content_mark, shortlog) def path_links(components): # we always want a link to '/' - links = ["/"] + yield mtn.Dir('/', revision) running_path = "" for component in components: running_path += component + "/" - links.append(running_path) + yield mtn.Dir(running_path, revision) def row_class(): while True: + yield "odd" yield "even" - yield "odd" renderer.render('revisionbrowse.html', branches=branches,