changeset 34637:5f79f5f8487a

bundle2: immediate exit for ctrl+c (issue5692) 21c2df59a regressed bundle2 by catching all exceptions and trying to handle them. The old behavior was to allow KeyboardInterrupts to throw and not have graceful cleanup, which allowed it to exit immediately. Let's go back to that behavior. Differential Revision: https://phab.mercurial-scm.org/D960
author Durham Goode <durham@fb.com>
date Wed, 11 Oct 2017 10:36:59 -0700
parents 31c6c4d27be7
children 021607b4ef49
files mercurial/bundle2.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed Oct 04 11:04:18 2017 -0400
+++ b/mercurial/bundle2.py	Wed Oct 11 10:36:59 2017 -0700
@@ -370,14 +370,10 @@
         if not self.iterator:
             return
 
-        if exc:
-            # If exiting or interrupted, do not attempt to seek the stream in
-            # the finally block below. This makes abort faster.
-            if (self.current and
-                not isinstance(exc, (SystemExit, KeyboardInterrupt))):
-                # consume the part content to not corrupt the stream.
-                self.current.seek(0, 2)
-
+        # Only gracefully abort in a normal exception situation. User aborts
+        # like Ctrl+C throw a KeyboardInterrupt which is not a base Exception,
+        # and should not gracefully cleanup.
+        if isinstance(exc, Exception):
             # Any exceptions seeking to the end of the bundle at this point are
             # almost certainly related to the underlying stream being bad.
             # And, chances are that the exception we're handling is related to
@@ -385,6 +381,10 @@
             # re-raise the original error.
             seekerror = False
             try:
+                if self.current:
+                    # consume the part content to not corrupt the stream.
+                    self.current.seek(0, 2)
+
                 for part in self.iterator:
                     # consume the bundle content
                     part.seek(0, 2)