How do I specify the source file encoding?

Sean Russell ser at germane-software.com
Fri Feb 20 21:38:29 CST 2009


Christian Boos wrote:
> There's one thing though which is possible in systems like Subversion 
> and which is hard to do at the Mercurial level is that you can set the 
> encoding on a file by file basis, if you really want to. The "Mercurial 
>   
You're right, of course, in your post.

This is a special instance of a larger issue (if you consider it to be 
an issue): Mercurial does not support ad-hoc versioned metadata about 
repository nodes such as files and directories.  svn:mime-type is just a 
versioned file attribute, like any other versioned attribute, except 
that the SVN server(s) understand it and behave accordingly when serving 
up data over the web.  These attributes are well-defined enough that 
third-party tools (such as Trac) can leverage them to also "do the right 
thing."

Mercurial simply doesn't support this sort of per-node versioned 
properties; where Subversion tracks the executable flag through this 
generic properties mechanism, Mercurial has that sort of knowledge 
hard-coded into it -- which, obviously, has limited the ways in which it 
can be used.
> way" for such a thing would be to have some sort of .hgencoding file, 
> which would map file patterns to encoding names. Or alternatively, a 
> .hgmimetypes file that would map file patterns to both mime-types and 
> encodings, like the svn:mime-type property does in svn. Such additional 
> metadata would be useful for external tools like Trac, but maybe also 
> for hgweb, for things like highlighting or recoding from the original
I can't imagine that it would be terribly difficult to implement, if 
someone wanted to do it.  I'd much rather see a more general solution 
that could be leveraged for future features, than a continuing set of 
hacks for specific cases.

SVN's properties aren't a cure-all, but they've been used to implement 
everything from file mime-types to merge tracking; they've been 
exceedingly useful.

--- SER



More information about the Mercurial mailing list