Преглед на файлове

Make the GitFile context manager discard writes on exceptions

Dan Villiom Podlaski Christiansen преди 2 години
родител
ревизия
199d7d6d7d
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      dulwich/file.py

+ 4 - 1
dulwich/file.py

@@ -209,7 +209,10 @@ class _GitFile(object):
         return self
 
     def __exit__(self, exc_type, exc_val, exc_tb):
-        self.close()
+        if exc_type is not None:
+            self.abort()
+        else:
+            self.close()
 
     def __getattr__(self, name):
         """Proxy property calls to the underlying file."""