Differences between revisions 3 and 9 (spanning 6 versions)
Revision 3 as of 2014-08-02 06:19:16
Size: 1670
Editor: Josip Medved
Comment: update to description
Revision 9 as of 2014-08-04 04:35:55
Size: 2157
Editor: Josip Medved
Comment: Added --all option
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#pragma section-numbers 2
Line 3: Line 4:
This Mercurial extension will remove the BOM from all Unicode files. Resulting
file will be UTF-8 and without pesky BOM bytes.
This Mercurial extension will remove the BOM from all Unicode files. Resulting file will be UTF-8 and without pesky BOM bytes.
Line 21: Line 21:
This extension will modify all Unicode files with BOM (byte order mark) and
convert them to BOM-less UTF-8. This comes especially handy when dealing with
Microsoft's Visual Studio that is really UTF-8 BOM happy.
This extension will modify all Unicode files with BOM (byte order mark) and convert them to BOM-less UTF-8. This comes especially handy when dealing with Microsoft's Visual Studio that is really UTF-8 BOM happy.
Line 25: Line 23:
Extensions adds two commands (`killbom`, `checkbom`) and hooks into the commit
process.
Extensions adds two commands (`killbom`, `checkbom`) and hooks into the commit process.
Line 34: Line 31:
    [extensions]
    killbom = /path/to/killbom.py
    
    [killbom]
    extensions = utf-8 utf-16le utf-16be utf-32le utf-32be
    maxsize = 1024
[extensions]
killbom = /path/to/killbom.py

[killbom]
action = modify
extensions = utf-8 utf-16le utf-16be utf-32le utf-32be
maxsize = 1024
Line 41: Line 39:


 * `extensions` is a list of all Unicode encodings that will be recognized.
 * `maxsize` is maximum file size that will be processed (in kilobytes).
 * `action` can be either `modify` (default), `verify`, or `ignore`:
  * `modify` - files will be adjusted before the commit
  * `verify` - commit will be aborted if there are Unicode files with BOM but files won't be modified
  * `ignore` - no action will be taken
Line 45: Line 51:
Using `killbom` command will remove Unicode COM from all modified and newly
added files:
Using `killbom` command will remove Unicode BOM from all modified and newly added files:
Line 49: Line 54:
    hg killbom [options]
    
    options:
      -8 --utf8only removes only UTF-8 BOM signature
hg killbom [options]

options:
  -8 --utf8only removes only UTF-8 BOM signature
  -a --all check all files in the repository
Line 59: Line 65:
    hg checkbom [options]
    
    options:
      -8 --utf8only checks for only UTF-8 BOM signature
hg checkbom [options]

options:
  -8 --utf8only checks for only UTF-8 BOM signature
  -a --all check all files in the repository
Line 66: Line 73:
In addition there are three hooks. On `pretxncommit` and `pretxnchangegroup`
extension will verify whether all Unicode files are BOM-free and it will stop
commit if they are not. On `precommit` extension will modify files and remove
BOM.


== See also ==
In addition there are three hooks. On `pretxncommit` and `pretxnchangegroup` extension will verify whether all Unicode files are BOM-free and it will stop commit if they are not. On `precommit` extension will modify files and remove BOM.

KillBom

This Mercurial extension will remove the BOM from all Unicode files. Resulting file will be UTF-8 and without pesky BOM bytes.

1. Status

This extension is not distributed with Mercurial.

Author: Josip Medved

Repository: https://bitbucket.org/jmedved/hg-killbom

2. Overview

This extension will modify all Unicode files with BOM (byte order mark) and convert them to BOM-less UTF-8. This comes especially handy when dealing with Microsoft's Visual Studio that is really UTF-8 BOM happy.

Extensions adds two commands (killbom, checkbom) and hooks into the commit process.

3. Configuration

To use it just add following in the hgrc or global Mercurial settings file:

[extensions]
killbom = /path/to/killbom.py

[killbom]
action = modify
extensions = utf-8 utf-16le utf-16be utf-32le utf-32be
maxsize = 1024
  • extensions is a list of all Unicode encodings that will be recognized.

  • maxsize is maximum file size that will be processed (in kilobytes).

  • action can be either modify (default), verify, or ignore:

    • modify - files will be adjusted before the commit

    • verify - commit will be aborted if there are Unicode files with BOM but files won't be modified

    • ignore - no action will be taken

4. Usage

Using killbom command will remove Unicode BOM from all modified and newly added files:

hg killbom [options]

options:
  -8 --utf8only  removes only UTF-8 BOM signature
  -a --all       check all files in the repository

To just verify whether all files are BOM free, you would use checkbom command:

hg checkbom [options]

options:
  -8 --utf8only  checks for only UTF-8 BOM signature
  -a --all       check all files in the repository

In addition there are three hooks. On pretxncommit and pretxnchangegroup extension will verify whether all Unicode files are BOM-free and it will stop commit if they are not. On precommit extension will modify files and remove BOM.


CategoryExtensionsByOthers

KillBomExtension (last edited 2014-08-04 04:35:55 by Josip Medved)