# # # patch "README" # from [51ea9bcf58e2383de5b13e36130946447ed07462] # to [86f9112184651535771db7b381225f3053a9d8f0] # # patch "templates/index.html" # from [5d46c8360e2af3a6dfa935e68ca9421502877d92] # to [3316f7e85ff5fcf0b00a20607bbc28d4bde92705] # # patch "viewmtn.py" # from [fe2ae21cd72112b293f7523e31338fc417759bf5] # to [fa5d204d1c2c236cf5c3ffe9910f705e8671c9fc] # ============================================================ --- README 51ea9bcf58e2383de5b13e36130946447ed07462 +++ README 86f9112184651535771db7b381225f3053a9d8f0 @@ -28,7 +28,7 @@ I generally sync all my changes to the following public monotone repositories: - venge.net + venge.net / off.net monotone.ucc.gu.uwa.edu.au You should be able to grab the latest viewmtn from any of them. ============================================================ --- templates/index.html 5d46c8360e2af3a6dfa935e68ca9421502877d92 +++ templates/index.html 3316f7e85ff5fcf0b00a20607bbc28d4bde92705 @@ -1,6 +1,18 @@ #extends base #def body + +

Welcome to this ViewMTN installation. The list below shows all branches served within this Monotone database. @@ -12,16 +24,19 @@ might be useful. might be useful.

- - -#for branch in $branches - - - + +#end if #end for
Branch
+#for t, did, branch, offset in $branches +#if $t == "d" +
[+] $branch.name
+ +#else +
#filter Filter $link($branch).html() #end filter -
============================================================ --- viewmtn.py fe2ae21cd72112b293f7523e31338fc417759bf5 +++ viewmtn.py fa5d204d1c2c236cf5c3ffe9910f705e8671c9fc @@ -358,9 +358,64 @@ mimeicon = icontheme.MimeIcon(icontheme. mimehelp = sharedmimeinfo.LookupHelper(getattr(config, "mime_map", None)) mimeicon = icontheme.MimeIcon(icontheme.IconTheme(config.icon_theme), config.icon_size) +from mk2 import MarkovChain + +class BranchDivisions: + def __init__ (self): + self.divisions = None + + def calculate_divisions (self, branches): + if self.divisions != None: + return + chain = MarkovChain (2, join_token='.') + for branch in branches: + chain.update (branch.name.split ('.')) + chain.upchunk () + divisions = set () + for branch in branches: + for chunk in chain.upchunked: + idx = branch.name.find (chunk) + if idx != -1: + divisions.add (branch.name[idx:idx+len(chunk)]) + self.divisions = list(divisions) + self.divisions.sort () + +divisions = BranchDivisions () + class Index: def GET(self): - renderer.render('index.html', page_title="Branches", branches=ops.branches()) + branches = map(None, ops.branches ()) + divisions.calculate_divisions (branches) + def division_iter(): + bitter = iter(branches) + divs = divisions.divisions + n_divs = len(divs) + in_divs = {} + look_for = 0 + def new_div (n): + did = look_for + in_divs[n] = did + return "d", did, mtn.Branch(n), len(in_divs.keys ()) * 10 + def end_div (n): + did = in_divs.pop (n) + return "e", did, mtn.Branch(n), len(in_divs.keys ()) * 10 + def branch_line (b): + return "b", 0, branch, 0 + for branch in bitter: + for div in in_divs.keys(): # we alter it in the loop, copy.. + if branch.name.find (div) != 0: + yield end_div (div) + if look_for < n_divs: + if cmp(branch, divs[look_for]) > 0: + look_for += 1 + if branch.name.find (divs[look_for]) == 0: + yield new_div (divs[look_for]) + look_for += 1 + yield branch_line (branch) + # any stragglers need to be closed + for div in in_divs: + yield end_div (div) + renderer.render('index.html', page_title="Branches", branches=division_iter()) class About: def GET(self):