Hg identify on multiple repos in single call?

Sean Farley sean.michael.farley at gmail.com
Tue Mar 11 22:07:31 CDT 2014


Eric Pyle <eric_pyle at sil.org> writes:

> I've looked into reading .hg/dirstate per your recommendation. However, I
> not only need a fast way to know the parent id of the working directory,
> but also whether or not anything has been modified. (I see that even the
> *vcprompt* code calls *hg status* to determine this.)

I had the same problem when trying to write a fast C replacement of 'hg
status'. The only time you need to unpack the manifest to do a diff is
when the timestamp of a file differs but not the size. If you can live
with that approximation, then go for it.

In the end, I ended up using chg + hgwatchman [1] in my prompt. For a
repo with ~20,000 files in it, 'hg status' takes about ~0.6 seconds on
my mac (even faster on linux). Compared to 1.7s without chg nor
hgwatchman. I could live with ~0.6s in my prompt, so I just use that
instead of trying to parse the dirstate.

If you really, really want to do this all in C, then look at Greg Ward's
xrevlog [2]. It needs some love to get it to be fully functional
(e.g. it doesn't work with generaldelta) but it'd be great for someone
to write some pure C implementations of parsing the manifest.

[1] https://bitbucket.org/facebook/hgwatchman/
[2] https://bitbucket.org/gward/xrevlog


More information about the Mercurial-devel mailing list