5

I have a Mercurial repository with several subrepos. Is there a possibility to only define a general .hgignore-File (e.g. to ignore object-files) both in the main repository and, optionally a specialized one in the sub-repositories?

There is not enough information in the manual. Specifying a .hgignore file with

[ui]
ignore = .hgignore

to .hgrc in my home-directory also does not work.

Any ideas?

glasflügel
  • 325
  • 2
  • 11

1 Answers1

3

A .hgignore file in each subrepo would serve as the specialized one for that subrepo. Then you can use the main repo's .hgignore as the main one by including this in each subrepo's hgrc file:

[ui]
ignore.main = \absolute\path\to\mainrepo\.hgignore

The reason why doing ignore = .hgignore didn't work for you in your global .hgrc (and won't in repo hgrc) is that having simply .hgignore is a relative file path and its resolution to an absolute path depends on the current working directory used when invoking hg. Examples:

  • If you're in \repos\main\ and invoke hg st, it will look for \repos\main\.hgignore. Same thing if you invoke hg st -R nested, because the current working directory is still the same.
  • But if you were in \repos\main\nested\ and then invoked hg st, the config would now be looking at \repos\main\nested\.hgignore.

If you want to specify a global .hgignore that is in your home directory, you would need to specify it with a non-relative path (or at least much less relative):

[ui]
ignore = ~\.hgignore
Joel B Fant
  • 24,406
  • 4
  • 66
  • 67
  • I'm not sure about your first bullet-point there. If you invoke `hg st -R nested` then `\repos\main\nested\.hgignore` will be used, as that's the `.hgignore` file in the working directory of the `nested` repo - that may be what you meant, but it doesn't read that way. – icabod Oct 18 '11 at 08:08
  • @icabod: I don't have a *nix machine to test with, but that's how Windows behaved. If I have different `extra.hgignore` files in `main` and `nested` and put `ignore = extra.hgignore` in `nested\.hg\hgrc`, doing `hg st` and `hg st -R nested` both pull from `main\extra.hgignore`. Only if I `cd` to `nested` will it instead grab `nested\extra.hgignore`. (For my test I used 4 files in both `main` and `nested`, with 4 different extensions distributed among the ignore files.) – Joel B Fant Oct 18 '11 at 13:44
  • Ah, I think I missed out a part of your answer when I was trying it out. My mistake :) – icabod Oct 19 '11 at 16:22