--- 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):