[PATCH] bundle2.getunbundler: rename "header" to "magicstring"

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Jun 20 18:15:19 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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>


More information about the Mercurial-devel mailing list