Reputation: 282825
I'm trying to parse the output of hg log
. So far I'm just doing something simple:
$arg_sep = '|||';
$entry_sep = ';;;';
$log = shell_exec("hg log -l 5 --template \"{rev}$arg_sep{node}$arg_sep{author}$arg_sep{date|hgdate}$arg_sep{parents}$arg_sep{files}$arg_sep{desc}$entry_sep\"");
And then exploding it. I anticipate a problem with the files though. They seem to be space-separated. What if the file actually contains a space, how am I supposed to parse that?
Can I get the log in a more parsable format? JSON would be nice, but I can't seem to find anythign on that.
Upvotes: 0
Views: 386
Reputation: 227
Check out http://www.selenic.com/mercurial/hg.1.html#template-usage
You could try
hg log -l 5 --style xml
and then try to parse the resulting xml.
Upvotes: 1
Reputation: 78330
Try this one:
hg log --verbose --style=xml
It's not quite JSON, but it is concretely parse-able and there are easy command line tools for extracting XML values.
Upvotes: 3