As part of my v0.2 release I wanted to fix bug 448707. It is aparently a very desired feature by the community. Adding this featue definitely makes it easier to immediately find out which files were touched while right now one has to click the changset link to do that.
Initial Thoughts
I talked to ted and jorendorff about how they thought I should go about implementing this feature. ted recommended using the http://hg.mozilla.org/mozilla-central/pushlog feed which returns the files touched. I thought I could use an XMLHttpRequest to get the data to the front-end and then format it. But after looking at the code I decided that that wasn’t the way to go. I decided to format the data on the back-end and then just print it through the map file exactly how everything else in the pushlog is rendered
Implementation
So, as I mentioned before I had to make some back-end changes (changelist function in pushlog-feed.py and map). The following is the code:
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 29 30 31 32 33 | def changelist(limit=0, **map): #pdb.set_trace() allentries = [] lastid = None ch = None l = [] mergehidden = "" p = 0 currentpush = None for id, user, date, node in entries: filesTouched = '' ctx = web.repo.changectx(node) n = ctx.node() if len(ctx.files()) > 1: for f in ctx.files(): filesTouched += f + '<br/>' else: for f in ctx.files(): filesTouched += f entry = {"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), "hidden": "", "push": [], "mergerollup": [], "dateId": localdate(date), "filesTouched": filesTouched } |
So basically, there is a function that gives me all the files touched by a changeset, ctx.files(). I just call the function append each file touched by a changeset into a string (filesTouched, in this case). Once I add it to the entry array I can then perform the following in the map file:
1 | pushlogentry = '<tr id="date#dateId#" class="parity#parity# #hidden# #dateId#"><td>#push%pushinfo#</td><td class="age"><a href="{url}rev/#node|short#{sessionvars%urlparameter}">#node|short#</a></td><td id="#dateId#"><strong>#author|person# — #desc|strip|escape|buglink#</strong> <span class="logtags">{inbranch%inbranchtag}{branches%branchtag}{tags%tagtag}</span>#mergerollup%mergehidden#<br/><span style="font-size: x-small; color: #FF902B; font-weight: bold">#filesTouched#</span></td></tr>n' |
I added:
1 | <br/><span style="font-size: x-small; color: #FF902B; font-weight: bold">#filesTouched#</span> |
The above line of code gets the filesTouched variable from the back-end and formats it using CSS styles to display within on the page.
The following is the result of the obove code: http://sidkalra.com/files/mercurial/filesTouched1.png
This way it is easy to tell which files a changeset touched. A users knows it right away, no need to click on any other links to find out. Only thing I am unsure about is the text color of the files touched. At first I had gone with red but that was a bit too bold, so I decided to go with orange but I don’t know if it fits the theme well. As far as I can tell it seems like an OK choice but I might (or might not) change it in the future.
EDIT: I’ve changed the color of the text to a dark brown so that it is easier to read. I felt that the previous orange color was a bit too harsh on the eyes. Have a look: http://sidkalra.com/files/mercurial/filesTouched2.png