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

login
register
mail settings
Submitter Pierre-Yves David
Date April 9, 2017, 5:41 p.m.
Message ID <9df8644ff84830255644.1491759715@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20040/
State Changes Requested
Headers show

Comments

Pierre-Yves David - April 9, 2017, 5:41 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 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.
Ryan McElroy - April 10, 2017, 9:17 a.m.
On 4/9/17 6:41 PM, 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 9df8644ff8483025564479285c0e652677bae0a0
> # Parent  0ae7bb16d6ceb88bbb76859dbdf30c9f92490369
> # EXP-Topic bundle2.doc
> bundle2: move the 'close' method off the unpackermixin
>
> That method is unrelated to unpacking and only used by the unbundle20 class.
s/That/This

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

Patch

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