How to back up local Mercurial repositories and use rebase?

My company is moving from Subversion to Mercurial. One of the reasons is with Hg we hope to be able to work more independently.

We are looking forward to using rebasing as our primary way to update from the main repository, at least in the beginning, to keep the history in one line, making the transition from Subversion easier.

Right now, if we need to work independently, we have two options: create a branch in Subversion, and commit there (aka merge hell), or not commit at all. With Mercurial we hope to be able to keep committing locally, and rebase every so often, thus gaining independence while staying free of the administration costs of bcreating named branches.

This all sounds cool until backing up comes into the picture. With Subversion it was obvious that if someone didn't commit, their work ccould be lost. But not committing became inconvenient quickly (no history, no log messages etc.), so people would commit time and again nevertheless.

With Mercurial it is going to be possible to go on committing and rebasing without pushing for extended periods of time, putting much more work at risk. So a question comes up: how to back up the stuff on developers' machines?

  • One solution would be to use some external backup software, but that doesn't sound like a very good idea.
  • We could also push to the main repo all the time (maybe even automatically?), but this would make it impossible to use rebasing, and would result in a lot of dangling heads in main.
  • We could push to a backup repo, and try to have only one head in the main repo. This sound a lot complicated.
  • Are there any other ways to do this? I'd like to find a solution that would let our developers use most of their Subversion knowledge in the beginning.


    Just to throw this out there: I think you're making a mistake. A linear history isn't a big deal and pull/merge is the much more normal mercurial workflow. Embrace a non-linear history and leave rebase for special occasions.

    You say "With Mercurial we hope to be able to keep committing locally, and rebase every so often, thus gaining independence while staying free of the administration costs of bcreating named branches.", but in mercurial one uses unnamed branches for this, so there's no administration costs.

    See http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously for an explanation of how unnamed branches created automatically will give you exactly what you want with zero hassle.

    I know it sounds like too-good-to-be-true snake oil, but your folks can just hg pull and hg merge and hg push when they're through and without anyone having to think about branch names, or who has what clone, or anything, you'll have a coordinated center with disconnected work.


    You could also give each developer a repo:

    https://example.com/repos/awesome-product
    https://example.com/repos/awesome-product-wolever
    https://example.com/repos/awesome-product-pintér
    

    Where they can push to all they want.

    It would mean a lot of dangling heads, but that's probably OK because nobody would look at them until it comes time to restore… Then you'd simply ask for only the ancestors of the current tip:

    hg pull https://example.com/repos/awesome-product-wolever -r tip
    

    If I were using this scheme, I'd set:

    [paths]
    backup = https://example.com/repos/awesome-product-wolever
    

    in .hgrc/hgrc .

    Alternatively, you could give each dev one overall backup repo by setting this in their global ~/.hgrc :

    [paths]
    backup = https://example.com/repos/wolever-backup
    

    I think you're doing it the wrong way.
    What you describe looks more like you're trying to put in place a tool to ensure/enforce a process, rather than to support the process.

    Working in a decentralized way is quite a big shift compare to the centralized approach, and by trying to put the kind constraint you describe will more than likely cause more hurt than good for the experience perceived by your developers.

    If you're scared that they won't push their changes on a regular basis to a main repository, then it would be good to ask yourself (and to ask them too) "Are we ready to change our process?" Many people still claims that the DVCS will bring chaos to their software factory. It's true that the DVCS'es don't enforce a linear (single-point-of-failure) way to work, but what bring chaos is not the tool, it is the team spirit you built in your company.

    Now, if you HAVE TO migrate to Mercurial (because it's already sold to the management level, or whatever), but feels more comfortable with the SVN approach, with a little "plus", try using HgSubversion first. Migration will still be easy later.

    链接地址: http://www.djcxy.com/p/37632.html

    上一篇: 在Vim中当前缓冲区的文件名/路径

    下一篇: 如何备份本地Mercurial存储库并使用rebase?