tags:

views:

177

answers:

2

When I clone out a Mercurial repository it usually shows files as being modified when they have not. This can happen when I do the following steps;

$ hg clone <url>
$ cd project
$ hg st
.... large number of files with M at the start for modified
$ hg diff
.... no result.

I think this is because the files have had their permissions changed in the process so it seems like the files are different since hg doesn't actually do a diff on each file when hg st is used. I know this can happen in git too.

if I do a hg commit then the problem does go away but it means I have to do an empty commit and that isn't particularly nice.

I've tried doing various things like hg st --all to get more information and it only shows that some files are modified - not all. I can't see a pattern.

When I'm doing my hg clone its happening on my network drive that I used because its backed up - I'm not sure if this could be whats causing the file permissions to change? I'm currently running Ubunut 9.04.

is there a way that I can get hg st to correct itself somehow?

The project in question (although its happened with others) is http://bitbucket.org/d0ugal/django-bursar/overview/ as I'm looking to do some work on it.

+2  A: 

If it's the permissions that have changed, you can see those differences by using hg diff --git. I'm not sure why the permissions would be changing upon checkout though.

jamessan
Thanks - I had just discovered that thanks to some help on IRC. Posted an answer myself as to how I resolved the issue in the end - not ideal but I can get back to work now!
Orange Box
A: 

As it turned out doing:

$ hg st --git

...shows that the file permissions had indeed changed from 644 to 755.

I don't particularly like the solution but I was able to resolve it by running this (on the server hosting the code, not my local machine).

find . -type f -print | xargs chmod 644

Then two files showed they had changed from 755 to 644 (so I updated those individually). Luckily it was pretty easy in this case but a project with more diverse file permissions could be a problem.

I think the issue could be with how my server is sharing the drive - I'll need to look into that at another point but this serves a fit for the interim. It must be something to do with how the files are saved to the remote machine? I think next time I'll try doing the git clone on the server itself and the work on the project locally.

As a side note, there is a point about this behavior in git's FAQ. http://git.wiki.kernel.org/index.php/GitFaq#Why_does_git_diff_sometimes_list_a_file_that_has_no_changes.3F - i couldn't find anything for mercurial though.

Orange Box
On another project I cloned the repository on my server, where the code is hosted, and it checked out correctly with the right permissions. It seems that somewhere between checking out and copying onto a network drive the permissions were changed.
Orange Box
Shouldn't that be `hg diff --git` rather than `hg st --git`?
Roberto Aloi