hgeol policy changes don't take effect without a restart
I have a repo where the policy started as:
[patterns]
.hgtags = LF
; Shell scripts are Unix LF
**.sh = LF
; Source files
**.c = CRLF
I recently changed the policy to LF, and did the update to null and back again. But when I edited the file, I noticed that in the diff window, the entire file's content was marked as removed and re-added. The same is true when running hg diff
in the log window. But hg diff
in a terminal window correctly shows only the few added lines. Additionally, committing from tortoise will commit the wrong line endings. Using tortoise vs separate command terminal to do the updates didn't matter. Closing and reopening fixes the diff.
I thought maybe this was a command server thing, but I wasn't able to write a test that reproduces it.
$ hg init eol-change
$ cd eol-change
$ cat >> .hgeol << EOF
> [patterns]
> **.c = CRLF
> EOF
$ hg ci -Aqm 'add CRLF eol policy'
>>> with open('file.c', 'wb') as fp:
... fp.write('line1\r\nline2\r\nline3\r\n')
$ hg ci -Aqm 'add CRLF file'
$ cat > .hgeol << EOF
> [patterns]
> **.c = LF
> EOF
>>> from __future__ import absolute_import
>>> from hgclient import check, readchannel, runcommand
>>> @check
... def diff(server):
... readchannel(server)
... runcommand(server, ['ci', '-m', 'change eol policy'])
... runcommand(server, ['up', '-C', 'null'])
... runcommand(server, ['up', '-C', 'tip'])
... with open('file.c', 'wb') as fp:
... fp.write('line1\r\nline2\r\nline2.5\r\n\r\nline3\r\n')
... runcommand(server, ['diff'])
*** runcommand ci -m change eol policy
*** runcommand up -C null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
*** runcommand up -C tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
*** runcommand diff
diff -r a5a9447127e7 file.c
--- a/file.c Thu Jan 01 00:00:00 1970 +0000
+++ b/file.c Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +1,5 @@
line1
line2
+line2.5
+
line3