diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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( diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -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): diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -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):