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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Apr 10 15:33:07 UTC 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 80068be95fbee53cc30784e1bd61df90c2b31ffe
# Parent  f77b40e01801531ef1b5824c49318d0ef081bf30
# 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 80068be95fbe
bundle2: move the 'close' method off the unpackermixin

This 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
@@ -659,12 +659,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:
@@ -817,6 +811,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