Preventing some changesets from being pushed

Mike Meyer mwm at mired.org
Thu Aug 26 15:41:18 UTC 2010


On Thu, 26 Aug 2010 03:04:23 -0700
Michael Diamond <dimo414 at gmail.com> wrote:

> On Thu, Aug 26, 2010 at 2:16 AM, Simon Robinson <
> thegreatelectron at yahoo.co.uk> wrote:
> > Is there a way of ensuring that some changes that I make in my local
> > repository never get pushed to the source (central) repository?
> >
> > I'm working on a large project using mercurial for version control. The
> > changes I make to the code get committed to my local repository and then
> > pushed to the 'central' repository that is shared by all members of the
> > team.  However, I have a couple of configuration settings - things like
> > connection strings to my private dev database - that I do not want to be
> > pushed centrally. Is there any way to achieve that?
> > I did consider putting the files containing the config settings in the
> > .hgignore, but the trouble is, I might make other changes to those same
> > files - like adding new settings - that I do want pushed. I really want to
> > be able to ignore certain changesets when pushing rather than ignore
> > certain
> > files.

> What I do (for my admittedly smaller projects) is create a base file which
> is checked in (includes/config.base.php), and an ignored file
> (includes/config.php) which the program actually looks in for configuration
> settings - if it doesn't exist (as it wouldn't in a fresh clone) the user is
> prompted to create it.  This keeps the notion of customizing your version of
> the code completely separate from tracking changes to the configuration file
> of the program.

I carried that a step further, and checked to see if the template file
was newer than the config file, and if so printed explicit
instructions to check the diff and update the config file before
exiting.

> In my use case the real config file is changed rarely enough that it isn't
> an issue to manually fix it.  But perhaps in your case, you could follow
> this model and then create a hook (on commit and pull) which looks to see if
> includes/config.base.php has been changed, and if it has, merge (not hg
> merge of course) it with includes/config.php.

That was our case as well. I don't think there's a good solution if
the config file changes frequently. Even something like mq requires
that you remember to undo/redo the patches regularly, and if you miss
that, you'll hose other developers config files.

      <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the Mercurial mailing list