Getting information directly from .hg/* files
Jason Harris
jason at jasonfharris.com
Wed May 26 16:53:20 UTC 2010
You might be interested in looking at Steve Losh's hg-prompt
http://stevelosh.com/projects/hg-prompt/
(I use it and quite like it...)
See http://jasonfharris.com/blog/2010/05/mercurial-prompt/ for my prompt...
Cheers,
Jas
On May 26, 2010, at 5:54 PM, Anton Shestakov wrote:
> Hello, everyone.
>
> I'm trying to write a little console helper like this one: [1], but for Mercurial. Current "draft" of it is written in bash and launches hg to get all needed information. At the moment, it can show what branch and revision your current directory at and if it was modified in your shell prompt. Basically, it uses just two commands: $(hg id -i) and $(hg log -r ${HG_REV} --template="{branches}@{rev}), nothing complicated.
>
> But I'm already concerned with speed. It's not really a Mercurial problem, more like Python problem: loading interpreter and all needed modules each time I run hg takes some time (hg id -i takes 115ms on my laptop). With just two commands it's already about 230ms — already noticable. And I want to extend the functionality to include merge situations, maybe head count & etc. Imagine a 300-400ms delay each time you run a command inside your repo. Shell would feel sluggish.
>
> That made me think about writing some C/Lua code to speed things up, and to exclude all possible interaction with hg it must use internal .hg/* files to get all needed information.
>
> Well, I've found .hg/branch file pretty quickly, but everything else is a bit too hard to find than I thought. Could someone please point me at internal data format specification, some specific place in hg source code maybe? I need to get all the information present in $(hg id -i) and $(hg log -r tip) at least.
>
> [1]: http://blog.phpwnage.com/old_blog/article.php?id=123
>
> P.S.: I hope my email client did break too long lines. Don't hesitate to let me know if this email don't fit in your screen. Thanks.
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
More information about the Mercurial
mailing list