Mercurial > hg-stable
changeset 26064:1b1ab6ff58c4
ui: capture push location on path instances
Currently, we treat "default" and "default-push" as separate paths,
even though they are the same logical entity but with different paths
for different operations. Because they are the same entity and
because we will eventually be implementing an official mechanism
for declaring push URLs for paths, we establish a "pushloc" attribute
on path instances. We populate this attribute on the "default" path
with the "default-push" value, if present. This will enable
consumers stop referencing "default-push" which will make their code
simpler.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 07 Aug 2015 21:53:34 -0700 |
parents | d29859cfcfc2 |
children | dceaef70e410 |
files | mercurial/ui.py |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Mon May 25 13:10:38 2015 -0700 +++ b/mercurial/ui.py Fri Aug 07 21:53:34 2015 -0700 @@ -996,8 +996,18 @@ # 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) + # 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 and 'default' in self: + self['default']._pushloc = defaultpush + def getpath(self, name, default=None): """Return a ``path`` from a string, falling back to a default. @@ -1027,11 +1037,12 @@ class path(object): """Represents an individual path and its configuration.""" - def __init__(self, name, rawloc=None): + def __init__(self, name, rawloc=None, pushloc=None): """Construct a path from its config options. ``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, @@ -1053,6 +1064,7 @@ self.name = name self.rawloc = rawloc self.loc = str(u) + self._pushloc = pushloc # When given a raw location but not a symbolic name, validate the # location is valid. @@ -1061,6 +1073,10 @@ raise ValueError('location is not a URL or path to a local ' 'repo: %s' % rawloc) + @property + def pushloc(self): + return self._pushloc or self.loc + # we instantiate one globally shared progress bar to avoid # competing progress bars when multiple UI objects get created _progresssingleton = None