English 中文(简体)
Mercurial (and, I guess Git) with Dropbox: any drawbacks?
原标题:

I have a Mercurial repository for a personal project, and I have been storing the master repository in my Dropbox for a few weeks now (something along this line; and I understand it s also possible with git).

The idea is that it serves both as a way to work with multiple machines and as a remote backup. I clone the repository and work on the non-Dropbox copy, and only push updates once in a while, the same way I would, I suppose, work with Bitbucket.

Can you think of any drawbacks to this idea, compared to using dedicating hosting (BitBucket in the case of Mercurial)? I know Bitbucket has free accounts for single users, which is great, but they are limited to 150M, which isn t a huge.

In particular, is it possible that Dropbox s sync process would corrupt the repository? I had to run hg recover once on the master repository, but it might be unrelated (and anyway it happily recovered). Does anyone have a bad experience with the idea? Does anyone have a longer good experience and can alleviate my worries? Does anyone have an opinion based on better understanding of the internals of these things?

edit: I added some clarifications to the questions. They are in italics.

最佳回答

I d advise against it for the reasons stated above, but more strenuously stated. Both mercurial and git have their own protocols for moving changesets between repositories. These protocols are optimized/built for:

  • efficiency
  • consistency (never can you pull from a repo in a half-updated state)
  • hooks/triggers -- doing things on push/pull including quality (no tabs allowed, etc.) filters

When you just let a directory sync handle the keeping of the .hg (or .git) directories in sync then during that sync you ve got a remote store that s in an inconsistent state and doesn t know it.

Additionally both hg and git have a separation of what s local-only and what s remote-okay within their disk state. They know what info to share (example: commited changesets) and what not to (example: current, local working directory parent revision).

In other answers folks are saying "you ll probably be fine" or "I ve never had a problem" and that s likely true, but it s not guaranteed true, and revision control isn t a place to play the odds. Use the proper, better, safer, more efficient, more full featured synchronization protocol for your source control system.

问题回答

I ve had problems with my Dropbox ed repositories becoming corrupted. It doesn t happen all the time, but the fact that it has happened more than once means that I m going to stop using Dropbox for this purpose.

That said, Dropbox is certainly cheaper than getting real hosting, so as long as you keep backups you may find it acceptable for personal projects.

I suppose that would probably work okay for personal projects on one or two machines, but really you re going to want to use professional hosting for multi member projects.

I have personally used BitBucket for some time and have been quite pleased... you can have one private project on the free account, too.

I d expect problems if you try to access repository in the middle of the sync. It also seems to be a bit of overhead. You don t really need to sync over the stuff you sync. I have no idea how dropbox handles conflicts, but I doubt it can do it in an scm-aware way.

+1 for bitbucket. It s free, and you get a single private repo with that free account (unlike github).

The drawback with the dropbox only solution is that if you do screw something up in the repo on your machine, that screwup will be copied out to bitbucket and replicated to every other place you ve got the dropbox installed. Dropbox is very quick, so you won t be able to stop it from happening in time to prevent issues.

You lose the ability to decouple making changes to your repository with publishing those changes.

I do use dropbox to host a couple of repositories that I use on both my home and work machines, but those aren t the only copies of those repositories. There s also a bitbucket repo (as well as other people that have clones of them).

I ve been using Dropbox with Hg too without experiencing a problem until now. Too late I realized hg doesn t report corruption during routine checkins, only when you try to use the repo for real (the worst of all situations, since you don t know something s broken until you really need it).

Its not clear whether if the corruption is spontaneous or caused by accessing the repository with Mac, Windows and Linux clients (I use all three at different times). But I ve seen at least one case of corruption happening when only the Mac was active so it could well be Dropbox itself.

If you do decide to live dangerously, run "hg verify" (or "git verify" regularly to turn up any dirt.

I ve been using Dropbox with git for personal projects for quite some time now, and I haven t had a single problem yet. Although, there are times you have to wait for Dropbox to sync. I think this can cause minor problems if there are more than a few people working on the same project, but for personal projects, I find Dropbox to be even better than GitHub, if only for the fact that pushing/pulling is faster.

As for pushing/pulling mid-sync, this will most probably cause problems, and it might even corrupt your repo, but if you re the only one working on the project, then you know exactly when Dropbox will sync.

I would not recommend using dropbox with mercurial, as I often see conflicted files between my Mac and Windows clients. Especially undo is affected, but I did experience conflicts with other files as well.

Regards Mirko

I am using it with Bazaar at the moment across 3 machines. However, I am the lone developer in any of the branches.

I used the init-repo --no-trees command to create the repository.

For those who prefer to use Dropbox over bitbucket/github, here s what I do to avoid corruption from the 2-way sync process of cloud backup services:

My local code folder is c:code & backup folder is c:Dropbox. Inside the Dropbox folder, I have a truecrypt encrypted file container (It s size is sufficiently larger than my code folder). During the day I regularly commit changes to my local Git/Mercurial repository. However at the end of the day, I quit Dropbox & mount the truecrypt file container. I push changes to a bare repository in the file container, unmount it & re-start Dropbox.

That way, I can safely use a cloud service for serving as a backup of my DVCS repository. If the file container is in use, Dropbox will wait for it to be unmounted so hopefully, there s no change of corruption there. Still, if I get a conflicted copy of the file container somehow, I can easily mount both the copies and compare the changesets.





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签