Rather basic question about using mercurial in test/production set-up

Marcin Kasperski Marcin.Kasperski at mekk.waw.pl
Tue Feb 16 17:53:46 UTC 2021


> However I now have a situation where I do need to keep the testing
> code separate from production as it were.  It's my mail filter program
> which handles all my incoming mail.  Thus I can't just change it and
> have errors in it because I will lose mail.

Simplest approach is usually to use branches. For example:

- your „stable” code lies on branch named „production”

- you develop your changes on branch named „test”

- whenever you finish testing, you merge test to production
  to copy all those changes there

- when you have new ideas, you reopen test and go on.

Mercurial helps here a bit, as branches are „sticky” – you must
update to branch test on testing machine once, and future `hg update`
won't switch branch unless asked to. Similarly on prod,
once you `hg update production` once, future `hg update`-s will
stay on that branch (unless asked to)

Approach above can be made even simpler by using „default” as
development branch. Then you only need one named branch - `production`.
You hack freely, you update on testmachine to newest commit on default
to test, and from time to time you merge to production branch.





More information about the Mercurial mailing list