[PATCH] eol: support alternate location for .hgeol file (issue3975)

Jorge Acereda jacereda at brainstorm.es
Wed Jul 10 10:24:17 CDT 2013


# HG changeset patch
# User Jorge Acereda <jacereda at brainstorm.es>
# Date 1373469140 -7200
# Branch stable
# Node ID 3487e904f78164e70cf91552419e1ecf235d8daf
# Parent  fbdac607bff3dfc0056268ca77e524a5ddd4f665
eol: support alternate location for .hgeol file (issue3975)

Adds a 'config' setting to the [eol] section that can be used to
specify an alternate location for the .hgeol file. This can help when
dealing with lots of subrepos.

When both the .hgeol and the setting are present, .hgeol takes
precedence.

diff -r fbdac607bff3 -r 3487e904f781 hgext/eol.py
--- a/hgext/eol.py	Mon Jul 01 18:07:33 2013 -0500
+++ b/hgext/eol.py	Wed Jul 10 17:12:20 2013 +0200
@@ -6,8 +6,20 @@
 Unix/Mac, thereby letting everybody use their OS native line endings.
 
 The extension reads its configuration from a versioned ``.hgeol``
-configuration file found in the root of the working copy. The
-``.hgeol`` file use the same syntax as all other Mercurial
+configuration file found in the root of the working copy.
+
+An alternate location for the ``.hgeol`` configuration file can be
+specified in a ``config`` setting in the ``[eol]`` section of your
+``hgrc``. This can be useful when dealing with lots of subrepos. When
+the ``.hgeol`` file is present in a repository, it will take
+precedence over the ``config`` setting.
+
+Example ``.hgrc`` file specifying the location of the ``.hgeol`` file::
+
+  [eol]
+  config = ~/shared-cfg/hgeol
+
+The ``.hgeol`` file use the same syntax as all other Mercurial
 configuration files. It uses two sections, ``[patterns]`` and
 ``[repository]``.
 
@@ -207,7 +219,12 @@
                 if node is None:
                     # Cannot use workingctx.data() since it would load
                     # and cache the filters before we configure them.
-                    data = repo.wfile('.hgeol').read()
+                    try:
+                        f = repo.wfile('.hgeol')
+                    except IOError:
+                        f = open(util.expandpath(ui.config('eol', 'config')))
+                    data = f.read()
+                    f.close()
                 else:
                     data = repo[node]['.hgeol'].data()
                 return eolfile(ui, repo.root, data)


More information about the Mercurial-devel mailing list