Archive for February, 2009
Using Gmail with hg’s Patchbomb Extension
Posted by Sid in Open Source on February 24th, 2009
I recently created a patch for the Mercurial Project and in order to submit the patch I had to use hg’s patchbomb extension. Unfortuantely that requires me to have SMTP on my system. I didn’t have that so either I needed to install SMTP or figure out a way to use Gmail. I decided to use Gmail but it took me a while to get it working because I couldn’t really find much help on the web. Since nobody seems to have explained how to do this properly I decided I’ll just put out a simple guide. Here it is:
- Open up your repo’s .hgrc file
- Add the following:
[extensions]
hgext.patchbomb =
[email]
from=[your_name] [<your_email>]
method=smtp
[smtp]
host=smtp.gmail.com
port=587
username=[gmail_email_address]
password=[gmail_password]
tls=True
v0.6 Release Complete
Posted by Sid in DPS911, Mercurial Project, Open Source on February 22nd, 2009
I’m finally done with my v0.6 release. This time around I’ve managed to put out a total of 5 patches for 3 bugs. The patch fix for bug 445560 was minor but needed. The second patch was for the Mercurial Project to fix hg annotate for their paper theme. This is my first contribution to the Mercurial project which will hopefully give all mercurial users access to a better hg annotate. The third patch was for bug 459727 to fix the bitrotting issue.
I have to say that I was able to get these patches working without much trouble which isn’t normally the case. I’m happy to say that I was more efficient in my work this time around. The only furstrating problem I had with this release was indenting issues when creating patches. I had to tinker with the patches quite a few times to get the indenting right. Nonetheless, another release is complete, the following are the important links:
- Release goals
- Minor fix for bug 445560
- Fixing Annotate for the Paper Theme
- Examining the Changes with hgpoller/pushlog-feed.py
- Refactoring to Fix the Bitrotting Issue with Bug 459727
- Removing the Page Navigation Links from Pushloghtml
EDIT: The patch for the paper theme has been sent to the Mercurial developer’s mailing list.
v0.6 Release - Refactoring to Fix the Bitrotting Issue with Bug 459727
Posted by Sid in DPS911, Mercurial Project, Open Source on February 21st, 2009
I had mentioned in my previous blog post that hgpoller/pushlog-feed.py had bitrotted. One of my goals for this release was to make changes to the current version of pushlog-feed.py so that my patch is no longer broken for bug 459727. I’ve finally made those changes, which mainly occur in pushes_worker(). The following is what this method looks like with my changes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | def pushes_worker(query, repo): """Given a PushlogQuery, return a data structure mapping push IDs to a map of data about the push.""" pushes = {} for id, user, date, node in query.entries: mergeData = [] ctx = repo.changectx(node) if len(ctx.parents()) > 1: for cs in ctx.parents(): mergeData.append(hex(cs.node()) + '|-|' + clean(person(cs.user())) + '|-|' + clean(cs.description())) if id in pushes: # we get the pushes in reverse order pushes[id]['changesets'].insert(0, node) pushes[id]['mergeData'].append(mergeData) else: pushes[id] = {'user': user, 'date': date, 'changesets': [node], 'formattedDate': util.datestr(localdate(date)), 'individualChangeset': hex(ctx.node()), 'author': clean(person(ctx.user())), 'desc': clean(ctx.description()), 'mergeData': mergeData, 'max': gettotalpushlogentries(conn) } return pushes |
Basically I had to pass in repo (web.repo) so that I could have access to repo.changectx(node). This now allows me access to ctx.parents() which I need to retrieve merge changeset data. I also went through the whole file and changed every instance where pushes_worker() was called so that repo was being passed in as a paramater along with query.
These are all the changes I needed to make to the server side code. Now I’ll have to examine the changes that were made to the client side which caused my patch to bitrot.
v0.6 Release - Examining the Changes with hgpoller/pushlog-feed.py
Posted by Sid in DPS911, Mercurial Project, Open Source on February 20th, 2009
I had mentioned in my v0.6 goals blog post that my patch for bug 459727 had bitrotted. Unfortunately significant changes were made to hgpoller which apparently broke my patch. I need to remedy this situation because all my server side functionality for this patch is in the pushlog-feed.py file.
I downloaded the latest hgpoller source code and had a look at the changes that had been made. The file has changed in quite a few places. It seems that the function that my patch alters has been changed as well. I’m talking about pushes_worker(), which is repsonsible for passing the data from the server side to the client side.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | def pushes_worker(query): """Given a PushlogQuery, return a data structure mapping push IDs to a map of data about the push.""" pushes = {} for id, user, date, node in query.entries: if id in pushes: # we get the pushes in reverse order pushes[id]['changesets'].insert(0, node) else: pushes[id] = {'user': user, 'date': date, 'changesets': [node] } return pushes |
Now, the problem is that I need access to web.repo within pushes_worker() so that I can call repo.changectx(node) but right now, I don’t have access to repo within the method. I’ll have to figure out a way to do that somehow.
v0.6 Release - Fixing Annotate for the Paper Theme
Posted by Sid in DPS911, Mercurial Project, Open Source on February 17th, 2009
In my last release I had put out an hg annotate fix for the gitweb_mozilla theme. Dirkjan Ochtman, a Mercurial Project developer, noticed my release and asked me to come up with a similar fix for the Mercurial Project’s paper theme. I decided to take up the task and see if I could get similar results for the paper theme as I did with gitweb_mozilla.
The paper theme uses a HUGE table to display the results just like gitweb_mozilla. I tested the current version of the theme using a large 10,000 line cpp file. It gave me a loading time of ~30sec, which is ~10sec longer than gitweb_mozilla.
The following is the code to fix annotate:
map
annotateline = '<div class="l#parity#"><div class="codeauthor"><a href="{url}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}#{targetline}" title="{node|short}: {desc|escape|firstline}">{author|user}@{rev}</a></div><a class="codeline" href="#{lineid}" id="{lineid}">{linenumber}</a>{line|escape}</div>'style-paper.css
div.codeauthor { display:inline-block; width:16ch; text-align: right; color:#999999; text-decoration:none; margin-right: 25em; } a.codeline { color:#999999; text-decoration:none; margin:0 10px; } div.l0 { background-color:#f6f6f0; } div.l0, div.l1 { display:block; } pre.completecodeline { font-size: 90%; line-height:1.4em; font-family: monospace; white-space: pre; } div.headrev { float: left; margin-right: 32em; margin-left: 8em; font-size: 90%; font-weight: bolder; } div.headline { font-weight: bolder; font-size: 90%; }
I changed the code (see above) and tested annotate again to examine the difference in loading time. I got some surprising results. The reduction in file size was not significant at all. The fix for gitweb_mozilla brought down the file size by 25%. However, in this case the reduction in file size wasn’t nearly as significant. Also the reduction in loading time for gitweb_mozilla was ~15sec but for the paper theme the loading time was only reduced by ~12secs. Currently, on my machine the loading time has gone down from ~30secs to ~18secs.
The speed increase isn’t as signficant for the paper theme as it was for gitweb_mozilla. Why is that? I don’t exactly know. Obviously there are other factors coming into play that aren’t allowing a similar speed boost. Nonetheless, there is a noticeble increase in loading times.
v0.6 Release Goals
Posted by Sid in DPS911, Mercurial Project, Open Source on February 15th, 2009
It’s time to start working on my 3rd release for this semester. My goal is to put out 3 patches this time around:
- A patch for the Mercurial Project’s Paper theme (fix for hg annotate, similar to what I did in v0.5)
- A small fix to bug 445560 so that it can finally go live
- A patch to update pushlogfeed.py for bug 459727 since it seems that the code has bitrotted and is no longer acceptable.
These 3 patches should combine to make a good solid release. These are 3 seperate improvements to hgweb that I’m sure users must be looking forward to having. I’m not quite sure what changes have been made to pushlogfeed.py causing it to bitrot. The solution to the problem may be simple or it may be complicated. I was under the impression that no changes needed to be made but new code has been added causing my code to break. Another exciting prospect is that I’ll have my name added to the Mercurial Project once I implement the annotate fix for the paper theme making my work available to all hgweb users.
I’ll be putting all the details of my work on the project page and this blog. Time to get to work!
v0.5 Release Complete
Posted by Sid in DPS911, Mercurial Project, Open Source on February 7th, 2009
I’ve finally completed my 0.5 release. This release I tackled an interesting problem with hg annotate. Trying to improve efficiency and loading time of an application isn’t something I had tackled before. It was a good experience trying to figure out the solution to this problem. I’ll be putting up a new patch on the bug page very soon. The following are some of the important links for this release:
- The release goals
- Understanding the problem
- Examining other templates
- Examining two older patches
- My fix for the problem
- Running an experiment
View the project page for more details.
EDIT: I’ve posted the patch for this release. Have a look…
v0.5 Release - Running an Experiment
Posted by Sid in DPS911, Mercurial Project, Open Source on February 7th, 2009
In my last post I revealed my fix for the hg annotate loading issues. My fix reduced the loading time to a relatively reasonable ~8sec considering the fact that currently the loading time is ~20sec. However, it was still bugging me that Mat’s implementation was producing faster loading times than my fix. His implementation is ~1sec faster.
Mat’s Implementation
The problem is that this implementation doesn’t use valid HTML. Mat uses two non-standard tags, x and l#parity#. Although, I must say that this is a very unorthodox and smart solution to this problem:
annotateline = '<l#parity#><x><a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></x><a href="##lineid#" id="#lineid#">#linenumber#</a>#line|escape#</l#parity#>'Altering Mat’s Code into Valid HTML
As an experiment I decided to test what would happen if I took Mat’s code and replaced the x and l#parity# tags with divs. Would the implemenation still remain as fast? Would it still be faster than mine? The following is the altered code:
annotateline = '<div class="l#parity#"><div class="codeauthor"><a href="#url#diff/#node|short#/#file|urlescape#{sessionvars%urlparameter}">#author|obfuscate#@#rev#</a></div><a class="codeline" href="##lineid#">#linenumber#</a>#line|escape#</div>'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | div.codeauthor { display:inline-block; width:16ch; text-align: right; color:#999999; text-decoration:none; margin-right: 25em; } a.codeline { color:#999999; text-decoration:none; margin:0 10px; } div.l0 { background-color:#f6f6f0; } div.l0, div.l1 { display:block; } pre.completecodeline { font-size:12px; line-height:1.4em; } a.codeline:hover, a.codeline:visited, a.codeline:active { color: #880000; } |
Results
I tried testing the altered code and I was getting a loading time of ~7sec for this cpp file. However, I was never able to get into the ~5sec region which Mat’s original code was sometimes able to achieve. This altered version was only able to reach a minimum time of ~6sec.
The point is that this altered version is a bit faster than my fix but slower than Mat’s original implementation. I compared the file sizes of the 3 versions:
- My fix: 2.4MB
- Mat’s Fix:1.8MB
- Altered version of Mat’s Fix: 2.2MB
It is interesting to note that using div tags instead of an x and l#parity# tag increases the file size by 18%. I don’t know why that happens but somehow the x and l#parity# tags are more efficient than div tags. Nonetheless the reasons don’t matter, the altered version of Mat’s fix seems to be the best solution to this problem at this time.