Patchwork D960: bundle2: immediate exit for ctrl+c (issue5692)

login
register
mail settings
Submitter phabricator
Date Oct. 13, 2017, 2:06 p.m.
Message ID <06f45463fa55509dc40d3b446f606812@localhost.localdomain>
Download mbox | patch
Permalink /patch/24827/
State Not Applicable
Headers show

Comments

phabricator - Oct. 13, 2017, 2:06 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5f79f5f8487a: bundle2: immediate exit for ctrl+c (issue5692) (authored by durham, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D960?vs=2592&id=2675

REVISION DETAIL
  https://phab.mercurial-scm.org/D960

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS




To: durham, #hg-reviewers, quark
Cc: yuja, mercurial-devel

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -370,21 +370,21 @@ 
         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
             # getting in that bad state. So, we swallow the seeking error and
             # 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)