Backed out changeset fc317bd5b637 stable
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 06 May 2024 11:26:52 +0200
branchstable
changeset 51611 436aee94f2d7
parent 51610 6c39edd1d348
child 51612 c1b6b8b03e48
Backed out changeset fc317bd5b637
mercurial/hg.py
--- a/mercurial/hg.py	Thu May 02 02:20:42 2024 +0200
+++ b/mercurial/hg.py	Mon May 06 11:26:52 2024 +0200
@@ -1420,58 +1420,44 @@
     )
 
 
-_no_subtoppath = object()
-
-
 def _outgoing(ui, repo, dests, opts, subpath=None):
     out = set()
     others = []
     for path in urlutil.get_push_paths(repo, ui, dests):
         dest = path.loc
-        prev_subtopath = getattr(repo, "_subtoppath", _no_subtoppath)
-        try:
-            repo._subtoppath = dest
-            if subpath is not None:
-                subpath = urlutil.url(subpath)
-                if subpath.isabs():
-                    dest = bytes(subpath)
+        repo._subtoppath = dest
+        if subpath is not None:
+            subpath = urlutil.url(subpath)
+            if subpath.isabs():
+                dest = bytes(subpath)
+            else:
+                p = urlutil.url(dest)
+                if p.islocal():
+                    normpath = os.path.normpath
                 else:
-                    p = urlutil.url(dest)
-                    if p.islocal():
-                        normpath = os.path.normpath
-                    else:
-                        normpath = posixpath.normpath
-                    p.path = normpath(b'%s/%s' % (p.path, subpath))
-                    dest = bytes(p)
-            branches = path.branch, opts.get(b'branch') or []
+                    normpath = posixpath.normpath
+                p.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))
-            revs, checkout = addbranchrevs(
-                repo, repo, branches, opts.get(b'rev')
+        ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(dest))
+        revs, checkout = addbranchrevs(repo, repo, branches, opts.get(b'rev'))
+        if revs:
+            revs = [repo[rev].node() for rev in logcmdutil.revrange(repo, revs)]
+
+        other = peer(repo, opts, dest)
+        try:
+            outgoing = discovery.findcommonoutgoing(
+                repo, other, revs, force=opts.get(b'force')
             )
-            if revs:
-                revs = [
-                    repo[rev].node() for rev in logcmdutil.revrange(repo, revs)
-                ]
-
-            other = peer(repo, opts, dest)
-            try:
-                outgoing = discovery.findcommonoutgoing(
-                    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)
-            except:  # re-raises
-                other.close()
-                raise
-        finally:
-            if prev_subtopath is _no_subtoppath:
-                del repo._subtoppath
-            else:
-                repo._subtoppath = prev_subtopath
+            o = outgoing.missing
+            out.update(o)
+            if not o:
+                scmutil.nochangesfound(repo.ui, repo, outgoing.excluded)
+            others.append(other)
+        except:  # re-raises
+            other.close()
+            raise
     # make sure this is ordered by revision number
     outgoing_revs = list(out)
     cl = repo.changelog
@@ -1543,6 +1529,7 @@
     finally:
         for oth in others:
             oth.close()
+        del repo._subtoppath
 
 
 def verify(repo, level=None):