D4086: changegroup: declare shallow flag in constructor
This revision was automatically updated to reflect the committed changes. Closed by commit rHGcdb9bc216771: changegroup: declare shallow flag in constructor (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D4086?vs=9848=9962 REVISION DETAIL https://phab.mercurial-scm.org/D4086 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 @@ -522,7 +522,7 @@ class cgpacker(object): def __init__(self, repo, filematcher, version, allowreorder, useprevdelta, builddeltaheader, manifestsend, - sendtreemanifests, bundlecaps=None): + sendtreemanifests, bundlecaps=None, shallow=False): """Given a source repo, construct a bundler. filematcher is a matcher that matches on files to include in the @@ -546,6 +546,9 @@ capabilities which can be used to build the bundle. While bundlecaps is unused in core Mercurial, extensions rely on this feature to communicate capabilities to customize the changegroup packer. + +shallow indicates whether shallow data might be sent. The packer may +need to pack file contents not introduced by the changes being packed. """ assert filematcher self._filematcher = filematcher @@ -560,6 +563,7 @@ if bundlecaps is None: bundlecaps = set() self._bundlecaps = bundlecaps +self._isshallow = shallow # experimental config: bundle.reorder reorder = repo.ui.config('bundle', 'reorder') @@ -736,7 +740,7 @@ mfrevlog.rev(n)) # We can't trust the changed files list in the changeset if the # client requested a shallow clone. -if self._is_shallow: +if self._isshallow: changedfiles.update(mfl[c[0]].read().keys()) else: changedfiles.update(c[3]) @@ -786,7 +790,7 @@ if ellipsesmode: mfdicts = None -if self._is_shallow: +if self._isshallow: mfdicts = [(self._repo.manifestlog[n].read(), lr) for (n, lr) in mfs.iteritems()] @@ -892,7 +896,7 @@ def generatefiles(self, changedfiles, linknodes, commonrevs, source): changedfiles = list(filter(self._filematcher, changedfiles)) -if getattr(self, '_is_shallow', False): +if self._isshallow: # See comment in generate() for why this sadness is a thing. mfdicts = self._mfdicts del self._mfdicts @@ -1171,7 +1175,7 @@ deltachunks=(diffheader, data), ) -def _makecg1packer(repo, filematcher, bundlecaps): +def _makecg1packer(repo, filematcher, bundlecaps, shallow=False): builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.linknode) @@ -1181,9 +1185,10 @@ builddeltaheader=builddeltaheader, manifestsend=b'', sendtreemanifests=False, -bundlecaps=bundlecaps) +bundlecaps=bundlecaps, +shallow=shallow) -def _makecg2packer(repo, filematcher, bundlecaps): +def _makecg2packer(repo, filematcher, bundlecaps, shallow=False): builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.basenode, d.linknode) @@ -1196,9 +1201,10 @@ builddeltaheader=builddeltaheader, manifestsend=b'', sendtreemanifests=False, -bundlecaps=bundlecaps) +bundlecaps=bundlecaps, +shallow=shallow) -def _makecg3packer(repo, filematcher, bundlecaps): +def _makecg3packer(repo, filematcher, bundlecaps, shallow=False): builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags) @@ -1208,7 +1214,8 @@ builddeltaheader=builddeltaheader, manifestsend=closechunk(), sendtreemanifests=True, -bundlecaps=bundlecaps) +bundlecaps=bundlecaps, +shallow=shallow) _packermap = {'01': (_makecg1packer, cg1unpacker), # cg2 adds support for exchanging generaldelta @@ -1268,7 +1275,8 @@ assert versions return min(versions) -def getbundler(version, repo, bundlecaps=None, filematcher=None): +def getbundler(version, repo, bundlecaps=None, filematcher=None, + shallow=False): assert version in supportedoutgoingversions(repo) if filematcher is None: @@ -1284,7 +1292,7 @@
D4086: changegroup: declare shallow flag in constructor
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Thus begins the process of better formalizing ellipses and shallow changegroup generation mode so it is tracked by cgpacker at construction time instead of bolted on after the fact by a wrapper function. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D4086 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 @@ -525,7 +525,7 @@ class cgpacker(object): def __init__(self, repo, filematcher, version, allowreorder, useprevdelta, builddeltaheader, manifestsend, - sendtreemanifests, bundlecaps=None): + sendtreemanifests, bundlecaps=None, shallow=False): """Given a source repo, construct a bundler. filematcher is a matcher that matches on files to include in the @@ -549,6 +549,9 @@ capabilities which can be used to build the bundle. While bundlecaps is unused in core Mercurial, extensions rely on this feature to communicate capabilities to customize the changegroup packer. + +shallow indicates whether shallow data might be sent. The packer may +need to pack file contents not introduced by the changes being packed. """ assert filematcher self._filematcher = filematcher @@ -563,6 +566,7 @@ if bundlecaps is None: bundlecaps = set() self._bundlecaps = bundlecaps +self._isshallow = shallow # experimental config: bundle.reorder reorder = repo.ui.config('bundle', 'reorder') @@ -739,7 +743,7 @@ mfrevlog.rev(n)) # We can't trust the changed files list in the changeset if the # client requested a shallow clone. -if self._is_shallow: +if self._isshallow: changedfiles.update(mfl[c[0]].read().keys()) else: changedfiles.update(c[3]) @@ -789,7 +793,7 @@ if ellipsesmode: mfdicts = None -if self._is_shallow: +if self._isshallow: mfdicts = [(self._repo.manifestlog[n].read(), lr) for (n, lr) in mfs.iteritems()] @@ -895,7 +899,7 @@ def generatefiles(self, changedfiles, linknodes, commonrevs, source): changedfiles = list(filter(self._filematcher, changedfiles)) -if getattr(self, '_is_shallow', False): +if self._isshallow: # See comment in generate() for why this sadness is a thing. mfdicts = self._mfdicts del self._mfdicts @@ -1174,7 +1178,7 @@ deltachunks=(diffheader, data), ) -def _makecg1packer(repo, filematcher, bundlecaps): +def _makecg1packer(repo, filematcher, bundlecaps, shallow=False): builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.linknode) @@ -1184,9 +1188,10 @@ builddeltaheader=builddeltaheader, manifestsend=b'', sendtreemanifests=False, -bundlecaps=bundlecaps) +bundlecaps=bundlecaps, +shallow=shallow) -def _makecg2packer(repo, filematcher, bundlecaps): +def _makecg2packer(repo, filematcher, bundlecaps, shallow=False): builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.basenode, d.linknode) @@ -1199,9 +1204,10 @@ builddeltaheader=builddeltaheader, manifestsend=b'', sendtreemanifests=False, -bundlecaps=bundlecaps) +bundlecaps=bundlecaps, +shallow=shallow) -def _makecg3packer(repo, filematcher, bundlecaps): +def _makecg3packer(repo, filematcher, bundlecaps, shallow=False): builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags) @@ -1211,7 +1217,8 @@ builddeltaheader=builddeltaheader, manifestsend=closechunk(), sendtreemanifests=True, -bundlecaps=bundlecaps) +bundlecaps=bundlecaps, +shallow=shallow) _packermap = {'01': (_makecg1packer, cg1unpacker), # cg2 adds support for exchanging generaldelta @@ -1271,7 +1278,8 @@ assert versions return min(versions) -def getbundler(version, repo, bundlecaps=None, filematcher=None): +def getbundler(version, repo, bundlecaps=None, filematcher=None, + shallow=False): assert version in