[PATCH 0 of 1] Add .hginclude support (like .hgignore, except specifies what to include).

Mitch Frazier mitch at fmr.name
Wed Nov 2 16:15:46 UTC 2005


Benoit Boissinot wrote:
> On 11/2/05, Mitch Frazier <mitch at fmr.name> wrote:
>> This patch adds support for the use of an .hginclude file.
>> The .hginclude file uses the same syntax as the .hgignore file.
>> Its purpose is to specify what files or file patterns should be
>> included in the repository, as opposed to the .hgignore file
>> which specifies what files or file patterns should be ignored.
>> The two files can be used in combination or by themselves.
>>
>> The .hginclude file is useful if you have a directory that
>> contains alot of files and you only want to include a few in
>> your repository.  An example might be /etc, where you want
>> to include just the config files that you've modified locally.
>
> What is the difference between this and ignoring everything in
> .hgignore ?

Files/patterns in .hgignore are never included, files/patterns in
.hginclude are always included.

Let me give you an example.  Say you want to archive the following files:

  /etc/my.cnf        # mysql configuration
  /etc/hosts         # host/IP address list

You can do this without using .hginclude:

  $ cd /etc
  $ hg init
  $ hg add my.cnf
  $ hg add hosts
  $ hg commit

but now try doing an "hg diff" or an "hg status" (or an "hg add" without
specifying a file name).  You get hundreds of warning messages about
files that don't interest you.

You could try putting this in .hgignore, to ignore everything:

   syntax: glob
   *

and then only add files you want, unfortunately this doesn't work as you
get python exceptions when you try to run may hg commands.  I tried
adding "inverting" patterns to .hgignore, eg something like:

   syntax: glob
   !(my.cnf|hosts)

but I couldn't seem to find any syntax that worked.

Doing this with .hginclude capability is easy:

  $ cd /etc
  $ hg init
  $ cat >.hginclude <<XX
  syntax: glob

  my.cnf
  hosts
  XX
  $ hg add
  $ hg commit

Now when you do an "hg add" it ignores everything except those two files
and "hg commit" works and "hg status" and "hg diff" don't display a
bunch of information/warnings about things that don't interest you.




More information about the Mercurial mailing list