mercurial/bundlerepo.py
changeset 52846 e26c9cb60454
parent 52845 b25208655467
--- a/mercurial/bundlerepo.py	Mon Feb 03 18:27:20 2025 +0000
+++ b/mercurial/bundlerepo.py	Mon Feb 03 18:31:36 2025 +0000
@@ -683,11 +683,15 @@
     rheads = [x for x in rheads if x not in commonset]
 
     state = getremotechanges_state_tracker(peer, incoming, common, rheads)
-    csets = _getremotechanges_slowpath(
-        state, ui, repo, bundlename=bundlename, onlyheads=onlyheads
-    )
 
-    return (state.localrepo, csets, state.cleanup)
+    try:
+        csets = _getremotechanges_slowpath(
+            state, ui, repo, bundlename=bundlename, onlyheads=onlyheads
+        )
+        return (state.localrepo, csets, state.cleanup)
+    except:  # re-raises
+        state.cleanup()
+        raise
 
 
 def _create_bundle(state, ui, repo, bundlename, onlyheads):