Converting Mercurial UNIX Line Endings to Windows
Asked Answered
S

1

5

How do I clone a Mercurial repository so that the my working copy always has CRLF line endings?

This is similar to this question Problems configuring eol extension in Mercurial

But I'm missing something that it doesn't seem to work on my computer.

I'm new to Mercurial having been using SVN (TortoiseSVN) for several years. I installed TortoiseHG and I am working with Brian O'Sullivan's Mercurial: The Definitive Guide book.

So one of the first things I did was clone his sample repository on my machine and found that the file had LF endings rather than the Windows CRLF version.

So I tried to find the option to handle this as I did in SVN.

I created a file in %USERPROFILE%\Mercurial.ini with the following.

[extensions]
eol =

I deleted the repository and checked it out again. No change.

Looking around some more I saw I might need a .hgeol file. So I created one in the %USERPROFILE% folder with

[patterns]
** = native

Deleted and recloned the repository, the file still had LF's rather than CRLF.

I then tried again putting the .hgeol file in the parent directory of the repository and lastly putting the command inside the Mercurial.ini file. I also tried replacing native with CRLF.

I must be missing something since it seems that this should be all I need to get it to work. Maybe I'm missing a concept here of automatic conversion like SVN did.

Ss answered 29/5, 2012 at 16:16 Comment(0)
P
7

The .hgeol file should be a file in the root of your repository, not in the parent of the root, nor in the user directory nor inside the Mercurial.ini file.

To add it to an existing clone, probably you should remove the existing working copy first with hg update null (or hg clone --noupdate). Then once you added the .hgeol file, you can get your working copy back using hg update, at which point the EOL conversion will take effect.

I do not think you can add it directly to clones to without first committing the file to your repository.

Portis answered 30/5, 2012 at 10:14 Comment(2)
I will give this a try this morning.Ss
That worked. I had tried putting the .hgeol file in the working directory, but I was unable to clone it because the folder wasn't empty. I think this helps my understanding because when I clone my modified clone I get the orginal LF ends. This tells me that it only looks at the .HG folder for the information and ingnores what is in the working folder. This is probably not an issue because on my own (company) repositories we will have the options set up from scratch. It's only the ones that I don't control and haven't included the option, that I would need to do this.Ss

© 2022 - 2024 — McMap. All rights reserved.