Posts Tagged filesTouched
v1.0 Release Complete
Posted by Sid in DPS911, Mercurial Project, Open Source on April 24th, 2009
Well this is it guys. My last release for the open source course is finished! It has come at the right time too as this is my 100th blog post. So for this release I ended up doing quite a bit more than I originally planned to. It all kind of became hectic in the end because ted suddenly reviewed my OnScroll patch yesterday, which meant that I immediately had to fix the changes he outlined.
First of all I tackled the files touched patch. Jorendorff has mentioned a few times that it is important to show information in an unobtrusive manner. Now, this wasn’t being accomplished earlier and so I decided to put expand/collapse functionality for the files touched.
Next I tackled a new bug where I only wanted >5 merges to get expand/collapse functionality. Anything less than that should be left as it is. I’ve got that working now.
As I mentioned earlier, I also tackled the OnScroll patch. Over the course of these last eight months this has been the patch that I’ve worked on the most. In this release I’ve done a major rehaul. The client-side code looks very different now as I had to change it to work with the new hg_templates/pushlog.tmpl. Also, I’ve used a lot of jquery to make the code shorter and simpler. Furthermore, I’ve improved bug functionality even further and got the “To Local” link to work with the new entries that load on scroll. These were the goals that I had originally set out to meet and I’ve accomplished them
Now, as I said earlier ted, djc and Pike all gave me some feedback yesterday regarding my OnScroll patch. Thus, I had to make some last minute changes to my release. First of all I tackled a problem with the server side code that handles merges. Previously I was using a long string delimited by a random separator. Now, I’ve replaced that with a nice and simple dictionary data structure. This took a bit of time as I had to rehaul major parts of my client-side implementation so that it could properly read the data that was now being stored in dictionaries.
Furthermore, I moved all my JavaScript code to an external file since the amount of code was just getting to be too much to handle in script tags. I also changed how I deal with the parity counter and how I retrieve the maximum number of entries in the database. Lastly, I made a change in regards to pushlog queries. Beforehand, my code was causing more entries to load even when a user executed a query. That should not have been happening and now I’ve managed to fix that problem.
The following are the important links from this release:
- Goals
- Expand/collapse for files touched
- Expand/collapse only for >5 pushes in a merge
- Fixing OnScroll to work with the new version of hg_templates and using more jquery functionality
- Getting the Localize Dates Link Working with the New Entries Loaded On Scroll
- Further Improving Bug Functionality for the OnScroll Patch
- Changing the Data Structure that Handles Merges for the OnScroll Patch
- Moving to an external Js file, the parity counter, retrieving max entries and dealing with pushlog queries
Finally, the release is done! All the patches have been posted to their respective bug pages. Please view the project page for more information.
v1.0 Release - Expand/Collapse for the Files Touched Patch
Posted by Sid in DPS911, Mercurial Project, Open Source on April 20th, 2009
In my goals blog post I stated that I wanted to add expand/collapse functionality to the files touched patch. Why you ask? Well the whole goal is to get the pushlog to show more information but in an unobtrusive manner. Right now this isn’t happening. Adding expand/collapse functionality will allow the user to decide when he wants to see the files and when he doesn’t.
I recently wrote a white paper on the ergonomics of touch screens. One thing that I learnt from that exercise is that it is the application’s job to adapt to the user and not the other way around. The application will not succeed if the user is forced to adapt to the application. I think this concept applies to this situation where the pushlog provides the user the ability to hide or show the files touched instead of always showing them, which forces the user to adapt to the new look of the pushlog.
The Implementation
The map file
pushlogentry = '<tr class="parity#parity# #hidden# id#id#"><td>#push%pushinfo#</td><td class="age"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td><td><strong class="filerow">#author|person# — #desc|strip|escape|buglink#</strong><span class="filetouch fileid#id#">{filesTouched}</span> <span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}</span>#mergerollup%mergehidden#</td></tr>\n'
pushlog.tmpl
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | // hide files touched $('.filetouch').hide(); // Add expand/collapse link $('.filerow').each ( function(i) { if($(this).next().html() != "") { var pushid = ($(this).next().attr("class")).match(/fileid\d+/); $(this).html($(this).html() + "<br/><span class=\"filelink\">hidden files <a class=\"expandfile fileid" + pushid + "\" href=\"#\">[Expand]</a></span>"); } }); // add click handler to unhide hidden things $('.expandfile').click(function () { if ($(this).text() == "[Expand]") $(this).text("[Collapse]"); else $(this).text("[Expand]"); var pushid = $(this).attr("class"); pushid = '.' + pushid.match(/fileid\d+/); $(pushid).toggle(); return false; }); |
The above pushlog.tmpl code is placed inside $(document).ready(). As you can see I basically hide all the files touched data on line 40. Then, I go through each files touched span and create the appropriate expand/collapse link on line 42. Lastly, I have the click handler that is responsible for displaying or hiding the files touched span. One important thing to note is that I must have a unique id (”fileid” in this case) for each expand/collapse link so that I know which files touched span to toggle. Without this unique id clicking on any one link would cause all links to expand/collapse, which we obviously don’t want.

There we have it, a nice and easy solution to this problem.
v0.9 Release Complete
Posted by Sid in DPS911, Mercurial Project, Open Source on April 12th, 2009
All the goals for my v0.9 release have been accomplished and thus another release comes to an end. Looking back I ended up using quite a bit of jquery to fix my bugs. In the process I learnt some new things about the library that I didn’t know beforehand, such as how $(document).ready() works. The guys over at jquery have definitely done some good work.
Files touched
This patch had bitrotted as the pushlog had gone through a variety of changes since I had submitted it way back in 2008. Now, it is up to date and raring to go. I will most probably have another iteration for this patch though, where I add expand/collapse functionality to it. Although, I’ll have to get clearance from ted first though.
Changeset UI
Ted gave me an r- review since he didn’t like that I was removing what the user had entered in the text boxes if another item was selected from the drop down list. Also, he wanted the drop down list to remember which query type was last executed. I’ve managed to get both these features working and I also altered the code to take advantage of jquery, which is now available in hg_templates.
Line breaks turned into spaces
This was the new bug that I tackled this release. First of all I wanted to keep the line breaks instead of have them turned into spaces. I managed to do that. Next, I had to implement expand/collapse functionality for any commit messages that had more than one line break. Since I had experience doing this with another bug; I quickly managed to get this functionality working.
The following are the important links for this release:
- Goals
- v0.9 Release - Updating the Files Touched Patch
- v0.9 Release - Implementing changes to the Changset Query UI
- v0.9 Release - Contemplating the Implementation for the Line Break bug
- v0.9 Release - Fix for the Line Break bug
The patches have been posted to their respective bug pages. Please view the project page for further details.
v0.9 Release - Updating the Files Touched Patch
Posted by Sid in DPS911, Mercurial Project, Open Source on April 8th, 2009
So, as I had mentioned in my goals blog post, I would be updating my files touched patch to work with the new code now found in the repo. First of all lets have a look at my old code:
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | def changelist(limit=0, **map): allentries = [] lastid = None ch = None l = [] for id, user, date, node in entries: filesTouched = '' ctx = web.repo.changectx(node) if len(ctx.files()) > 1: for f in ctx.files(): filesTouched += f + '<br/>' else: for f in ctx.files(): filesTouched += f if id != lastid: lastid = id l.append({"parity": parity.next(), "user": user, "date": localdate(date), 'numchanges': 0, "changes": []}) ch = l[-1]['changes'] ctx = web.repo.changectx(node) n = ctx.node() ch.append({"author": ctx.user(), "desc": ctx.description(), "files": web.listfilediffs(tmpl, ctx.files(), n), "rev": ctx.rev(), "node": hex(n), "tags": nodetagsdict(web.repo, n), "branches": nodebranchdict(web.repo, ctx), "inbranch": nodeinbranch(web.repo, ctx), "parity": l[-1]["parity"], "filesTouched": filesTouched }) l[-1]['numchanges'] += 1 if limit > 0: l = l[:limit] for e in l: yield e |
pushlogchange = '<td class="age"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td><td><strong>#author|person# — #desc|strip|escape|buglink#</strong><br/><span style="font-size: x-small; color: #996633; font-weight: bold">#filesTouched#</span> <span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}</span></td></tr><tr class="parity#parity#">'pushlog-feed.py has changed quite a bit since I submitted this patch a few months back. Thus, I’ll have to change my code a bit. Even the map file has changed but my code itself (for the map file) won’t be changing much. I’ll just be placing it in a different area. Also, as you can see above I have the CSS within the span tag. That has to be moved to the a stylesheet.
Lets look at my solution:
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | def changelist(limit=0, **map): # useless fallback listfilediffs = lambda a,b,c: [] if hasattr(webutil, 'listfilediffs'): listfilediffs = lambda a,b,c: webutil.listfilediffs(a,b,c, len(b)) elif hasattr(web, 'listfilediffs'): listfilediffs = web.listfilediffs allentries = [] lastid = None ch = None l = [] mergehidden = "" filesTouched = "" p = 0 currentpush = None for id, user, date, node in query.entries: ctx = web.repo.changectx(node) n = ctx.node() entry = {"author": ctx.user(), "desc": ctx.description(), "files": listfilediffs(tmpl, ctx.files(), n), "rev": ctx.rev(), "node": hex(n), "tags": nodetagsdict(web.repo, n), "branches": nodebranchdict(web.repo, ctx), "inbranch": nodeinbranch(web.repo, ctx), "hidden": "", "push": [], "mergerollup": [], "filesTouched": filesTouched, "id": id } if id != lastid: lastid = id p = parity.next() entry["push"] = [{"user": user, "date": localdate(date)}] if len([c for c in ctx.parents() if c.node() != nullid]) > 1: mergehidden = "hidden" entry["mergerollup"] = [{"count": 0}] else: mergehidden = "" currentpush = entry else: entry["hidden"] = mergehidden if mergehidden: currentpush["mergerollup"][0]["count"] += 1 entry["parity"] = p for f in ctx.files(): entry["filesTouched"] += '<br/>' + f l.append(entry) if limit > 0: l = l[:limit] for e in l: yield e |
pushlogentry = '<tr class="parity#parity# #hidden# id#id#"><td>#push%pushinfo#</td><td class="age"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td><td><strong>#author|person# — #desc|strip|escape|buglink#</strong><span class="filetouch">{filesTouched}</span> <span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}</span>#mergerollup%mergehidden#</td></tr>\n'span.filetouch { font-family: sans-serif; color: #996633; }
I have reduced the server side code a little but I’ve managed to retain the same functionality, which is always great. I moved the declaration of the filesTouched variable to the top where the rest of the variable declarations occur.
So, the entry dictionary holds the filesTouched key/value. I set the value in my for loop at line 415. In my previous code I had an if/else statement, which I have now removed. This is because before I had a static line break in the map file right before the files are displayed. I removed that and just decided to add a line break before each file is displayed (line 416). Now I don’t have to worry about whether there is only one file touched or more than one and add a line break accordingly (which is what the old if/else statement was for).
Also, as you can see the CSS now cleanly resides in the style-gitweb.css stylesheet. I still don’t know about the text color though. Does it match the color scheme of the gitweb_mozilla template? Not really but I couldn’t find any other color that was both readable and matched the theme. I guess I could have left the text black but I wanted to differentiate it somehow. I guess this is the difference between a programmer and a designer eh?
In the future (maybe my next release) I’ll look to add expand/collapse functionality for this bug since many times just one push can touch a large amount of files. For now, I hope this gets reviewed and approved soon so that people can start reaping its benefits.
v0.9 Release Goals
Posted by Sid in DPS911, Mercurial Project, Open Source on April 8th, 2009
The end of the semester is approaching rapidly (only 2 weeks left) and so is my time here at Seneca. I can’t believe 4 years have gone by so fast. No time to think about my time after graduation though. I’m in engulfed in work right now, a typical situation this late in the semester. Anyway, it’s time for yet another release.
This time I’m not going to touch my major bug. Instead, I’ll be making changes to three other bugs this time around. I’ll be revisting one of the bugs that I fixed last semester (files touched). It had been approved for a long time now but the patch never got applied to the repo and it seems to have bitrotted now. The next bug I will be tackling is the changesetUI one for which I need to make some changes. Last but not the least, I’ll will take on a new bug regarding line breaks for long messages. The following are the goals for this release:
- Files touched - Update the patch to make it work with the new code in hgpoller and hg_templates. Also move the all the css to a stylesheet.
- Changeset UI - ted reviewed the patch that I submitted for this bug and he doesn’t want me to set the value when the drop down changes. This would mean that whatever the user has already entered would be overwritten. I guess it makes sense, since you want to avoid that from a usability standpoint. Also I will look to re-write the code to take advantage of jquery which has been added to the repo now. Furthermore, there is another query for the pushlog that takes in two pushids. I will be adding that to the drop down list as well.
- Line breaks turned into spaces - When a long message is displayed in the pushlog the linebreaks are not registered. My goal is to only show the first line and then show an ellipsis link that the user can click to show/hide the rest of the message that has the line breaks.
Fun stuff! Time to get to work!