diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4985,11 +4985,7 @@ finally: other.close() - repo._subtoppath = path.pushloc or path.loc - try: - return hg.outgoing(ui, repo, dest, opts) - finally: - del repo._subtoppath + return hg.outgoing(ui, repo, dest, opts) @command( diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1320,7 +1320,7 @@ return _incoming(display, subreporecurse, ui, repo, source, opts) -def _outgoing(ui, repo, dest, opts): +def _outgoing(ui, repo, dest, opts, subpath=None): path = ui.getpath(dest, default=(b'default-push', b'default')) if not path: raise error.Abort( @@ -1328,6 +1328,15 @@ hint=_(b"see 'hg help config.paths'"), ) dest = path.pushloc or path.loc + if subpath is not None: + subpath = urlutil.url(subpath) + if subpath.isabs(): + dest = bytes(subpath) + else: + p = urlutil.url(dest) + p.path = os.path.normpath(b'%s/%s' % (p.path, subpath)) + dest = bytes(p) + branches = path.branch, opts.get(b'branch') or [] ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(dest)) @@ -1382,10 +1391,10 @@ yield n -def outgoing(ui, repo, dest, opts): +def outgoing(ui, repo, dest, opts, subpath=None): if opts.get(b'graph'): logcmdutil.checkunsupportedgraphflags([], opts) - o, other = _outgoing(ui, repo, dest, opts) + o, other = _outgoing(ui, repo, dest, opts, subpath=subpath) ret = 1 try: if o: diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -873,7 +873,8 @@ opts = copy.copy(opts) opts.pop(b'rev', None) opts.pop(b'branch', None) - return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts) + subpath = subrepoutil.repo_rel_or_abs_source(self._repo) + return hg.outgoing(ui, self._repo, dest, opts, subpath=subpath) @annotatesubrepoerror def incoming(self, ui, source, opts):