Merge lp:~mkanat/loggerhead/view-default into lp:loggerhead
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Max Kanat-Alexander on 2010-12-01 | ||||
| Approved revision: | 435 | ||||
| Merged at revision: | 433 | ||||
| Proposed branch: | lp:~mkanat/loggerhead/view-default | ||||
| Merge into: | lp:loggerhead | ||||
| Diff against target: |
449 lines (+149/-91) 9 files modified
loggerhead/apps/branch.py (+2/-0) loggerhead/controllers/annotate_ui.py (+54/-0) loggerhead/controllers/view_ui.py (+33/-48) loggerhead/highlight.py (+4/-2) loggerhead/static/css/view.css (+14/-12) loggerhead/templatefunctions.py (+2/-2) loggerhead/templates/inventory.pt (+8/-8) loggerhead/templates/revision.pt (+2/-2) loggerhead/templates/view.pt (+30/-17) |
||||
| To merge this branch: | bzr merge lp:~mkanat/loggerhead/view-default | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Martin Pool | Approve on 2010-12-01 | ||
| Michael Hudson-Doyle | 2010-11-30 | Approve on 2010-12-01 | |
|
Review via email:
|
|||
Commit Message
Create a new "view" controller, and have that be the default view of a file.
Description of the Change
This adds a new controller, "view", and makes it the default for viewing a file, instead of "annotate". The "view" controller is just like "annotate", except that it doesn't show the revision for each line. This should significantly improve the performance of loggerhead, particularly on high-level installations (like launchpad) or on large branches (such as launchpad itself) because most of the time, people don't need the annotated information for a branch--they just want to see its content.
In actual tests, the "view" controller is between 3x and 10x faster than the "annotate" controller. (To see similar gains to these, try viewing a large file on the launchpad devel branch without any existing caches in loggerhead.)
The "view" and "annotate" controller both use the same templates, and I've renamed all of the templates and CSS to "view" instead of "annotate" (since we now think of "annotate" as a special case of "view"). I've moved annotate_ui.py to view_ui.py and created a brand-new annotate_ui.py over the old one.
| Max Kanat-Alexander (mkanat) wrote : | # |
> I think it's mostly fine. The template is ugly though. Why do you need to
> put a None at the end of the annotation iterator? It would be better to pad
> out the results until you've reached the length of the text lines, or
> something.
That's true, I could do that, but that would also then involve code for keeping track of when there were extra lines in 'contents' that were beyond how far along we were with annotating. Would simplify the template, though, which I think is a valid goal. I think the problem is that 'contents' contains an extra final line when there's a "\n" at the end of the file, and annotate_iter doesn't consider that to be a line.
> If you're going to rename the annotation css file, you should probably rename
> the rules therein too.
Yeah, I suppose you're right. I was trying to keep the changes at least *somewhat* focused though, so that they could be reviewed sensibly. But now that it's passed review I'll just do that change.
> Everything else looks ok. Loading the annotation information via ajax would
> be nice, but can wait :-)
Yeah, I had the same thought.
| Martin Pool (mbp) wrote : | # |
That looks plausible to me, and reasonably clean.
As we discussed elsewhere, it would be good to get this onto the Launchpad deployment branch separately from changes in loggerhead trunk that are possibly more risky, such as historydb.
I wish there was an automatic test included here, but if there is no framework in place I won't ask you to write one as part of this proposal.
- 433. By Max Kanat-Alexander on 2010-12-01
-
Instead of yielding None for when there are more lines than annotate_iter
has, just fix the off-by-one bug that made us have too many lines in
"contents" (caused by annotate_iter using split_lines and us using
split("\n") in highlight()). - 434. By Max Kanat-Alexander on 2010-12-01
-
The colors of rows in the annotated view wasn't getting set properly. There
would be a revision number, and then the *next* line would change color. - 435. By Max Kanat-Alexander on 2010-12-01
-
Rename the anno* CSS classes to view*.

Yay for progress on this!
I think it's mostly fine. The template is ugly though. Why do you need to put a None at the end of the annotation iterator? It would be better to pad out the results until you've reached the length of the text lines, or something.
If you're going to rename the annotation css file, you should probably rename the rules therein too.
Everything else looks ok. Loading the annotation information via ajax would be nice, but can wait :-)
Cheers,
mwh