telling mercurial to ignore a file when merging and updating - mercurial

I want mercurial to ignore my own local copy of log/development.log (I am on RoR).
I used "hg forget filename" to forget the file, and then committed that change.
It seems to be successful now.. but every time I merge with other changesets now, I see
remote changed log/development.log which local deleted
use (c)hanged version or leave (d)eleted?
what am I doing wrong? how can I make this msg go away? I just want my local copy to be separate from the copy in the repository.
Thank you...

If you deleted the file in your line, and you merge it with the one that still has this file, this message is to be expected. The only way to get rid of it is to remove this file from the repos/branches you're merging with (or get their owners to remove it, if you don't control them).
And then never commit a temporary log file into the repository ever again.

Related

hg status returns blank but file has changed

I have a file that I've copied over the top of a file in my hg repo with xcopy. I've done this literally 1000's of times with different files and no issue. When I copy this specific file and try to commit, I get the 'nothing changed' message.
The file has definitely changed. If I open it in Notepad, make no changes and then resave it, mercurial recognizes the changes. If I open it in Notepad++, edit it, undo the edit and then save it, mercurial recognizes the changes.
If I restart the process (copying files into a new hg repo and committing), it fails at the same point every time. There is something about these files, but what? I thought it might be date modified as they were the exact same millisecond, but after editing my copied file to add 1 minute to the date modified, it still doesn't work.
What can cause this? What should I look for?
hg status
hg status -A
C file.txt
hg commit file.txt
nothing changed
On Windows, using Mercurial 2.2.2 with NO extensions enabled (inotify extension is known to cause a similar issue)
It appears that Mercurial (2.2.2 at least), only checks a file when it gets edited/replaced. It does this by checking the date modified. As my files had the exact same timestamp, it didn't check the contents.
When I edited the timestamp so it was different, that only changes the metadata and not the file itself. So Mercurial wasn't notified of the change, so it never looked and saw that the timestamp was different.
Solution: Changing the timestamp of the new file BEFORE copying the file (or copy it somewhere else, edit it, then copy to the repo) allows Mercurial to see the that the timestamp has changed and it will then check the contents for what's changed.

How to stop mercurial from syncing an EXISTING project file

So the problem is that all developers need different settings for their local testing, but the settings file is part of the project (unlike the nbproject folder for example that we all ignore). I know about .htignore, but the filter only applies to files that are not part of the project.
If I forget the file, then this removes it from the "global" repository, where we have a "holder" version of the settings file.
Right now we just don't commit that file, but every now and then somebody forgets and pushes his own settings, which then are synced back to other developers and it's a constant pain. We just want to "automatically" not push that file. Is there a solution to this? Are we doing something wrong?
You could add a precommit hook that gives an error every time you try to commit this particular file.
To handle the case of developers that forget to setup such a hook, you can also add a serverside hook that will reject their push.

Binary equal files show as modified, unable to revert

I suddenly have a few files that show as modified, but KDiff says they are binary equal. Reverting and discarding those changes does nothing.
Somehow, the eol extension is enabled and when I try to disable it, I can't view that one repo's Working Directory in TortoiseHg. An error appears:
[Error 6] The handle is invalid
When using the command line hg status, this error appears:
'cleverencode:' is not recognized as an internal or external command,
operable program or batch file.
When using hg revert myfile, .orig files are generated but the files still appear as modified and the same error from above appears.
When updating to a previous commit, a whole lot of other files get in the same situation like those few I have now.
If necessary, I can throw away this clone and make a new clone, but it would be nice if this can be resolved without doing so.
Was able to solve it.
My global mercurial.ini had some lines with cleverencode in them. After removing those, the issue has disappeared. Enabling/disabling the eol extension also doesn't seem to cause any issues any more.
I suspect the troublemaker was Atlassian's SourceTree, I had installed an update yesterday and it asked if automatic line ending handling should be enabled. I'm quite sure I unchecked it, regardless, it seems to have mixed eol config with win32text config.
See also: [SRCTREEWIN-708] Possible error with Mercurial line ending handling configuration - Atlassian JIRA
I found that the cleverencode did not work for me -- I didn't have it in my mercurial.ini. My case was also a binary file that mysteriously got marked as modified and would not go away with revert, clean, etc...
I did some poking around and fixed it: there's a repo/.hg/largefiles directory. I believe mercurial keeps this as a local cache of binary files in order to revert back changes. In this directory you'll see a bunch of file names in hex. In TortoiseHg "browse" your binary file causing the problem. It'll show you the hex code corresponding to your binary. Find that file in the largefiles directory and delete it.
You should now be able to revert the file back to unchanged. I think mercurial uses the largefiles version to revert first. Then, when this version doesn't match the repo version it gets marked as modified (in my case my binary somehow got truncated to 0 length) and will never go away.
You can also just delete the largefiles dir altogether if you can't match the hex name. It will get recreated as needed. I think the only repercussion is that it's take longer to do some binary file operations since it will have to go to the server.

how to ignore files in kiln/mercurial using tortoise hg "that are part of the repository"

We use tortoise hg with Kiln. In my vs 2010 c# project there are some files that are part of the repository but I would like tortoise hg to ignore them when I make a commit.
For eg., say in a login screen I may hard code the userid, password for testing. I dont really want this file considered during a commit. I understand .hgignore file but this really works for files that are not part of the repo. Any trick in tortoise hg to ignore files that are part of the repo ? (so they do not show up as modified (M) during a commit.) thanks
I always use a combination of .hgignore and BeforeBuild (in the .csproj file) for things like this.
In one of my pet projects, I have the following setup:
App.config contains my real hardcoded user id and password for testing.
App.config.example is identical, but with fake data like "dummy_user" and "dummy_pw".
App.config is not part of the repository, and it's ignored (in .hgignore).
App.config.example is part of the repository.
Then, I have the following in the BeforeBuild target in the .csproj file of my solution:
<Target Name="BeforeBuild">
<Copy
Condition="!Exists('App.config')"
SourceFiles="App.config.example"
DestinationFiles="App.config"/>
</Target>
All this together has the following effect:
the config file with the real data can never be accidentally committed to the repository, because it's ignored
the repository only contains the config file with the example data
if someone else clones the repository to his machine, he won't have the "real" config file...but if it's missing, it will be automatically created before the first build by Visual Studio / MSBuild by simply copying the .example file (and then he can just put his real login data into the newly created App.config file).
if an App.config with real hardcoded user data already exists, it won't be overwritten when building because the BeforeBuild event will only happen if App.config does not already exist
The answer by Christian is the right one, but I want to mention that TortoiseHg supports what you want with their Auto Exclude List.
One problem with an exclude list is that it cannot work with merges: you must commit all files when you merge and so you'll have to do a little dance with shelve, merge, commit, and unshelve.
When you do a TortoiseHG commit, there is a list of files with checkboxes by them. Deselect the files you do not want comitted.
Or, on the command line, do a commit of the form hg commit --exclude "pattern", where pattern is defined in the hg man page.
You could always use hg forget.

TortoiseHG: undoing Guess Rename --> Accept Match

I'm using TortoiseHG and am trying to handle a renamed file. Unfortunately, I accidentally clicked Accept Match for one of the files and want to undo it. How do I do so without hurting the files I'm trying to commit?
In the commit dialog you can right-click on the added file, and select forget. Then the file is no longer marked as copy. When you want the file in the commit, you can add this file again.
I'm not sure what's different but for me, there is no "forget" option in this situation.
What worked for me is choosing "revert" on the added file (the one marked as 'A'). This removes the rename, but also restores the original file. (If you renamed asdf.txt to fdsa.txt you will now have two files with those names.)
You then have to manually delete the restored file, and you should be back where you started. Note that I find it's safer to delete files with Windows file explorer, since they will end up in the recycle bin. Files deleted from thg are deleted permanently.