Mercurial tips

I have been using Mercurial as my version control system for a while now. Here are some pointers I picked up along the way.

Mercurial won’t forget files! ‘hg forget <filename>’ returns ‘No such file or directory’

Although Mercurial can perform commits, adds etc. from any location in the folder structure it seems like forget needs to be started from the right spot. Meaning when you type ‘hg status’ you see something like –

<path>/<filename>

so naturally I tried

hg forget <path>/<filename>

But that path did not resolve to the file I was trying to target from my current location in the hierarchy. This works –

hg forget <relative-path>/<filename>

How to restore a file from Mercurial?

First, use hg grep to find the deleted file you wish to recover. The output of this command will show you the last revision for which the file was present, and the path to the deleted file.

Second, run hg revert -r <revision number> <path to deleted file> The deleted file will now be in your working copy, ready to be committed back into head.
http://stackoverflow.com/questions/2175427/how-can-i-recover-a-removed-file-in-mercurial-if-at-all

Mercurial push returns HTTP Error: 500 (Permission denied)

Run chown -R www-data /path/to/repos on the server. It looks like this has to be done for every repository. Is it possible to run apache with higher privileges?

Leave a comment