Separating Dev code from Live Code
Fairly new to using mercurial and a little confused as to a good approach to take for seperating live code from dev code. I come from using PureCM where everything was divided into Streams and you could simply merge开发者_运维技巧 one Stream to another. My goal is to set something up in mercurial that behaves similarly.
Ideally, whatever avenue I take would also include a path for easily merging dev code to live code while maintaining the change set history.
What approaches are available and any documentation on how it is done?
Branches are what you want. You can make a stable branch and a dev branch (and any other branches you might want) and merge any changes from the dev branch into stable when you see fit.
For example, say you have a repo with no branches (besides the default) and you want a dev branch and a stable branch. First thing you do is make the dev branch
hg branch dev
Now your working copy is on branch dev and any commits you make will be on dev. If you type hg branches
now it should say
dev
default
To switch back to the default branch type hg up default
And finally, if you want to merge changes from the dev branch to default you would type
hg up default # update to the default branch
hg merge dev # merge changes from dev into working copy (default in this case)
If your repository is published using hgweb you can also see a nice graph of the commits and branches on there.
Disclaimer: I've never used PureCM, but googling it I find that it's not a distributed model. So I'm coming at my answer from that direction.
It sounds as if you might be struggling more with how distributed version control works. This is one of the fundamental differences between distributed and non-distributed source control (and in my opinion, one of the big wins that it gives you).
Since you are not bound to a central repository, your 'live' code is just another clone of any particular repository. Technically speaking, all clones that you make of any code that you have of a distributed source control system count as a 'branch' (which may or may not be like streams from PureCM, though I have a feeling they're similar). That said, if you have a central repository that all your developers pull from, all you need to do is just clone a copy of your code at whatever point you're going live with it, and that's your live 'branch'. That way your developers keep working with the most recent code, and keep merging with the most recent, and you have an entire repository that is just the code you've got live.
So long story made long, it's just another clone. That make sense?
As a side note/example, the way that my current workflow goes with one of my projects, we use our 'central' DVCS repository as the place where the extra clone goes. So we have our primary "app" that everyone pulls from, and then we have "app-release-1-1-11" (which includes the date it went live). So that the released code is also available on the central repo. Hope that helps!
Check out the hginit.com tutorial - this covers some standard strategies.
What we do is have separate repositories, we'll have a prod support repository and a dev repository. Maintenance changes to prod support get merged back into dev.
精彩评论