[PATCH] ui: small cleanup in suboption parsing

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Dec 7 22:58:29 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1449528679 28800
#      Mon Dec 07 14:51:19 2015 -0800
# Node ID 4259ca7d7d1eefd25f926e3ebff52b9d48d4344c
# Parent  a9ab664083bff058206777783da85bee0a20c74e
# EXP-Topic cleanup.pushattr
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 4259ca7d7d1e
ui: small cleanup in suboption parsing

Anything after the first ':' is expected to be a suboption name. The old code is
correct but it:
- use 'rsplit' for no good reason (same as 'split' unless 'maxsplit' is used),
- splits multiples time even if only the first value is of interest.

We move to "split(':', 1)" because it is doing exactly what we need.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -319,11 +319,11 @@ class ui(object):
         if v is None:
             return None
         if not os.path.isabs(v) or "://" not in v:
             src = self.configsource(section, name, untrusted)
             if ':' in src:
-                base = os.path.dirname(src.rsplit(':')[0])
+                base = os.path.dirname(src.split(':', 1)[0])
                 v = os.path.join(base, os.path.expanduser(v))
         return v
 
     def configbool(self, section, name, default=False, untrusted=False):
         """parse a configuration element as a boolean


More information about the Mercurial-devel mailing list