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.