Mercurial > hg
changeset 38895:d7ac49c2353c
changegroup: pass version into constructor
Currently, the version is an attribute on each class. Passing
the argument into the constructor gets us one step closer to
eliminating cg2packer and cg3packer.
Differential Revision: https://phab.mercurial-scm.org/D4077
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 02 Aug 2018 17:33:23 -0700 |
parents | 19344024a8e1 |
children | 271854adc3a6 |
files | mercurial/changegroup.py |
diffstat | 1 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changegroup.py Thu Aug 02 17:29:53 2018 -0700 +++ b/mercurial/changegroup.py Thu Aug 02 17:33:23 2018 -0700 @@ -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