encode/decode filter weirdness

Maquelin, Olivier olivier.maquelin at intel.com
Mon Sep 19 19:43:13 CDT 2005


Experimenting with encode/decode filters to convert CRLF <-> LF led to
some behaviors I could not explain. The following was run under Linux
using the 0.7 release of Mercurial.

Starting with a fresh repository, hgrc set up to call my 'txt2unix'
filter (turns CRLF into LF) and a file containing CRLFs:

[~/foo] cat .hg/hgrc
[encode]
*.txt = txt2unix
[~/foo] ls
foo.txt
[~/foo] od -a foo.txt
0000000   o   n   e  cr  nl   t   w   o  cr  nl
0000012

Now I commit the new file and check its contents:

[~/foo] hg addremove
adding foo.txt
[~/foo] hg commit -m "test"
[~/foo] hg status
[~/foo] od -a foo.txt
0000000   o   n   e  cr  nl   t   w   o  cr  nl
0000012

So far no big surprises. foo.txt still contains the CRLFs, but the
internal representation should be the canonical one with LFs. It might
be nice for 'hg status' to tell us that the directory contents do not
match what would be retrieved from the repository, but that is not a
terribly big deal.

Now let's try to extract the canonical representation from the
repository by deleting the file and having it re-created:

[~/foo] rm foo.txt 
[~/foo] hg status
R foo.txt
[~/foo] hg revert
[~/foo] hg status
M foo.txt
[~/foo] hg diff
[~/foo] od -a foo.txt
0000000   o   n   e  nl   t   w   o  nl
0000010

The file contents are as expected, but why is 'hg status' reporting the
file as being modified? The only way to get rid of this seems to be 'hg
update -C':

[~/foo] hg update
[~/foo] hg status
M foo.txt
[~/foo] hg update -C
[~/foo] hg status
[~/foo] od -a foo.txt
0000000   o   n   e  nl   t   w   o  nl
0000010

-- Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.selenic.com/pipermail/mercurial/attachments/20050919/6e589ff3/attachment-0001.html


More information about the Mercurial mailing list