##// END OF EJS Templates
ui: pass a `ui` object to `paths.getpath`...
marmoute -
r47454:66fb0455 default
parent child Browse files
Show More
@@ -1407,7 +1407,7 b' def perfphasesremote(ui, repo, dest=None'
1407 1407 opts = _byteskwargs(opts)
1408 1408 timer, fm = gettimer(ui, opts)
1409 1409
1410 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
1410 path = ui.getpath(dest, default=(b'default-push', b'default'))
1411 1411 if not path:
1412 1412 raise error.Abort(
1413 1413 b'default repository not configured!',
@@ -837,7 +837,7 b' def _push(orig, ui, repo, dest=None, *ar'
837 837 exchange, b'_localphasemove', _phasemove
838 838 )
839 839 # Copy-paste from `push` command
840 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
840 path = ui.getpath(dest, default=(b'default-push', b'default'))
841 841 if not path:
842 842 raise error.Abort(
843 843 _(b'default repository not configured!'),
@@ -4946,7 +4946,7 b' def outgoing(ui, repo, dest=None, **opts'
4946 4946 """
4947 4947 # hg._outgoing() needs to re-resolve the path in order to handle #branch
4948 4948 # style URLs, so don't overwrite dest.
4949 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
4949 path = ui.getpath(dest, default=(b'default-push', b'default'))
4950 4950 if not path:
4951 4951 raise error.ConfigError(
4952 4952 _(b'default repository not configured!'),
@@ -5680,7 +5680,7 b' def push(ui, repo, dest=None, **opts):'
5680 5680 # this lets simultaneous -r, -b options continue working
5681 5681 opts.setdefault(b'rev', []).append(b"null")
5682 5682
5683 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
5683 path = ui.getpath(dest, default=(b'default-push', b'default'))
5684 5684 if not path:
5685 5685 raise error.ConfigError(
5686 5686 _(b'default repository not configured!'),
@@ -1317,7 +1317,7 b' def incoming(ui, repo, source, opts):'
1317 1317
1318 1318
1319 1319 def _outgoing(ui, repo, dest, opts):
1320 path = ui.paths.getpath(dest, default=(b'default-push', b'default'))
1320 path = ui.getpath(dest, default=(b'default-push', b'default'))
1321 1321 if not path:
1322 1322 raise error.Abort(
1323 1323 _(b'default repository not configured!'),
@@ -1826,9 +1826,9 b' def outgoing(repo, subset, x):'
1826 1826 l and getstring(l[0], _(b"outgoing requires a repository path")) or b''
1827 1827 )
1828 1828 if not dest:
1829 # ui.paths.getpath() explicitly tests for None, not just a boolean
1829 # ui.getpath() explicitly tests for None, not just a boolean
1830 1830 dest = None
1831 path = repo.ui.paths.getpath(dest, default=(b'default-push', b'default'))
1831 path = repo.ui.getpath(dest, default=(b'default-push', b'default'))
1832 1832 if not path:
1833 1833 raise error.Abort(
1834 1834 _(b'default repository not configured!'),
@@ -1031,7 +1031,7 b' class ui(object):'
1031 1031 def expandpath(self, loc, default=None):
1032 1032 """Return repository location relative to cwd or from [paths]"""
1033 1033 try:
1034 p = self.paths.getpath(loc)
1034 p = self.getpath(loc)
1035 1035 if p:
1036 1036 return p.rawloc
1037 1037 except error.RepoError:
@@ -1039,7 +1039,7 b' class ui(object):'
1039 1039
1040 1040 if default:
1041 1041 try:
1042 p = self.paths.getpath(default)
1042 p = self.getpath(default)
1043 1043 if p:
1044 1044 return p.rawloc
1045 1045 except error.RepoError:
@@ -1051,6 +1051,13 b' class ui(object):'
1051 1051 def paths(self):
1052 1052 return paths(self)
1053 1053
1054 def getpath(self, *args, **kwargs):
1055 """see paths.getpath for details
1056
1057 This method exist as `getpath` need a ui for potential warning message.
1058 """
1059 return self.paths.getpath(self, *args, **kwargs)
1060
1054 1061 @property
1055 1062 def fout(self):
1056 1063 return self._fout
@@ -2190,7 +2197,7 b' class paths(dict):'
2190 2197 loc, sub = ui.configsuboptions(b'paths', name)
2191 2198 self[name] = path(ui, name, rawloc=loc, suboptions=sub)
2192 2199
2193 def getpath(self, name, default=None):
2200 def getpath(self, ui, name, default=None):
2194 2201 """Return a ``path`` from a string, falling back to default.
2195 2202
2196 2203 ``name`` can be a named path or locations. Locations are filesystem
@@ -2222,8 +2229,8 b' class paths(dict):'
2222 2229 except KeyError:
2223 2230 # Try to resolve as a local path or URI.
2224 2231 try:
2225 # We don't pass sub-options in, so no need to pass ui instance.
2226 return path(None, None, rawloc=name)
2232 # we pass the ui instance are warning might need to be issued
2233 return path(ui, None, rawloc=name)
2227 2234 except ValueError:
2228 2235 raise error.RepoError(_(b'repository %s does not exist') % name)
2229 2236
General Comments 0
You need to be logged in to leave comments. Login now