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

login
register
mail settings
Submitter Pierre-Yves David
Date April 10, 2017, 3:33 p.m.
Message ID <80068be95fbee53cc307.1491838387@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20071/
State Accepted
Headers show

Comments

Pierre-Yves David - April 10, 2017, 3:33 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Yuya Nishihara - April 11, 2017, 1:18 p.m.
On Mon, 10 Apr 2017 17:33:07 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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

Queued the first three per review, thanks.

Patch

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 = {}