I have a file in mercurial that I want dev machines to pull the file, but I want the deployment server to NOT pull the file (it has special mods to it that the dev machines don't have). Is this possible, or should I just have a custom push to server solution instead of just doing an hg pull?
A typical way to do this would be to do the following:
You store a copy of each file in the repository, and name them correctly. For instance, if the file in question is web.config
, you would store the following two in the repository:
web.server.config
web.dev.config
Then you would add a built step to ensure the right file was copied to the actual web.config
file, you could use a batch file:
if "%COMPUTERNAME%" == "SERVER" copy web.server.config web.config
if not "%COMPUTERNAME%" == "SERVER" copy web.dev.config web.config
Then you would ignore web.config itself through .hgignore:
glob:web.config
A variant of Karlsen's answer that I always use.
I have /config
or /etc
directory in the project. That directory will often contain sample configs like:
dev.yaml
ci_server.yaml
Then my apps pull from /etc/app.yaml
which is a symlink to the correct config depending on the host it's being run on.
The best think about doing it this way is you don't have variant code paths (the batch script branches) which eliminates a potential bug vector. This allows you to exercise the same code path that will be used in production (down to where to look for the override file).
Is this something that can be solved outside version control? For instance, include the file in all copies of the repository, but enable or disable its use with environment variables or something similar. This doesn't sound like something most version control systems are built to handle, unless you use nasty hacks to do things like add/remove/patch files after updating.
One option is to create a special hgignore file for the deployment server, that could or could not be included in the repository. Then in the server's hgrc file specify the path to the special hgignore file with the ignore
variable.
This would ensure that updates to file would be ignored by the deployment server but could still be updated as usual for the development machines.
© 2022 - 2024 — McMap. All rights reserved.