5

I'm trying to clone a unix-hosted Mercurial repository to a Windows computer. I'm hoping to use the eol extension so that my text files with LF endings on the server have CRLF when cloned to a Windows computer.

Previously I've used the win32text extension which has worked fine, but since the general consensus seems to be that the eol extension is the way to go, I thought I'd give it a shot.

In my Mercurial.ini I have

[extensions]
eol =

I understood that the default behaviour was to convert LF to CRLF on cloning, but I've clearly missed something as whenever I clone something from the Unix server to Windows, the line endings remain as LF.

Any ideas?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Nick Pierpoint
  • 17,641
  • 9
  • 46
  • 74

1 Answers1

5

Following @Geoffrey's comment, I created a .hgeol file as:

[patterns]
** = native

This does the trick, but I'm left confused. I'd assumed that enabling the eol extension would turn on this pattern handling by default. Doesn't this mean that I can only successfully clone from a Unix server if the repository owner has had the foresight to include a .hgeol file handle Windows clients?

Nick Pierpoint
  • 17,641
  • 9
  • 46
  • 74
  • You can always add `.hgeol` yourself (and ignore it with `.hgignore` if you don't want to or not allowed to track the file). If you look at the source, you'll see it's done with a repo wrapper and `pre-update` hook, so you'd get degraded performance if it's turned on for all files (similar to the keyword extension). The thing is most modern tools and editors are supposed to be able to handle different EOLs, and you'd only have to specify the files for those ancient tools that can't. – Geoffrey Zheng Sep 27 '10 at 19:08
  • Yes - I added a local .hgeol and it worked fine. It all just feels like more hard work than it need be. I know most editors will work fine just with LF, but I need folks to be able to quickly open up a text file in Notepad, say, and not give me grief when it doesn't work. – Nick Pierpoint Sep 27 '10 at 23:30
  • 1
    I sympathize with anyone who has to work with the kind of "folks" that made Notepad the [Best Web Authoring Tool](http://blogs.msdn.com/b/oldnewthing/archive/2009/11/02/9915989.aspx). – Geoffrey Zheng Sep 28 '10 at 02:26
  • 1
    Hi Nick and Geoffrey: I wrote the extension and I'm glad you figured it out -- please edit the wiki to mention this issue or you can even send a patch for the documentation to mercurial-devel@selenic.com if you want. As for why you need a `.hgeol` file, then this is because the extension is meant to be something you enable globally and on all platforms. Projects can then distribute a `.hgeol` file tailored for their needs, i.e., with the minimum number of files they need to convert. – Martin Geisler Oct 01 '10 at 08:58
  • Thanks for the follow-up Martin, and great work on the extension. I understand the "** = native" entry is a bit wide-ranging, but is it still 'safe'? – Nick Pierpoint Oct 01 '10 at 09:18
  • `** = native` will convert all files that look line text files. That is all files without any NUL bytes. It should be safe enough. – Martin Geisler Jan 19 '12 at 09:59