indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers.
REVISION SUMMARY Currently, we have 3 classes for changegroup generation. Each class handles a specific changegroup format. And each subsequent version's class inherits from the previous one. The interface for the classes is not very well defined and a lot of version-specific behavior is behind overloaded functions. This approach adds complexity and makes changegroup generation difficult to reason about. Upcoming commits will be consolidating these 3 classes so differences between changegroup versions and changegroup generation are controlled by parameters to a single constructor / type rather than by overriding class attributes via inheritance. We begin this process by building dedicated functions for creating each changegroup packer instance. Currently they just call the constructor on the appropriate class. This will soon change. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4076 AFFECTED FILES mercurial/changegroup.py CHANGE DETAILS diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -1179,11 +1179,20 @@ return struct.pack( self.deltaheader, node, p1n, p2n, basenode, linknode, flags) -_packermap = {'01': (cg1packer, cg1unpacker), +def _makecg1packer(repo, filematcher, bundlecaps): + return cg1packer(repo, filematcher, bundlecaps=bundlecaps) + +def _makecg2packer(repo, filematcher, bundlecaps): + return cg2packer(repo, filematcher, bundlecaps=bundlecaps) + +def _makecg3packer(repo, filematcher, bundlecaps): + return cg3packer(repo, filematcher, bundlecaps=bundlecaps) + +_packermap = {'01': (_makecg1packer, cg1unpacker), # cg2 adds support for exchanging generaldelta - '02': (cg2packer, cg2unpacker), + '02': (_makecg2packer, cg2unpacker), # cg3 adds support for exchanging revlog flags and treemanifests - '03': (cg3packer, cg3unpacker), + '03': (_makecg3packer, cg3unpacker), } def allsupportedversions(repo): @@ -1252,8 +1261,8 @@ filematcher = matchmod.intersectmatchers(repo.narrowmatch(), filematcher) - return _packermap[version][0](repo, filematcher=filematcher, - bundlecaps=bundlecaps) + fn = _packermap[version][0] + return fn(repo, filematcher, bundlecaps) def getunbundler(version, fh, alg, extras=None): return _packermap[version][1](fh, alg, extras=extras) To: indygreg, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel