Mercurial showing files as modified incorrectly

故事扮演 提交于 2019-12-21 12:17:47

问题


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.


回答1:


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.




回答2:


As it turned out doing:

$ hg diff --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.



来源:https://stackoverflow.com/questions/2221280/mercurial-showing-files-as-modified-incorrectly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!