outgoing: pass subrepo path using function argument instead of abssource hack
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 15 Apr 2021 09:23:28 +0200
changeset 46930 0afe96e374a7
parent 46929 5a59a0ed0a37
child 46931 d4e4ccb75f99
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
mercurial/commands.py
mercurial/hg.py
mercurial/subrepo.py
--- a/mercurial/commands.py	Thu Apr 15 09:23:19 2021 +0200
+++ b/mercurial/commands.py	Thu Apr 15 09:23:28 2021 +0200
@@ -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(
--- a/mercurial/hg.py	Thu Apr 15 09:23:19 2021 +0200
+++ b/mercurial/hg.py	Thu Apr 15 09:23:28 2021 +0200
@@ -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:
--- a/mercurial/subrepo.py	Thu Apr 15 09:23:19 2021 +0200
+++ b/mercurial/subrepo.py	Thu Apr 15 09:23:28 2021 +0200
@@ -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):