[PATCH 3 of 5 paths v3] ui.paths: filter config options containing "." (BC)

Gregory Szorc gregory.szorc at gmail.com
Sun Mar 8 14:54:16 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1425243224 28800
#      Sun Mar 01 12:53:44 2015 -0800
# Node ID 0f9c6588afcbaaca41b8a5ff17d8969e7f6d157a
# Parent  57681bad997779da88778ff95254951c89250441
ui.paths: filter config options containing "." (BC)

Upcoming patches will enable additional attributes to be defined
on a per-path basis. This will be done by creating config options
of the form "path.X" and "path.Y."

This patch teaches the new paths API to assume options containing
"." are per-path attributes and not valid path names.

This patch is technically backwards incompatible because nothing
was preventing people from using "." in path names. However, the
author feels this convention is not widespread enough to warrant
maintaining backwards compatibility. If backwards compatibility
is needed, we'll have to employ different functionality for
defining per-path attributes, such as separate config sections
per path. An earlier version of this patch series did feature
separate config sections per path. However, people felt that
adopting sub-options was a better approach since this is done
elsewhere (such as with merge tool definition).

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -941,8 +941,14 @@ class paths(dict):
         for name, loc in ui.configitems('paths'):
             # No location is the same as not existing.
             if not loc:
                 continue
+
+            # Options with "." are reserved for future use to define
+            # per-path attributes.
+            if '.' in name:
+                continue
+
             self[name] = path(name, rawloc=loc)
 
     def getpath(self, name, default=None):
         """Return a ``path`` for the specified name, falling back to a default.
diff --git a/tests/test-paths.t b/tests/test-paths.t
--- a/tests/test-paths.t
+++ b/tests/test-paths.t
@@ -62,4 +62,19 @@
   $ hg -q id
   000000000000
 
   $ cd ..
+
+Options with "." are reserved for per-path settings
+
+  $ cat >> $HGRCPATH << EOF
+  > [paths]
+  > default = http://hg.example.com/
+  > default.foo = True
+  > other = http://hg2.example.com/
+  > other.irrelevant = "some value"
+  > EOF
+  $ hg init paths-with-options
+  $ hg -R paths-with-options paths
+  default = http://hg.example.com/
+  gpath1 = http://hg.example.com/
+  other = http://hg2.example.com/


More information about the Mercurial-devel mailing list