Mercurial > hg-stable
changeset 46950:279df499511e
incoming: kill the `repo._subtoppath =` hack
We do the same as for `hg outgoing`, instead of relying on implicit passing
value by monkey punching them onto the repo object, we pass equivalent
information by argument to the proper function.
This is way cleaner.
Differential Revision: https://phab.mercurial-scm.org/D10416
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 14 Apr 2021 17:41:02 +0200 |
parents | 3800a6aafb6f |
children | 338ab1d89ddb |
files | mercurial/commands.py mercurial/hg.py mercurial/subrepo.py |
diffstat | 3 files changed, 23 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Apr 14 17:29:27 2021 +0200 +++ b/mercurial/commands.py Wed Apr 14 17:41:02 2021 +0200 @@ -4351,11 +4351,7 @@ finally: other.close() - repo._subtoppath = ui.expandpath(source) - try: - return hg.incoming(ui, repo, source, opts) - finally: - del repo._subtoppath + return hg.incoming(ui, repo, source, opts) @command(
--- a/mercurial/hg.py Wed Apr 14 17:29:27 2021 +0200 +++ b/mercurial/hg.py Wed Apr 14 17:41:02 2021 +0200 @@ -1255,7 +1255,14 @@ def _incoming( - displaychlist, subreporecurse, ui, repo, source, opts, buffered=False + displaychlist, + subreporecurse, + ui, + repo, + source, + opts, + buffered=False, + subpath=None, ): """ Helper for incoming / gincoming. @@ -1270,6 +1277,14 @@ msg %= len(srcs) raise error.Abort(msg) source, branches = srcs[0] + if subpath is not None: + subpath = urlutil.url(subpath) + if subpath.isabs(): + source = bytes(subpath) + else: + p = urlutil.url(source) + p.path = os.path.normpath(b'%s/%s' % (p.path, subpath)) + source = bytes(p) other = peer(repo, opts, source) cleanupfn = other.close try: @@ -1297,7 +1312,7 @@ return 0 # exit code is zero since we found incoming changes -def incoming(ui, repo, source, opts): +def incoming(ui, repo, source, opts, subpath=None): def subreporecurse(): ret = 1 if opts.get(b'subrepos'): @@ -1321,7 +1336,9 @@ count += 1 displayer.show(other[n]) - return _incoming(display, subreporecurse, ui, repo, source, opts) + return _incoming( + display, subreporecurse, ui, repo, source, opts, subpath=subpath + ) def _outgoing(ui, repo, dests, opts, subpath=None):
--- a/mercurial/subrepo.py Wed Apr 14 17:29:27 2021 +0200 +++ b/mercurial/subrepo.py Wed Apr 14 17:41:02 2021 +0200 @@ -882,7 +882,8 @@ opts = copy.copy(opts) opts.pop(b'rev', None) opts.pop(b'branch', None) - return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts) + subpath = subrepoutil.repo_rel_or_abs_source(self._repo) + return hg.incoming(ui, self._repo, source, opts, subpath=subpath) @annotatesubrepoerror def files(self):