Posts Tagged graph
v0.3 Release - 1st Iteration of the Graph View
Posted by Sid in Mercurial Project, Open Source on December 2nd, 2008
I’ve been working hard trying to get the graph view working for the gitweb_mozilla template. Earlier, I documented the problems I was having. That is all resolved now and I’m moving on to bigger and better things.
So my goal was to get the graph to the stage of the coal template, which I am using as a reference and then make further improvements from there to make it look similar to the rest of the gitweb_mozilla pages.
To do this I created a new template called graph.tmpl which can be viewed by typing {url}/graph in the address bar. This is where the graph will be drawn. You can view the code it has here. However, with just this code my graph wasn’t rendering properly. The following is what it looked like: http://sidkalra.com/files/mercurial/graphView1.png. I couldn’t quite figure out why this was happening. It seemed like the graph was drawing properly and the data was appearing properly too and yet they weren’t coming together. Something was missing from the puzzle…
I showed my problem to a friend, Tiago Moreira who happened to be sitting right next to me as the time. He was able to point out that it might be a CSS problem, something I failed to consider. This was definately a lead and I had a look at the coal template’s css file and the answer hit me in the face straight away. The canvas tag was assigned a z-index of 5.
canvas { position: absolute; z-index: 5; top: -0.7em; margin: 0; }
This means that anything in the canvas tag will have a higher priority over everything else and it will also allow the data in other tags (in this case the two ul tags with the ids graphnodes and nodebgs) to slip in underneath the canvas giving the following result: http://sidkalra.com/files/mercurial/graphView2.png
Now my graph view looks similar to the one that the coal template has. My next objectives are to improve it greatly by making it look similar to the other pages in the gitweb_mozilla theme as I mentioned above and adding more changeset information to the each row. Basically the end goal is for it to look similar to the pushlog but with the graph drawn in as well.
v0.3 Release - Understanding djc’s Graph View
Posted by Sid in Mercurial Project, Open Source on November 25th, 2008
I’m starting work on a graph view for the pushlog. Frankly, I didn’t know where to begin since I have never really done anything like this before, then again I could say the same thing about the whole project. After having a discussion with jorendorff I was pointed towards djc’s (Dirkjan Ochtman) Graph view for Mercurial. He already has it working and my job is to now understand what he has done and get it working for the pushlog now.
The Source
I downloaded the source from http://hg.intevation.org/mercurial/crew/ using hg clone.
Getting it Running
Getting it running on my browser was pretty simple. Almost identical to what I had to do for the pushlog. Just open up a command prompt and navigate to the directory where you saved the source and call the hg serve command. Then fire up a browser and type in http://localhost:8000 and you should be able to see the graph view.
Understanding the Code
Mercurial crew comes with Mercurial and hgweb. Some of the functionality is implemented in crew/templates/static/graph.js which is what runs on the client side. Also the tmpl file used to render the page is crew/templates/coal/graph.tmpl which imports graph.js to utilize its methods. The template also takes in a parameter, jsdata which contains the graph data. jsdata is populated on the server side by the graph method of the crew/mercurial/hgweb/webcommands.py file. It contains graphmod.graph() which is apparently what does the actual graph layout.
I don’t fully understand this code at the moment. There are many questions going through my mind. For example it seems that the server side code (mercurial.hgweb.webcommands.graph) returns a tmpl so I don’t know whether I should be working from a new tmpl file or can I put my client side code in hg_templates/gitweb_mozilla/pushlog.tmpl like I have been doing all along?
The client side code receives the data from the server side through {jsdata|json} which is all the changeset data. But right now with the pushlog all this is processed through pushlog-feed.py which gives the data to hg_templates\gitweb_mozilla\map that renders the page. So should I be messing with this map file? If not then how can I pass the data to the client side so that I can draw the graph and render it on the page?
The above 2 examples are only some of the questions going through my mind right now. I have told you about them because they are ones that must be answered urgently. It is important that I understand the basic functionality of djc’s Graph view so that I can deduce a way to apply it to my problem.
It is still early days for this feature and I’m still trying to feel my way through it. Hopefully things will pick up as my understanding of this feature increases.