Differences between revisions 9 and 10
Revision 9 as of 2010-10-27 17:03:01
Size: 3554
Editor: mpm
Comment:
Revision 10 as of 2011-03-25 16:50:12
Size: 3799
Editor: mail
Comment:
Deletions are marked like this. Additions are marked like this.
Line 73: Line 73:
=== 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.

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:

  • Windows traditionally uses CRLF (\r\n, carriage-return followed by line-feed). The default text editor on Windows, Notepad, only understands CRLF. Command line tools and redirection also use CRLF.

  • Unix and Linux traditionally uses LF (\n), though many tools can handle CRLF as well.

  • Older versions of Mac OS used CR (\r), but Mac OS X is Unix and uses LF. This extension does not support the old CR format.

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 =

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:

  • all Python files (**.py, a recursive glob pattern) should be stored in the working copy using the operating system native EOLs (\r\n on Windows, \n on Mac and Linux). The files are stored in LF format in the repository -- this is configurable using the [repository] section described below.

  • all Visual Studio project files (**.vcproj) should be stored in Windows format in both the working copy and the repository. This rule applies equally to all operating systems.

  • all text files (**.txt) should also be stored in native form in the working copy.

  • the Makefile should be stored in Unix format in working copy and repository.

  • all JPEG images (**.jpg) are binary and should be left alone. The extension will never touch files containing NUL bytes (\0) so this rule is not strictly necessary.

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.

3.3. 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

EolExtension (last edited 2013-08-26 20:58:53 by BryanHoffpauir)