Debian Codegraph @

doc/html/ext-eol.html

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <meta name="generator" content="Docutils 0.21.2: https://docutils.sourceforge.io/" />
7 <title>eol</title>
8 <link rel="stylesheet" href="../style.css" type="text/css" />
9 </head>
10 <body>
11 <div class="document" id="eol">
12 <span id="ext-eol"></span>
13 <h1 class="title">eol</h1>
14
15 <div class="contents htmlonly topic" id="contents">
16 <p class="topic-title"><a class="reference internal" href="#top">Contents</a></p>
17 <ul class="simple">
18 <li><a class="reference internal" href="#description" id="toc-entry-1">Description</a></li>
19 </ul>
20 </div>
21 <p>automatically manage newlines in repository files</p>
22 <div class="section" id="description">
23 <h1><a class="toc-backref" href="#contents">Description</a></h1>
24 <p>This extension allows you to manage the type of line endings (CRLF or
25 LF) that are used in the repository and in the local working
26 directory. That way you can get CRLF line endings on Windows and LF on
27 Unix/Mac, thereby letting everybody use their OS native line endings.</p>
28 <p>The extension reads its configuration from a versioned <tt class="docutils literal">.hgeol</tt>
29 configuration file found in the root of the working directory. The
30 <tt class="docutils literal">.hgeol</tt> file use the same syntax as all other Mercurial
31 configuration files. It uses two sections, <tt class="docutils literal">[patterns]</tt> and
32 <tt class="docutils literal">[repository]</tt>.</p>
33 <p>The <tt class="docutils literal">[patterns]</tt> section specifies how line endings should be
34 converted between the working directory and the repository. The format is
35 specified by a file pattern. The first match is used, so put more
36 specific patterns first. The available line endings are <tt class="docutils literal">LF</tt>,
37 <tt class="docutils literal">CRLF</tt>, and <tt class="docutils literal">BIN</tt>.</p>
38 <p>Files with the declared format of <tt class="docutils literal">CRLF</tt> or <tt class="docutils literal">LF</tt> are always
39 checked out and stored in the repository in that format and files
40 declared to be binary (<tt class="docutils literal">BIN</tt>) are left unchanged. Additionally,
41 <tt class="docutils literal">native</tt> is an alias for checking out in the platform's default line
42 ending: <tt class="docutils literal">LF</tt> on Unix (including Mac OS X) and <tt class="docutils literal">CRLF</tt> on
43 Windows. Note that <tt class="docutils literal">BIN</tt> (do nothing to line endings) is Mercurial's
44 default behavior; it is only needed if you need to override a later,
45 more general pattern.</p>
46 <p>The optional <tt class="docutils literal">[repository]</tt> section specifies the line endings to
47 use for files stored in the repository. It has a single setting,
48 <tt class="docutils literal">native</tt>, which determines the storage line endings for files
49 declared as <tt class="docutils literal">native</tt> in the <tt class="docutils literal">[patterns]</tt> section. It can be set to
50 <tt class="docutils literal">LF</tt> or <tt class="docutils literal">CRLF</tt>. The default is <tt class="docutils literal">LF</tt>. For example, this means
51 that on Windows, files configured as <tt class="docutils literal">native</tt> (<tt class="docutils literal">CRLF</tt> by default)
52 will be converted to <tt class="docutils literal">LF</tt> when stored in the repository. Files
53 declared as <tt class="docutils literal">LF</tt>, <tt class="docutils literal">CRLF</tt>, or <tt class="docutils literal">BIN</tt> in the <tt class="docutils literal">[patterns]</tt> section
54 are always stored as-is in the repository.</p>
55 <p>Example versioned <tt class="docutils literal">.hgeol</tt> file:</p>
56 <pre class="literal-block">
57 [patterns]
58 **.py = native
59 **.vcproj = CRLF
60 **.txt = native
61 Makefile = LF
62 **.jpg = BIN
63
64 [repository]
65 native = LF
66 </pre>
67 <div class="admonition note">
68 <p class="first admonition-title">Note</p>
69 <p class="last">The rules will first apply when files are touched in the working
70 directory, e.g. by updating to null and back to tip to touch all files.</p>
71 </div>
72 <p>The extension uses an optional <tt class="docutils literal">[eol]</tt> section read from both the
73 normal Mercurial configuration files and the <tt class="docutils literal">.hgeol</tt> file, with the
74 latter overriding the former. You can use that section to control the
75 overall behavior. There are three settings:</p>
76 <ul class="simple">
77 <li><tt class="docutils literal">eol.native</tt> (default <tt class="docutils literal">os.linesep</tt>) can be set to <tt class="docutils literal">LF</tt> or
78 <tt class="docutils literal">CRLF</tt> to override the default interpretation of <tt class="docutils literal">native</tt> for
79 checkout. This can be used with <a class="reference external" href="hg-archive.html"><tt class="docutils literal">hg archive</tt></a> on Unix, say, to
80 generate an archive where files have line endings for Windows.</li>
81 <li><tt class="docutils literal"><span class="pre">eol.only-consistent</span></tt> (default True) can be set to False to make
82 the extension convert files with inconsistent EOLs. Inconsistent
83 means that there is both <tt class="docutils literal">CRLF</tt> and <tt class="docutils literal">LF</tt> present in the file.
84 Such files are normally not touched under the assumption that they
85 have mixed EOLs on purpose.</li>
86 <li><tt class="docutils literal"><span class="pre">eol.fix-trailing-newline</span></tt> (default False) can be set to True to
87 ensure that converted files end with a EOL character (either <tt class="docutils literal">\n</tt>
88 or <tt class="docutils literal">\r\n</tt> as per the configured patterns).</li>
89 </ul>
90 <p>The extension provides <tt class="docutils literal">cleverencode:</tt> and <tt class="docutils literal">cleverdecode:</tt> filters
91 like the deprecated win32text extension does. This means that you can
92 disable win32text and enable eol and your filters will still work. You
93 only need to these filters until you have prepared a <tt class="docutils literal">.hgeol</tt> file.</p>
94 <p>The <tt class="docutils literal">win32text.forbid*</tt> hooks provided by the win32text extension
95 have been unified into a single hook named <tt class="docutils literal">eol.checkheadshook</tt>. The
96 hook will lookup the expected line endings from the <tt class="docutils literal">.hgeol</tt> file,
97 which means you must migrate to a <tt class="docutils literal">.hgeol</tt> file first before using
98 the hook. <tt class="docutils literal">eol.checkheadshook</tt> only checks heads, intermediate
99 invalid revisions will be pushed. To forbid them completely, use the
100 <tt class="docutils literal">eol.checkallhook</tt> hook. These hooks are best used as
101 <tt class="docutils literal">pretxnchangegroup</tt> hooks.</p>
102 <p>See <a class="reference external" href="topic-patterns.html"><tt class="docutils literal">hg help patterns</tt></a> for more information about the glob patterns
103 used.</p>
104 </div>
105 </div>
106 </body>
107 </html>