Patchwork [3,of,9,paths,v2] ui.paths: filter config options containing "." (BC)

login
register
mail settings
Submitter Gregory Szorc
Date March 1, 2015, 9:50 p.m.
Message ID <ab2f54a886bbe13db285.1425246642@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/7864/
State Changes Requested
Headers show

Comments

Gregory Szorc - March 1, 2015, 9:50 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1425243224 28800
#      Sun Mar 01 12:53:44 2015 -0800
# Node ID ab2f54a886bbe13db2854bdf750e32560e16c1e1
# Parent  4ac2f2aba635e6a1db1a2ddd0dd02ca1b1f5ecc6
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).

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -942,8 +942,14 @@  class paths(object):
         for name, loc in self.ui.configitems('paths'):
             # No URL 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
+
             yield path(name, loc=loc)
 
     def __getitem__(self, key):
         for path in self:
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
+  gpath1 = http://hg.example.com/
+  default = http://hg.example.com/
+  other = http://hg2.example.com/