[PATCH 3 of 4] bundle2: move the 'close' method off the unpackermixin

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Apr 9 13:41:55 EDT 2017


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1491757704 -7200
#      Sun Apr 09 19:08:24 2017 +0200
# Node ID 9df8644ff8483025564479285c0e652677bae0a0
# Parent  0ae7bb16d6ceb88bbb76859dbdf30c9f92490369
# EXP-Topic bundle2.doc
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 9df8644ff848
bundle2: move the 'close' method off the unpackermixin

That method is unrelated to unpacking and only used by the unbundle20 class.
We move it there for clarity.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -653,12 +653,6 @@ class unpackermixin(object):
                 else:
                     raise
         return None
-
-    def close(self):
-        """close underlying file"""
-        if util.safehasattr(self._fp, 'close'):
-            return self._fp.close()
-
 def getunbundler(ui, fp, magicstring=None):
     """return a valid unbundler object for a given magicstring"""
     if magicstring is None:
@@ -811,6 +805,11 @@ class unbundle20(unpackermixin):
         self.params # load params
         return self._compressed
 
+    def close(self):
+        """close underlying file"""
+        if util.safehasattr(self._fp, 'close'):
+            return self._fp.close()
+
 formatmap = {'20': unbundle20}
 
 b2streamparamsmap = {}


More information about the Mercurial-devel mailing list