Patchwork D4077: changegroup: pass version into constructor

login
register
mail settings
Submitter phabricator
Date Aug. 6, 2018, 6:56 a.m.
Message ID <b95857489c550c40ecd31f156aac9b99@localhost.localdomain>
Download mbox | patch
Permalink /patch/33297/
State Not Applicable
Headers show

Comments

phabricator - Aug. 6, 2018, 6:56 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd7ac49c2353c: changegroup: pass version into constructor (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4077?vs=9839&id=9953

REVISION DETAIL
  https://phab.mercurial-scm.org/D4077

AFFECTED FILES
  mercurial/changegroup.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -521,8 +521,8 @@ 
 
 class cg1packer(object):
     deltaheader = _CHANGEGROUPV1_DELTA_HEADER
-    version = '01'
-    def __init__(self, repo, filematcher, bundlecaps=None):
+
+    def __init__(self, repo, filematcher, version, bundlecaps=None):
         """Given a source repo, construct a bundler.
 
         filematcher is a matcher that matches on files to include in the
@@ -536,6 +536,8 @@ 
         assert filematcher
         self._filematcher = filematcher
 
+        self.version = version
+
         # Set of capabilities we can use to build the bundle.
         if bundlecaps is None:
             bundlecaps = set()
@@ -1100,11 +1102,10 @@ 
         return struct.pack(self.deltaheader, node, p1n, p2n, linknode)
 
 class cg2packer(cg1packer):
-    version = '02'
     deltaheader = _CHANGEGROUPV2_DELTA_HEADER
 
-    def __init__(self, repo, filematcher, bundlecaps=None):
-        super(cg2packer, self).__init__(repo, filematcher,
+    def __init__(self, repo, filematcher, version, bundlecaps=None):
+        super(cg2packer, self).__init__(repo, filematcher, version,
                                         bundlecaps=bundlecaps)
 
         if self._reorder is None:
@@ -1157,7 +1158,6 @@ 
         return struct.pack(self.deltaheader, node, p1n, p2n, basenode, linknode)
 
 class cg3packer(cg2packer):
-    version = '03'
     deltaheader = _CHANGEGROUPV3_DELTA_HEADER
 
     def _packmanifests(self, dir, mfnodes, lookuplinknode):
@@ -1177,13 +1177,13 @@ 
             self.deltaheader, node, p1n, p2n, basenode, linknode, flags)
 
 def _makecg1packer(repo, filematcher, bundlecaps):
-    return cg1packer(repo, filematcher, bundlecaps=bundlecaps)
+    return cg1packer(repo, filematcher, b'01', bundlecaps=bundlecaps)
 
 def _makecg2packer(repo, filematcher, bundlecaps):
-    return cg2packer(repo, filematcher, bundlecaps=bundlecaps)
+    return cg2packer(repo, filematcher, b'02', bundlecaps=bundlecaps)
 
 def _makecg3packer(repo, filematcher, bundlecaps):
-    return cg3packer(repo, filematcher, bundlecaps=bundlecaps)
+    return cg3packer(repo, filematcher, b'03', bundlecaps=bundlecaps)
 
 _packermap = {'01': (_makecg1packer, cg1unpacker),
              # cg2 adds support for exchanging generaldelta