comparison mercurial/ui.py @ 27265:47539ea08bdb

ui: pass ui instance to path.__init__ It will be used in a subsequent patch.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 06 Dec 2015 12:31:46 -0800
parents e07003a94ef3
children 4dccc37b87bd
comparison
equal deleted inserted replaced
27264:e07003a94ef3 27265:47539ea08bdb
1069 continue 1069 continue
1070 1070
1071 # TODO ignore default-push once all consumers stop referencing it 1071 # TODO ignore default-push once all consumers stop referencing it
1072 # since it is handled specifically below. 1072 # since it is handled specifically below.
1073 1073
1074 self[name] = path(name, rawloc=loc) 1074 self[name] = path(ui, name, rawloc=loc)
1075 1075
1076 # Handle default-push, which is a one-off that defines the push URL for 1076 # Handle default-push, which is a one-off that defines the push URL for
1077 # the "default" path. 1077 # the "default" path.
1078 defaultpush = ui.config('paths', 'default-push') 1078 defaultpush = ui.config('paths', 'default-push')
1079 if defaultpush: 1079 if defaultpush:
1080 # "default-push" can be defined without "default" entry. This is a 1080 # "default-push" can be defined without "default" entry. This is a
1081 # bit weird, but is allowed for backwards compatibility. 1081 # bit weird, but is allowed for backwards compatibility.
1082 if 'default' not in self: 1082 if 'default' not in self:
1083 self['default'] = path('default', rawloc=defaultpush) 1083 self['default'] = path(ui, 'default', rawloc=defaultpush)
1084 self['default'].pushloc = defaultpush 1084 self['default'].pushloc = defaultpush
1085 1085
1086 def getpath(self, name, default=None): 1086 def getpath(self, name, default=None):
1087 """Return a ``path`` from a string, falling back to a default. 1087 """Return a ``path`` from a string, falling back to a default.
1088 1088
1110 try: 1110 try:
1111 return self[name] 1111 return self[name]
1112 except KeyError: 1112 except KeyError:
1113 # Try to resolve as a local path or URI. 1113 # Try to resolve as a local path or URI.
1114 try: 1114 try:
1115 return path(None, rawloc=name) 1115 # We don't pass sub-options in, so no need to pass ui instance.
1116 return path(None, None, rawloc=name)
1116 except ValueError: 1117 except ValueError:
1117 raise error.RepoError(_('repository %s does not exist') % 1118 raise error.RepoError(_('repository %s does not exist') %
1118 name) 1119 name)
1119 1120
1120 assert False 1121 assert False
1121 1122
1122 class path(object): 1123 class path(object):
1123 """Represents an individual path and its configuration.""" 1124 """Represents an individual path and its configuration."""
1124 1125
1125 def __init__(self, name, rawloc=None, pushloc=None): 1126 def __init__(self, ui, name, rawloc=None, pushloc=None):
1126 """Construct a path from its config options. 1127 """Construct a path from its config options.
1127 1128
1129 ``ui`` is the ``ui`` instance the path is coming from.
1128 ``name`` is the symbolic name of the path. 1130 ``name`` is the symbolic name of the path.
1129 ``rawloc`` is the raw location, as defined in the config. 1131 ``rawloc`` is the raw location, as defined in the config.
1130 ``pushloc`` is the raw locations pushes should be made to. 1132 ``pushloc`` is the raw locations pushes should be made to.
1131 1133
1132 If ``name`` is not defined, we require that the location be a) a local 1134 If ``name`` is not defined, we require that the location be a) a local