How To: Browse a Mercurial log in Visual FoxPro

If you use Mercurial as your version control system, you know it maintains a log of all repository history. You can view the log with the hg log command or with the TortoiseHg Workbench app.

However, if you’re a Visual FoxPro developer, you might wonder if you can get at the log from VFP. It turns out this is easy to do in two simple steps.

1) From the command prompt, do hg log --style xml > log.xml to send the log output to a file named log.xml.

2) Then, in VFP, do XMLTOCURSOR( "log.xml", "csrHgLog", 512) to create a cursor you can browse and work with in VFP.

This little tip was included in the white paper from my session on VFP Version Control with Mercurial at the 2011 Southwest Fox conference in Gilbert, AZ.


Unknown said...

Rick thanks for your work on this. I really enjoyed your session on this at SWFox. It took me a bit to figure out how to structure my projects, because I really want to drive the repository from the project file, but I think I am about there. Question, is that a way to the manifest to an xml file?

Rick Borup said...

The hg man command does not have a --style option so you can't output the manifest to xml directly. However, you can use hg man > man.txt to send the output to a text file and then work with it from there. Check the -v and --debug options if you want more than just the file names.