Patchwork bundle2.getunbundler: rename "header" to "magicstring"

login
register
mail settings
Submitter Pierre-Yves David
Date June 20, 2015, 11:15 p.m.
Message ID <ff334f0bf6e42d72f478.1434842119@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9732/
State Accepted
Headers show

Comments

Pierre-Yves David - June 20, 2015, 11:15 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1428441267 25200
#      Tue Apr 07 14:14:27 2015 -0700
# Node ID ff334f0bf6e42d72f4785fdf21b73e40dc338e0a
# Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
bundle2.getunbundler: rename "header" to "magicstring"

This is more consistent with the name used in the bundler class. Thanks goes to
Martin von Zweigbergk for pointing this out.
Augie Fackler - June 22, 2015, 2:19 p.m.
On Sat, Jun 20, 2015 at 04:15:19PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1428441267 25200
> #      Tue Apr 07 14:14:27 2015 -0700
> # Node ID ff334f0bf6e42d72f4785fdf21b73e40dc338e0a
> # Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
> bundle2.getunbundler: rename "header" to "magicstring"

Queued, thanks.

>
> This is more consistent with the name used in the bundler class. Thanks goes to
> Martin von Zweigbergk for pointing this out.
>
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -595,22 +595,22 @@ class unpackermixin(object):
>      def close(self):
>          """close underlying file"""
>          if util.safehasattr(self._fp, 'close'):
>              return self._fp.close()
>
> -def getunbundler(ui, fp, header=None):
> -    """return a valid unbundler object for a given header"""
> -    if header is None:
> -        header = changegroup.readexactly(fp, 4)
> -    magic, version = header[0:2], header[2:4]
> +def getunbundler(ui, fp, magicstring=None):
> +    """return a valid unbundler object for a given magicstring"""
> +    if magicstring is None:
> +        magicstring = changegroup.readexactly(fp, 4)
> +    magic, version = magicstring[0:2], magicstring[2:4]
>      if magic != 'HG':
>          raise util.Abort(_('not a Mercurial bundle'))
>      unbundlerclass = formatmap.get(version)
>      if unbundlerclass is None:
>          raise util.Abort(_('unknown bundle version %s') % version)
>      unbundler = unbundlerclass(ui, fp)
> -    indebug(ui, 'start processing of %s stream' % header)
> +    indebug(ui, 'start processing of %s stream' % magicstring)
>      return unbundler
>
>  class unbundle20(unpackermixin):
>      """interpret a bundle2 stream
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -34,11 +34,11 @@ def readbundle(ui, fh, fname, vfs=None):
>      if version == '10':
>          if alg is None:
>              alg = changegroup.readexactly(fh, 2)
>          return changegroup.cg1unpacker(fh, alg)
>      elif version.startswith('2'):
> -        return bundle2.getunbundler(ui, fh, header=magic + version)
> +        return bundle2.getunbundler(ui, fh, magicstring=magic + version)
>      else:
>          raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
>
>  def buildobsmarkerspart(bundler, markers):
>      """add an obsmarker part to the bundler with <markers>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -595,22 +595,22 @@  class unpackermixin(object):
     def close(self):
         """close underlying file"""
         if util.safehasattr(self._fp, 'close'):
             return self._fp.close()
 
-def getunbundler(ui, fp, header=None):
-    """return a valid unbundler object for a given header"""
-    if header is None:
-        header = changegroup.readexactly(fp, 4)
-    magic, version = header[0:2], header[2:4]
+def getunbundler(ui, fp, magicstring=None):
+    """return a valid unbundler object for a given magicstring"""
+    if magicstring is None:
+        magicstring = changegroup.readexactly(fp, 4)
+    magic, version = magicstring[0:2], magicstring[2:4]
     if magic != 'HG':
         raise util.Abort(_('not a Mercurial bundle'))
     unbundlerclass = formatmap.get(version)
     if unbundlerclass is None:
         raise util.Abort(_('unknown bundle version %s') % version)
     unbundler = unbundlerclass(ui, fp)
-    indebug(ui, 'start processing of %s stream' % header)
+    indebug(ui, 'start processing of %s stream' % magicstring)
     return unbundler
 
 class unbundle20(unpackermixin):
     """interpret a bundle2 stream
 
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -34,11 +34,11 @@  def readbundle(ui, fh, fname, vfs=None):
     if version == '10':
         if alg is None:
             alg = changegroup.readexactly(fh, 2)
         return changegroup.cg1unpacker(fh, alg)
     elif version.startswith('2'):
-        return bundle2.getunbundler(ui, fh, header=magic + version)
+        return bundle2.getunbundler(ui, fh, magicstring=magic + version)
     else:
         raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
 
 def buildobsmarkerspart(bundler, markers):
     """add an obsmarker part to the bundler with <markers>