Posts Tagged templates

v0.5 Release - Examining How Other Templates Implement Hg Annotate

In order to complete the goals for my v0.5 release I examined how other templates implement hg annotate. I wanted to find out whether these other implementations had the ability to load 10,000 line cpp files quickly or not.

Default Template

Hgweb comes with a default template, which is quite ugly if you ask me but maybe it is efficient. I put together my local hgweb environment to use the default template and I was able to get a time of ~12secs. However, there was a major problem with this template. I noticed that after about 2000 lines the rest of the lines stopped showing up. The page kept loading new content but as I scrolled down the rest of the page was completely blank. None of the other 8000 or so lines of code were visible. This problem means that this template is of no use to me.

Coal Template

The next step was to try the coal template, which strangely doesn’t look very different from the default template. I configured my local hgweb environment to use the coal template and I got a time of ~14secs. This is not a significant improvement over Mozilla’s template which was clocking in at ~20secs but it is definitely better. Any reduction in loading time is a good thing. The problem is that gitweb_mozilla (the template that Mozilla uses) and the Coal template both use the same type of implementation. They both use one HUGE table to display the file, which obviously is not the correct method to employ (see below).

gitweb_mozilla

<div class="page_body">
  <table border="0">
    #annotate%annotateline#</table>
</div>

coal

<div class="overflow">
  <table class="bigtable" border="0">
    <tr>
      <th class="annotate">rev</th>
      <th class="lineno">line</th>
      <th class="line">source</th>
    </tr>
    {annotate%annotateline}
  </table>
</div>

Neither of these templates have been able to help me to solve my problem. Next I’ll be having a look at some of the patches that people put up on the bug page. Lets see if they improve annotate’s loading time or not.

, , ,

No Comments

v0.2 Release - Showing the Correct Author Name for bug 459727

My v0.2 for the pushlog is coming along at a steady pace. There are still some problems but hopefully I will have them solved soon. Right now, the following is how new entries look like OnScrollDown:

http://sidkalra.com/files/mercurial/improvedPushlog2.png

Now have a look at the author column (in the above image). Sometimes the text under that column is a name while other times it is an email. This is not the functionality I want. It should always be a name, never the email (there is already a column for that). Currently I am using ctx.user() to populate the author column. This obviously doesn’t give me the right data. I can’t use the user column straight from the db (I already use it to populate the email column) since it doesn’t give me the author name either.

I need to find some other way of acquiring the author name. I was wondering if there is some other ctx function that I could use to acquire the right data. I tried guessing it by going ctx.author() or ctx.person() or ctx.name() but no luck so far.

I had a look at how it is done for the initially loaded data. The answer is in the map file. The author name is printed by going #author|person#. I don’t really understand what that means and how this variable gets the correct author name for each row. I’ll have to consult ted, djc or jorendorff on this issue.

EDIT: I’ve managed to fix this issue. It was actually quite simple in the end. I had a talk with ted and we discussed what #author|person# does. He said it was just a filter that takes whatever is in ctx.user() and tries to remove the email. I needed to do something similar for my solution so bsmedberg recommended importing mercurial.templatefilters.person which will allow me to perform person(ctx.user()) which returns the name every time. Problem solved! View the result

, , , ,

No Comments