bundle20: move magic string into the class
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 06 Apr 2015 15:40:12 -0700
changeset 24640 685639f9430d
parent 24639 c79b1e690110
child 24641 60fecc5b14a4
bundle20: move magic string into the class This makes it easy to create a new bundler class that inherits from the core one. This matches the way 'changegroup' packers work. The main target is to allow HG2Y support in an extension to ease transition of companies using the experimental protocol in production (yeah...) But I've no doubt this will be useful when playing with a future HG21.
mercurial/bundle2.py
--- a/mercurial/bundle2.py	Tue Apr 07 08:45:52 2015 -0700
+++ b/mercurial/bundle2.py	Mon Apr 06 15:40:12 2015 -0700
@@ -162,8 +162,6 @@
 _pack = struct.pack
 _unpack = struct.unpack
 
-_magicstring = 'HG2Y'
-
 _fstreamparamsize = '>i'
 _fpartheadersize = '>i'
 _fparttypesize = '>B'
@@ -410,6 +408,8 @@
     populate it. Then call `getchunks` to retrieve all the binary chunks of
     data that compose the bundle2 container."""
 
+    _magicstring = 'HG2Y'
+
     def __init__(self, ui, capabilities=()):
         self.ui = ui
         self._params = []
@@ -453,8 +453,8 @@
 
     # methods used to generate the bundle2 stream
     def getchunks(self):
-        self.ui.debug('start emission of %s stream\n' % _magicstring)
-        yield _magicstring
+        self.ui.debug('start emission of %s stream\n' % self._magicstring)
+        yield self._magicstring
         param = self._paramchunk()
         self.ui.debug('bundle parameter: %s\n' % param)
         yield _pack(_fstreamparamsize, len(param))