We are migrating from SVN to Mercurial and this question has arised practically from day one. So, here is the given:
- Shared Mercurial repository residing on a dedicated server, which is continuously backed up.
- Developers pull revisions, work on them, make local commits, push back to the shared repository.
- Developers wish to backup their local commits.
- The backup engine is Mercurial.
- Backed commits are never pulled, except when the particular developer loses its yet unpushed work. This is expected to happen rather rarely.
- It should be relatively painless to restore the commits from the backup.
I tend to provide a special backup script, which would do something like this:
hg push -fr REV URL
As you can see, I am OK with having multiple heads in the backup repository, unless you convince me otherwise.
So, the question is about REV and URL, namely I see the following options for them:
- REV = default, URL per dev - Each developer is given a dedicated backup repository.
- REV per dev, same URL for all - Each developer is given a dedicated branch within the same backup repository.
- REV = default, same URL for all - All developers back their local commits into the default branch of the same backup repository.
I do not have much experience with Mercurial, so I find it really hard to decide which option is the best. Can anyone advise, please?
EDIT
I have now realized that my question exposes my total misunderstanding of the push command. Of course, I do not mean push -fr REV URL
. What I really meant by REV is BRANCH, so the options should read:
- BRANCH = default, URL per dev
- BRANCH per dev, same URL for all
- BRANCH = default, same URL for all
Next, I have no idea how to push to a different branch.
For instance, a developer works in the default branch and wishes to backup its local commits to the special backup repository shared by all the other devs. Of course, this backup repository is not the one from which developers pull the new changes. Anyway, the backup needs to go to a branch dedicated to that particular dev, as stated per options 2. How do I do it? How can I tell push that the changes are pushed to a different branch?
(BTW: You logically are missing a fourth option,
which would, however, make not much sense.)
IMHO it would be useful if every developer has his own backup repo. Imagine the "restore" situation: you are losing your local working space and have to restore it from backup. There you don't necessarily want the other's unpushed stuff (or do you?). It can hurt you if you try to push to the "real" repo.
Everyone working within a branch would not work well because it would perturb the "everyday's work" which happens in the branches
default
,testing
,devel
and/orexperimental
. (Just examples.)=> URL per dev.
For the question what should be pushed: just everything, so don't give any
-r
arguments.