subrepo: propagate non-default path on outgoing stable
authorFelipe Resende <felipe@fcresende.dev.br>
Sun, 31 Mar 2024 17:57:46 -0300
branchstable
changeset 52086 fb15ba66c702
parent 52085 653b7a19f1de
child 52087 888e00b2c3ee
subrepo: propagate non-default path on outgoing There was already a fix made in 5dbff89cf107 for pull and push commands. I did the same for the outgoing command. The problem I identified is that when the parent repository has multiple paths, the outgoing command was not respecting the parent path used and was always using the default path for subrepositories.
mercurial/hg.py
tests/test-exchange-multi-source.t
--- a/mercurial/hg.py	Fri Oct 25 01:14:53 2024 +0200
+++ b/mercurial/hg.py	Sun Mar 31 17:57:46 2024 -0300
@@ -1472,30 +1472,18 @@
             displayer.close()
 
 
+_no_subtoppath = object()
+
+
 def outgoing(ui, repo, dests, opts, subpath=None):
     if opts.get(b'graph'):
         logcmdutil.checkunsupportedgraphflags([], opts)
-    o, others = _outgoing(ui, repo, dests, opts, subpath=subpath)
     ret = 1
-    try:
-        if o:
-            ret = 0
-            display_outgoing_revs(ui, repo, o, opts)
-        for oth in others:
-            cmdutil.outgoinghooks(ui, repo, oth, opts, o)
-            ret = min(ret, _outgoing_recurse(ui, repo, dests, opts))
-        return ret  # exit code is zero since we found outgoing changes
-    finally:
-        for oth in others:
-            oth.close()
-
-
-def _outgoing(ui, repo, dests, opts, subpath=None):
-    out = set()
-    others = []
     for path in urlutil.get_push_paths(repo, ui, dests):
         dest = path.loc
-        if True:
+        prev_subtopath = getattr(repo, "_subtoppath", _no_subtoppath)
+        try:
+            repo._subtoppath = dest
             if subpath is not None:
                 subpath = urlutil.url(subpath)
                 if subpath.isabs():
@@ -1525,14 +1513,24 @@
                     repo, other, revs, force=opts.get(b'force')
                 )
                 o = outgoing.missing
-                out.update(o)
                 if not o:
                     scmutil.nochangesfound(repo.ui, repo, outgoing.excluded)
-                others.append(other)
+                else:
+                    ret = 0
+                    display_outgoing_revs(ui, repo, o, opts)
+
+                cmdutil.outgoinghooks(ui, repo, other, opts, o)
+                ret = min(ret, _outgoing_recurse(ui, repo, dests, opts))
             except:  # re-raises
+                raise
+            finally:
                 other.close()
-                raise
-    return list(out), others
+        finally:
+            if prev_subtopath is _no_subtoppath:
+                del repo._subtoppath
+            else:
+                repo._subtoppath = prev_subtopath
+    return ret
 
 
 def verify(repo, level=None):
--- a/tests/test-exchange-multi-source.t	Fri Oct 25 01:14:53 2024 +0200
+++ b/tests/test-exchange-multi-source.t	Sun Mar 31 17:57:46 2024 -0300
@@ -133,10 +133,26 @@
   $ hg out -G -R test-repo-bare ./branch-E-push ./branch-G-push ./branch-H-push
   comparing with ./branch-E-push
   searching for changes
+  o  changeset:   7:40faebb2ec45
+     tag:         tip
+     parent:      2:f838bfaca5c7
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     H
+  
+  o  changeset:   6:c521a06b234b
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     G
+  |
+  o  changeset:   5:2f3a4c5c1417
+     parent:      1:27547f69f254
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     F
+  
   comparing with ./branch-G-push
   searching for changes
-  comparing with ./branch-H-push
-  searching for changes
   o  changeset:   7:40faebb2ec45
   |  tag:         tip
   |  parent:      2:f838bfaca5c7
@@ -144,17 +160,6 @@
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     H
   |
-  | o  changeset:   6:c521a06b234b
-  | |  user:        test
-  | |  date:        Thu Jan 01 00:00:00 1970 +0000
-  | |  summary:     G
-  | |
-  | o  changeset:   5:2f3a4c5c1417
-  |    parent:      1:27547f69f254
-  |    user:        test
-  |    date:        Thu Jan 01 00:00:00 1970 +0000
-  |    summary:     F
-  |
   | o  changeset:   4:a603bfb5a83e
   | |  user:        test
   | |  date:        Thu Jan 01 00:00:00 1970 +0000
@@ -170,6 +175,29 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     C
   
+  comparing with ./branch-H-push
+  searching for changes
+  o  changeset:   6:c521a06b234b
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     G
+  |
+  o  changeset:   5:2f3a4c5c1417
+     parent:      1:27547f69f254
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     F
+  
+  o  changeset:   4:a603bfb5a83e
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     E
+  |
+  o  changeset:   3:b3325c91a4d9
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     D
+  
   $ hg bundle -R test-repo-bare bundle.hg ./branch-E-push ./branch-G-push ./branch-H-push
   searching for changes
   searching for changes
@@ -339,11 +367,15 @@
   $ hg out -G -R test-repo-bare ./branch-E-push ./branch-G-push ./branch-H-push --rev default
   comparing with ./branch-E-push
   searching for changes
+  o  changeset:   7:40faebb2ec45
+     tag:         tip
+     parent:      2:f838bfaca5c7
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     H
+  
   comparing with ./branch-G-push
   searching for changes
-  comparing with ./branch-H-push
-  searching for changes
-  no changes found
   o  changeset:   7:40faebb2ec45
   |  tag:         tip
   |  parent:      2:f838bfaca5c7
@@ -356,6 +388,9 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     C
   
+  comparing with ./branch-H-push
+  searching for changes
+  no changes found
   $ hg bundle -R test-repo-bare bundle.hg ./branch-E-push ./branch-G-push ./branch-H-push --rev default
   searching for changes
   searching for changes
@@ -422,11 +457,6 @@
   $ hg out -G -R test-repo-bare ./branch-G-push ./branch-H-push ./branch-E-push --rev default
   comparing with ./branch-G-push
   searching for changes
-  comparing with ./branch-H-push
-  searching for changes
-  no changes found
-  comparing with ./branch-E-push
-  searching for changes
   o  changeset:   7:40faebb2ec45
   |  tag:         tip
   |  parent:      2:f838bfaca5c7
@@ -439,6 +469,18 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     C
   
+  comparing with ./branch-H-push
+  searching for changes
+  no changes found
+  comparing with ./branch-E-push
+  searching for changes
+  o  changeset:   7:40faebb2ec45
+     tag:         tip
+     parent:      2:f838bfaca5c7
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     H
+  
   $ hg bundle -R test-repo-bare bundle.hg ./branch-G-push ./branch-H-push ./branch-E-push --rev default
   searching for changes
   searching for changes