Fast checking "Is this dir a hg repository?"
Yuya Nishihara
yuya at tcha.org
Tue Nov 25 15:25:23 UTC 2014
On Tue, 25 Nov 2014 19:16:15 +0900, Anton Shestakov wrote:
> 2014-11-25 16:32 GMT+08:00 Roman Inflianskas <infroma at gmail.com>:
> > I'm interested in writing custom prompt for fish shell that displays current
> > mercurial repository status (branch, is it dirty, etc.). What is the fastest
> > way to check "Is this dir a hg repository?"?
>
> The fastest way to check if a directory tracked in mercurial is
> probably to write a small C program for directory traversal. Second
> best option is a shell script. This is what I'm currently using for my
> bash prompt [1].
FYI, "vcprompt" does directory traversal in C.
https://bitbucket.org/gward/vcprompt/src/1cfd699ab055/src/vcprompt.c#cl-214
> > We need the first step because even such easy command as `hg root` work very
> > slow compared with recursive search for `.hg` directory. Is there way to
> > make it faster?
>
> I think there is, but I would guess that involves hacking mercurial.
> If you'd like to try, welcome.
"hg root" is slow mostly because python startup is slow. I think there's no
good way to make it faster, but if you like a crazy idea, try cHg.
https://bitbucket.org/yuja/chg
Regards,
More information about the Mercurial
mailing list