1.3. Windows Specific

Because Windows handles line endings differently to Linux and OS X, you will need some extra entries in your configuration:

# inside [extensions]
hgext.win32text=

[encode]
** = cleverencode:
[decode]
** = cleverdecode:
[hooks]
# Reject commits which would introduce windows-style text files
pretxncommit.crlf = python:hgext.win32text.forbidcrlf

This is very important - by default Mercurial performs no line-ending conversion. By enabling the win32text extension, you cause all text files to be converted to Unix line endings before commit, and converted to Windows line endings when your working copy is updated. This keeps everything consistent.

The cleverencode and cleverdecode entries determine whether a file is text by looking to see if there are any NUL characters in the file; if there are none, it is assumed to be text, if there are one or more NULs then it’s considered to be binary.

The hook defined at the bottom is included to prevent accidental committing of files with remaining Windows line feeds.

If you’re using TortoiseHg, you definitely want to set the following option:

[tortoisehg]
postpull = rebase

This sets the default action after pulling changesets to rebase your own outstanding changesets on top of it. You can also find it in the Global Options under Synchronize > After Pull Operation.