v0.5 Release – My Fix for the hg Annotate Problem

In my last post I had examined a couple of patches that other people had posted for bug 459823. This time I wrote my own code to see if I could make an improvement on what others have done. I did borrow some things but my implementation will be a bit different.

HTML

Instead of using one large table to hold all the rows I’ve decided to use a single div that holds two links and another div:

annotateline = '<a class="codelineauthor" href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a><a class="codelinenumber" href="##lineid#" id="#lineid#">#linenumber#</a><div class="codeline parity#parity#">#line|escape#</div>'

The HTML is pretty simple, nothing fancy. All the formatting will be done by the CSS instead of a table.

CSS

I’ve decided to place my CSS in the style-gitweb.css style sheet instead of just leaving it in the fileannotate.tmpl file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
a.codelineauthor {
	width: 50ch;
	float: left; 
}
a.codelinenumber:hover,
a.codelinenumber:visited,
a.codelinenumber:active {
    color: #880000;
}
a.codelinenumber {
    text-decoration: none;
	margin-right: 0.5em;
	float: left;
	color:#999999;
}
div.completecodeline {
    font-size: 12px;
	line-height: 1.4em;
	font-family: monospace;
	white-space: pre;
	display: block;
}

The float property is used to align the two links and the div so that it looks like a table.

Result

The result is quite positive. This implementation cuts the loading time by ~12sec when testing a 10,000 line cpp file in mozilla-central. The loading time currently on live is ~20sec and my implementation cuts it to ~8sec. This is around the same amount of time that Bonsai takes to load the same file. The browser doesn’t freeze and the initial screenful appears immediately just as jorendorff specified.

It is interesting to note that the size of the page on live (with the HUGE table) is 3.2MB while my solution cuts the file size down to 2.4MB, a 25% reduction.

This entry was posted in DPS911, Mercurial Project, Open Source and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>