Tuesday, February 17th, 2009
I was reading the back issues of the excellent blog Cocoa Is My Girlfriend and noticed this entry on using Git and Dropbox. Currently, I’m a Mercurial user, and I wondered if this trick (keeping a repository on Dropbox and pushing to it locally) would work with Mercurial.
Turns out it does. From the directory of the project you want to share, do:
hg clone --noupdate . ~/Dropbox/Shared/Code/MyProject
--noupdate parameter tells Mercurial not to create a working copy on disk, which is good because we’ll never be interacting directly with this particular repository directly.
This will create a seemingly empty directory
MyProject. The actual repository files and data are stored in
MyProject/.hg which is invisible in the Finder. I created a text file titled “These directories are hg repos. It’s normal for them to be empty” to remind myself, in case I forget.
To update Dropbox, run
hg push ~/Dropbox/Shared/Code/MyProject.1 You’ll then see Dropbox’s menu item indicate it’s syncing, and when it’s done, all should be well!
Why not use a hosting service?
There exist hosting services for Mercurial (similar to Github in the git world). Personally, I’m a fan and user of Bitbucket. On top of hosting my code, the free issue tracker and wiki are boss as well. Sadly though, both Github and Bitbucket’s pricing plans are deficient for my particular use case.
Most of the time when I use this technique, I’m the only other person who will ever see the code, and I’m only using Dropbox to keep things in sync between my two machines. Dropbox’s pricing structure is pretty reasonable — I can have hundreds of “private” repositories, as long as I stay within disk space limitations.
Both Github and Bitbucket make you pay per private repository. This makes sense if I’m going to be sharing the code with a number of other people and want to utilize additional features like issue tracking, but doesn’t really make sense when it’s just me. Furthermore, I create a number of these one off, private projects — I don’t want to be paying monthly for code I wrote (potentially) years ago and will never touch again.
The solution is archiving
I wish that these services would allow me to archive a project — that is, mark it as inactive and unused. I’d be unable to pull or push from the repository and all of the other metadata would be in read-only mode. Only the number of active private projects would be limited. Incidentally, the excellent time tracking site Freckle uses this technique to awesome effect.
With the ability to archive I would be able to better estimate the total cost of a service like Bitbucket or Github, as the cost would be stable over time, instead of (likely) rising to unaffordable levels. Instead of feeling like I’m paying a fair price for a service I could run myself,2 I’m worried about costs rising in the future and generally feeling very apprehensive.