In my previous post I moved my first steps with Mercurial DVCS, now I'll install a Mercurial server implementation and configure both my computers to access it using SSH protocol.
With DVCS you don't have to use a central server, repositories could be shared over LAN using shared folders, but this doesn't mean you can't have one. Various mercurial server side implementations exists, using different protocols. May be I'm too server-client minded but I didn't feel satisfied by just sharing repositories over a shared folder so I decided to install Mercurial-server.
Installing Mercurial-server is an easy task the command
sudo apt-get install mercurial-server
complete the installation process and the creation of the application user (hg). A bit more complex is configuring SSH for accessing the server, I mainly followed instructions from here and from Mercurial-server documentation.
Mercurial-server uses public-key authentication and SSH-Agent in order to grant access to its clients, so the first step has been to generate a keys couple for SSH. The ssh-keygen command does this interactively.
maxx@VeritonS661:~$ ssh-keygen -t dsaGenerating public/private dsa key pair.Enter file in which to save the key (/home/maxx/.ssh/id_dsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/maxx/.ssh/id_dsa.Your public key has been saved in /home/maxx/.ssh/id_dsa.pub.
I then copied the public key in mercurial-server keys configuration path and told mercurial-server to refresh its authentication files, using the following commands:
ssh-add -L > maxx.keysudo mkdir /etc/mercurial-server/keys/root/maxxsudo cp maxx.key /etc/mercurial-server/keys/root/maxx /veritons661sudo -u hg /usr/share/mercurial-server/refresh-auth
the usual path for mercurial-server keys is (for root users)
but if the same user must be accessed from different machines a different path is used:
since I was going to add the maxx user from the EEEPC too I had to use, of course, the second from. On the EEEPC side I generated SSH keys at the same manner then, after logging to the desktop computer (the server) with:
ssh -A veritons661
and I eventually registered EEEPC's maxx user like this
ssh-add -L > eeepc900.keysudo cp eeepc900.key /etc/mercurial-server/keys/root/maxx/eeepc900sudo -u hg /usr/share/mercurial-server/refresh-auth
Pushing changes to remote repositories ...
The operation of sharing code from the local repository th the remote one is commonly called “push”.
First the remote repository must be created and initialized, Eclipse allow to do this from the repository creation wizard.
The repository location URL is in the form “ssh://hg@<host>/<repository-name>”. The “Init Mercurial Repository” check must be selected.
Once the remote repository is properly initialized changes can be pushed selecting the “ Team → Push ...” item from project contextual menu.
The push wizard ask for repository URL
and the change-set to push
Netbeans plug-in doesn't seem to offer the remote repository initialization feature so, from the EEEPC, I had to do it by command-line:
hg init ssh://hg@veritons661/<repository-name>
Once the remote repository is initialized changes can be pushed to it using Netbeans menu voice “Team → Share → Push Other ...”.
Pulling a project from remote repository
The inverse operation of pushing is, of course, pulling. From Eclipse the “File → Import ...” menu brings to the “Clone existing mercurial repository” wizard
from here I did set the repository URL and the wizard proceeded with importing all the files in an empty project
On the Netbeans side pulling changes is similar apart from terminology:
Selecting the “Team → Share → Pull Other ...” item from menu the pull wizard appear asking for the remote repository URL.
That's all for now. I managed, with the help of Mercurial and Mercurial-server, to set-up a VCS that works on both my two computers, even when off-line. Of course Mercurial, like all others similar systems, only take care of files versioning. Converting a project from Eclipse to Netbeans and vice-versa is still a task that has to be done manually, and it can be tricky sometimes. If I want to continue to work with both IDEs I'll have to find a way to make it more straight-forward.