Tracking /etc files (was: Re: hg add default behaviour...)

Maxim Khitrov mkhitrov at
Thu Aug 23 18:09:26 CDT 2007

On 8/23/07, Giorgos Keramidas <keramida at> wrote:
> On 2007-08-23 16:57, Maxim Khitrov <mkhitrov at> wrote:
> > For example, I run several FreeBSD servers on which mercurial is used
> > to keep track of all configuration files. The repository is located in
> > /.hg, and I configured ignore rules such that only files in /etc and
> > /usr/local/etc and added. Install a new piece of software, run hg add
> > to import the default configuration, edit configuration and commit the
> > changes. For me, it's been a great way to keep your systems healthy
> > and track all the important configuration changes. I use the exact
> > same behavior when working on programming projects. See absolutely no
> > reason why hg add should behave any differently.
> Would you care to elaborate a bit on the setup you use to get this sort
> of /etc file tracking going?
> Mercurial doesn't track some of the file attributes (i.e. owner:group,
> special file system attributes, mtime/ctime/atime, etc.), so it would be
> interesting to know if you have hooks in place to handle that, what
> these hooks do, and other neat tips.
> Perhaps a page in the wiki, or an article of some sort? :-)
> - Giorgos

No hooks, it's just storing the file contents. Wouldn't be at all
difficult to write something that would store permissions and other
attributes, but I don't need that. I use this in combination with
regular back-ups, it's just a nice way to quickly view the history of
the system (who changed what and why).  When I install a new server I
run "hg init" in the root directory, change permissions on /.hg to
0700, then create /.hgignore with the following contents:


It's a bit messy, but basically the first line lists top-level
directories that should be searched for changes, everything else is
automatically ignored. Then it's just a matter of fine-tuning. Under
/boot/ I want to track loader.conf, /root/kernel/POSEIDON is the name
of my kernel configuration, then the last two lines are for
/usr/local/etc. Whenever I change some settings I use hg commit -m
"..." to record what I've done.

- Max

More information about the Mercurial mailing list