tags:

views:

40

answers:

2

I'm setting up multiple Mercurial repositories for all of our different projects, probably close to 50. Is there a way to search across multiple repos for a specific file or string? For example, say that a database column is renamed, how would I search each repository for any reference to the old column name? I know that I can do this for each repository individually, but if you've got 50 repositories, that can be quite time consuming?

If it's not possible, are there any best practices then for structuring your repositories to minimize this pain?

+1  A: 

It's not possible -- repositories are entirely independent.

If you wanted to set up a global search one way to do it would be to push all your 50 repositories into a single repository that can be searched. Something like this:

hg init everything
for therepo in /path/to/repos/* ; do
   hg -R everything pull -f $therepo
done

Then you can search in everything. You could keep everything current using a cron job or changegroup hooks on your other repos that do a push to everything.

Ry4an
It's actually possible (see below), but I agree with Ry4an that if you're going to be doing this operation frequently, you should keep local copies of all 50 repositories.
leo grrr
A: 

You can use the command hg locate with a remote repository argument. Here's a small snippet of the help--read the fine manual for details. hg help will tell you a list of available commands.

You will probably just have to write a shell script to run this command on all of your repositories.

C:\Dev>hg help -v locate
hg locate [OPTION]... [PATTERN]...

locate files matching specific patterns

    Print files under Mercurial control in the working directory whose names
    match the given patterns.

    By default, this command searches all directories in the working
    directory. To search just the current directory and its subdirectories,
    use "--include .".

    If no patterns are given to match, this command prints the names of all
    files under Mercurial control in the working directory.

    [...]

global options:
 -R --repository      repository root directory or name of overlay bundle file
 [...]
leo grrr
> You can use the command hg locate with a remote repository argumentReally? In what version? I am using 1.6 and it says:"abort: repository 'ssh://hg@machine/test' is not local":-( That would have been very useful indeed! The command also only find files from working directories, it doesn't seem to work when the working copy is empty (clone -U)...
Christophe Muller