EOL Extension

Automatic management of EOL conversion.

1. Status

This extension is distributed with Mercurial 1.5.4.

Author: Martin Geisler mg@lazybytes.net

2. Overview

Different platforms have different conventions for representing line endings in text files:

When working with people on different operating systems, it can therefore be desirable to be able to checkout text files with the operating system native line ending representation. This extension lets you specify how end of lines (EOLs) are converted between the repository representation and the working copy representation.

3. Configuration

Configure your .hgrc to enable the extension by adding following lines:

[extensions]
eol =

Important: After you've finished your EOL configuration you should make a clean checkout. This is necessary since the EOL extension only converts line endings when hg update is ran (and then only on files that are modified by this command). Line endings are not converted when committing a file. The easiest way to do a clean checkout is to delete all files from your working copy (use hg co null', don't use hg remove for this) - except the .hg directory of course. Then run hg update -C` to check this files out again - now with the correct line endings.

3.1. Per-repository configuration

Then create a file called .hgeol in the root of your working copy. This file contains patterns that tells the extension how files should be converted back and forth between the working copy and the repository. If this file is missing, the extension will not convert any files. The patterns look like this:

[patterns]
**.py = native
**.vcproj = CRLF
**.txt = native
Makefile = LF
**.jpg = BIN

This example specifies the following rules:

The native format must know how to convert the operating system native encoding back to the repository encoding. The default repository encoding is LF, but this is configurable too. Put the following section into .hgeol to override the default:

[repository]
native = CRLF

You should put the .hgeol file under version control so that all members of your project use the same rules.

3.2. Per-user configuration

The extension will normally not touch files in which the EOLs are not consistent, that is, files containing both \r\n and \n line endings. This is on the assumption that the user knows what he or she is doing and has put in the mixed line endings on purpose.

If you want to convert such files anyway, then set

[eol]
only-consistent = False

in your .hgrc file.

Please see hg help eol for help matching your version of the extension and see hg help patterns for more information on the glob patterns used.

4. Hooks

TBD

5. Migrating from win32text to eol

In earlier versions of Mercurial, the conversion of line endings was done with the Win32TextExtension. Please see the page MigratingFromWin32TextToEol for a guide for migrating from win32text to eol.


CategoryBundledExtension