# HG changeset patch # User Pierre-Yves David # Date 2021-04-15 07:23:28 # Node ID 0afe96e374a79e4d776606bf73e79230db474ec3 # Parent 5a59a0ed0a379df7b19243ea739bee5422afd722 outgoing: pass subrepo path using function argument instead of abssource hack This is clearer, remove the needs for the `repo._subtoppath` hack and will make our live easier when making `outgoing` accept multiple destinations. Differential Revision: https://phab.mercurial-scm.org/D10390 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4985,11 +4985,7 @@ def outgoing(ui, repo, dest=None, **opts 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 @@ def incoming(ui, repo, source, opts): 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 @@ def _outgoing(ui, repo, dest, opts): 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 @@ def _outgoing_filter(repo, revs, opts): 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 @@ class hgsubrepo(abstractsubrepo): 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):