Conditional Mercurial Ignore File

I have a file in mercurial that I want dev machines to pull out the file, but I want the deployment server to NOT pull out the file (it has special mods that it doesn't have). Is this possible, or should I just have a custom push to server solution instead of just doing hg pull?

+6
mercurial deployment hgignore
source share
4 answers

A typical way to do this would be the following:

You save a copy of each file in the repository and name them correctly. For example, if the file is in question web.config , you should save the following two in the repository:

  • web.server.config
  • web.dev.config

Then you added the built-in step to ensure the correct file copied to the actual web.config , you can use the batch file:

 if "%COMPUTERNAME%" == "SERVER" copy web.server.config web.config if not "%COMPUTERNAME%" == "SERVER" copy web.dev.config web.config 

Then you will ignore web.config itself through .hgignore:

 glob:web.config 
+6
source share

Carlsen's answer option that I always use.

The project has a /config or /etc directory. This directory often contains example configurations, for example:

  • dev.yaml
  • ci_server.yaml

Then my applications are extracted from /etc/app.yaml , which is a symbolic link to the correct config, depending on which host it is running on.

It’s best to think of it this way: you don’t have any code path options (script branches) that eliminate a potential error vector . This allows you to use the same code path that will be used in the production process (down to where to look for the override file).

+2
source share

Is this something that can be solved outside of version control? For example, include the file in all copies of the repository, but enable or disable its use with environment variables or something similar. This is not like most version control systems are created for processing, unless you use unpleasant hacks to perform actions such as adding / deleting / fixing files after updating.

+1
source share

One option is to create a special hgignore file for the deployment server, which may or may not be included in the repository. Then, on the hgrc server , specify the path to the special hgignore file with the ignore variable.

This ensures that deployment servers ignore updates, but can still be updated as usual for development machines.

+1
source share

All Articles