Differences between revisions 4 and 5
Revision 4 as of 2010-05-31 19:52:38
Size: 1055
Comment:
Revision 5 as of 2010-06-01 07:16:36
Size: 3419
Comment:
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
Different platforms have different conventions for representation of line endings in text files: Different platforms have different conventions for representing line endings in text files:
Line 12: Line 12:
 * Unix and Linux traditionally uses LF (`\n`) on Unix. Many tools can handle CRLF, but sometimes the native format is essential.
 * Older versions of Mac OS used CR (`\r`), but Mac OS X and later is Unix and uses LF.
 * 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 and later is Unix and uses LF. This extension does not support the old CR format.
Line 15: Line 15:
This extension will let your configure Mercurial to write text files using line endings that match your OS. 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.
Line 25: Line 25:
Then please see `hg help eol` for details on how to configure the extension. ==== Per Repository Configuration ====
Line 27: Line 27:
/!\ Expand this section. 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. 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.

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

EOL Extension

This extension is distributed with Mercurial 1.5.4.

Author: Martin Geisler mg@lazybytes.net

1. 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 uses 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 and later 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.

2. Configuration

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

[extensions]
eol =

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

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


CategoryExtension

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