I\'m a web developer working on my own using django, and I\'m trying to get my head round how best to deploy sites using mercurial. What I\'d like to have is to be able to keep
Here are two possible solutions one using mercurial and one not using mercurial:
I'd probably use Mercurial Queues for something like this. Keep the main repository as the development version, and have a for-production
patch that makes any necessary changes for production.
Perhaps try something like this: (I was just thinking about this issue, in my case it's a sqlite database)
settings.py
to .hgignore, to keep it out of the repository.settings.py
files from the two separate branches and move them into two separate files, settings-prod.py
and settings-dev.py
If you have a couple of additional files, do the same thing for them. If you have a lot of files but they're all in the same directory by themselves, you could just create a pair of directories: production
and development
, and then either copy or symlink the appropriate one into a deploy
directory.
If you did something like this, you could dispense with the need for branching your repository.
I've solved this with local settings.
Append to settings.py:
try:
from local_settings import *
except ImportError:
pass
touch local_settings.py
^local_settings.py$
to your .hgignore
Each deploy I do has it's own local settings (typically different DB stuff and different origin email addresses).
PS: Only read the "minified versions of javascript portion" later. For this, I would suggest a post-update hook and a config setting (like JS_EXTENSION).
Example (from the top of my head! not tested, adapt as necessary):
settings.py
file;local_settings.py
file on the production server;<script type="text/javascript" src="blabla.js"></script>
To:
<script type="text/javascript" src="blabla{{JS_EXTENSION}}"></script>
*.raw.js
and generates .mini.js
(minified versions of raw);.mini.js$
to your .hgignore
I actually do this using named branches and straight merging instead of transplanting (which is more reliable, IMO). This usually works, although sometimes (when you've edited the different files on the other branch), you'll need to pay attention not to remove the differences again when you're merging.
So it works great if you're not changing the different files much.