Fast checking "Is this dir a hg repository?"
Roman Inflianskas
infroma at gmail.com
Tue Nov 25 13:57:35 UTC 2014
On Tuesday 25 November 2014 00:35:19 Tynor Fujimoto wrote:
> I just check for output on `hg branch`. Have you tried that?
>
> -T
>
> > On Nov 25, 2014, at 12:32 AM, Roman Inflianskas <infroma at gmail.com> wrote:
> >
> > Hi, all.
> >
> > I'm interested in writing custom prompt <https://github.com/bpinto/oh-my-fish/tree/master/themes/bobthefish> for fish shell <http://fishshell.com/> that displays current mercurial repository status (branch, is it dirty, etc.). What is the fastest way to check "Is this dir a hg repository?"?
> >
> > For now we are using checking for `.hg` directory (in the current directory and parents) to quickly filter all directories that are 100% not a repositories. If it contains `.hg` repository, we call `hg root --cwd $dir`. 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?
> >
> > Also, when the current directory is a home directory with `.hg` directory inside (or in any of its children directories) `hg` works just like it's a repository. `hg root` shows home directory and `hg status` lists all the files inside it. Of course it slows the shell dramatically. How can I process home directories correctly (that means I want to filter them out). Of course, it's easy to expand `~` and check string equivalence. But it's not enough, because root user (with home `/root`) can be inside `/home/user` directory. I don't know a fast and reliable way how to get all homes. Yes, I know about `/etc/passwd`. The problem is that there could be other sources like NIS, LDAP, etc.
> >
> > Here is PR <https://github.com/bpinto/oh-my-fish/pull/262> on GitHub that adds support for showing status of mercurial repositories for fish shell.
> >
>
Of course I've tried this. How is it better, than `hg root`? It seems that it doesn't work faster, than `hg root`. Moreover, it shows no difference between home and repos:
$ cd ~
$ hg branch
default
$ cd repo
$ hg branch
default
--
Regards, Roman Inflianskas
More information about the Mercurial
mailing list