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 –


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.

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 Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s