version control

Mercurial ignore empty directory

This is one thing that I should really remember. Mercurial will just ignore empty directory so beware of doing something like this:-

$ mkdir myproject
$ cd myproject
$ hg init
$ vi index.php
(editing ....)
$ hg add index.php
$ hg commit
(commit message ...)
$ hg branch exp
marked working directory as branch exp
$ mkdir modules
$ hg add modules
$ hg commit
(commit message)
$ cd modules
$ vi exp.php
(editing ...)
$ hg add exp.php
$ hg up -C default
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg status
abort: No such file or directory
$ cd ..
$ ls
index.php
### wtf !!, this is not on the screen.

My expectation was only exp.php would be gone when I switch ‘cleanly’ to the default branch. In fact, the commit that I did when adding modules directory does record anything though it was logged and the revision increased.

Btw, this blog post illustrated the use of Mercurial better than the official docs.

Mercurial clone through ssh

I want to do some backup of my work on the remote machine. My first try was with hg push but it turn out that hg push require a repository to be exist on the remote end. So I just tarred up the local repo and manually copying the tarball using scp and then did an hg pull to get it back. This way I can just push my changes as a backup in the future. But something is wrong somewhere.

$ hg clone ssh://me@remotehost/home/kamal/hg/repo/
remote: abort: There is no Mercurial repository here (.hg not found)!
abort: no suitable response from remote hg!

It’s weird since doing hg log on the remote repo work just fine. So I try to execute the command with a verbose option, thank god they have it.

$ hg -v clone ssh://me@remotehost/home/kamal/hg/repo/
running ssh me@remotehost "hg -R home/kamal/hg/repo/ serve --stdio"
remote: abort: There is no Mercurial repository here (.hg not found)!
abort: no suitable response from remote hg!

That’s it. A path problem. Add another slash to the path would make it work. Then I checked back the man page and it clearly stated:-

- path is relative to the remote user’s home directory by default. Use an extra slash at the start of a path to specify an absolute path: ssh://example.com//tmp/repository

I use an absolute path because the first try using the common ‘~/’ for my home directory does not work. Next time, carefully read the manual !

Syndicate content