I faced a situation where I wanted to develop locally at home but still keep the sources available for myself on other hosts. For example, I am currently developing a TDD primer slideware and I have a simple example code base for a coding dojo that I wrote here at home. I want to be able to continue it at work too and then be able to sync it with my home laptop.
The problem is that I don’t want to run a Mercurial webserver at home (no proper hardware, just an old T42) or use any commercial service like bitbucket. I can’t run servers at work either due to firewalls and corporate policies.
But what I do have is a shell! And it does have Mercurial installed. So, off we go to setup a private code proxy that I can use as an intermediate storage for my work.
remote> ssh user@remote remote> cd ~/my-repos/ remote> mkdir project remote> cd project remote> hg init remote> exit local> cd project local> hg clone . ssh://user@remote/my-repos/project searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 6 changesets with 29 changes to 13 files
Just remember that clone assumes path relative to users home directory (that’s why there was so short path on the command).
After the first clone I have to manually run
on the remote to make it aware of the changes. Now I just edited the projects hgrc file on the remote to contain
[hooks] changegroup = hg update
Now it updates itself when ever I push stuff into it again. That’s it, now I can easily setup and share with myself any repositories that contain source code I want access anywhere.