[PATCH 2 of 3 V2] ui: pass ui instance to path.__init__
Gregory Szorc
gregory.szorc at gmail.com
Sun Dec 6 14:59:33 CST 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1449433906 28800
# Sun Dec 06 12:31:46 2015 -0800
# Node ID 225b213102e4943f160a03c6e75e58cf97106165
# Parent 6594eeb85d16bebd5f4173062aeba38df858c3d2
ui: pass ui instance to path.__init__
It will be used in a subsequent patch.
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1066,26 +1066,26 @@ class paths(dict):
for name, loc in ui.configitems('paths'):
# No location is the same as not existing.
if not loc:
continue
# TODO ignore default-push once all consumers stop referencing it
# since it is handled specifically below.
- self[name] = path(name, rawloc=loc)
+ self[name] = path(ui, name, rawloc=loc)
# Handle default-push, which is a one-off that defines the push URL for
# the "default" path.
defaultpush = ui.config('paths', 'default-push')
if defaultpush:
# "default-push" can be defined without "default" entry. This is a
# bit weird, but is allowed for backwards compatibility.
if 'default' not in self:
- self['default'] = path('default', rawloc=defaultpush)
+ self['default'] = path(ui, 'default', rawloc=defaultpush)
self['default'].pushloc = defaultpush
def getpath(self, name, default=None):
"""Return a ``path`` from a string, falling back to a default.
``name`` can be a named path or locations. Locations are filesystem
paths or URIs.
@@ -1107,29 +1107,31 @@ class paths(dict):
if not name:
return None
try:
return self[name]
except KeyError:
# Try to resolve as a local path or URI.
try:
- return path(None, rawloc=name)
+ # We don't pass sub-options in, so no need to pass ui instance.
+ return path(None, None, rawloc=name)
except ValueError:
raise error.RepoError(_('repository %s does not exist') %
name)
assert False
class path(object):
"""Represents an individual path and its configuration."""
- def __init__(self, name, rawloc=None, pushloc=None):
+ def __init__(self, ui, name, rawloc=None, pushloc=None):
"""Construct a path from its config options.
+ ``ui`` is the ``ui`` instance the path is coming from.
``name`` is the symbolic name of the path.
``rawloc`` is the raw location, as defined in the config.
``pushloc`` is the raw locations pushes should be made to.
If ``name`` is not defined, we require that the location be a) a local
filesystem path with a .hg directory or b) a URL. If not,
``ValueError`` is raised.
"""
More information about the Mercurial-devel
mailing list