diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py --- a/hgext/narrow/narrowwirepeer.py +++ b/hgext/narrow/narrowwirepeer.py @@ -93,7 +93,7 @@ exclude=oldexcludes) diffmatch = matchmod.differencematcher(newmatch, oldmatch) - bundler = bundle2.widen_bundle(repo, diffmatch, common, known, + bundler = bundle2.widen_bundle(repo, diffmatch, oldmatch, common, known, cgversion, ellipses) except error.Abort as exc: bundler = bundle2.bundle20(repo.ui) diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -2267,7 +2267,8 @@ streamclone.applybundlev2(repo, part, filecount, bytecount, requirements) -def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses): +def widen_bundle(repo, oldmatcher, newmatcher, common, known, cgversion, + ellipses): """generates bundle2 for widening a narrow clone repo is the localrepository instance @@ -2289,7 +2290,8 @@ # XXX: we should only send the filelogs (and treemanifest). user # already has the changelog and manifest packer = changegroup.getbundler(cgversion, repo, - filematcher=diffmatcher, + filematcher=newmatcher, + oldfilematcher=oldmatcher, fullnodes=commonnodes) cgdata = packer.generate(set([nodemod.nullid]), list(commonnodes), False, 'narrow_widen', changelog=False) diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -727,7 +727,7 @@ progress.complete() class cgpacker(object): - def __init__(self, repo, filematcher, version, + def __init__(self, repo, filematcher, oldfilematcher, version, builddeltaheader, manifestsend, forcedeltaparentprev=False, bundlecaps=None, ellipses=False, @@ -762,7 +762,9 @@ significantly smaller. """ assert filematcher + assert oldfilematcher self._filematcher = filematcher + self._oldfilematcher = oldfilematcher self.version = version self._forcedeltaparentprev = forcedeltaparentprev @@ -1051,7 +1053,8 @@ fullclnodes=self._fullclnodes, precomputedellipsis=self._precomputedellipsis) - yield tree, deltas + if not tree or not self._oldfilematcher.visitdir(store.tree[:-1] or '.'): + yield tree, deltas def _prunemanifests(self, store, nodes, commonrevs): # This is split out as a separate method to allow filtering @@ -1151,12 +1154,13 @@ progress.complete() -def _makecg1packer(repo, filematcher, bundlecaps, ellipses=False, - shallow=False, ellipsisroots=None, fullnodes=None): +def _makecg1packer(repo, filematcher, oldfilematcher, bundlecaps, + ellipses=False, shallow=False, ellipsisroots=None, + fullnodes=None): builddeltaheader = lambda d: _CHANGEGROUPV1_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.linknode) - return cgpacker(repo, filematcher, b'01', + return cgpacker(repo, filematcher, oldfilematcher, b'01', builddeltaheader=builddeltaheader, manifestsend=b'', forcedeltaparentprev=True, @@ -1166,12 +1170,13 @@ ellipsisroots=ellipsisroots, fullnodes=fullnodes) -def _makecg2packer(repo, filematcher, bundlecaps, ellipses=False, - shallow=False, ellipsisroots=None, fullnodes=None): +def _makecg2packer(repo, filematcher, oldfilematcher, bundlecaps, + ellipses=False, shallow=False, ellipsisroots=None, + fullnodes=None): builddeltaheader = lambda d: _CHANGEGROUPV2_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.basenode, d.linknode) - return cgpacker(repo, filematcher, b'02', + return cgpacker(repo, filematcher, oldfilematcher, b'02', builddeltaheader=builddeltaheader, manifestsend=b'', bundlecaps=bundlecaps, @@ -1180,12 +1185,13 @@ ellipsisroots=ellipsisroots, fullnodes=fullnodes) -def _makecg3packer(repo, filematcher, bundlecaps, ellipses=False, - shallow=False, ellipsisroots=None, fullnodes=None): +def _makecg3packer(repo, filematcher, oldfilematcher, bundlecaps, + ellipses=False, shallow=False, ellipsisroots=None, + fullnodes=None): builddeltaheader = lambda d: _CHANGEGROUPV3_DELTA_HEADER.pack( d.node, d.p1node, d.p2node, d.basenode, d.linknode, d.flags) - return cgpacker(repo, filematcher, b'03', + return cgpacker(repo, filematcher, oldfilematcher, b'03', builddeltaheader=builddeltaheader, manifestsend=closechunk(), bundlecaps=bundlecaps, @@ -1253,12 +1259,14 @@ return min(versions) def getbundler(version, repo, bundlecaps=None, filematcher=None, - ellipses=False, shallow=False, ellipsisroots=None, - fullnodes=None): + oldfilematcher=None, ellipses=False, shallow=False, + ellipsisroots=None, fullnodes=None): assert version in supportedoutgoingversions(repo) if filematcher is None: filematcher = matchmod.alwaysmatcher(repo.root, '') + if oldfilematcher is None: + oldfilematcher = matchmod.nevermatcher(repo.root, '') if version == '01' and not filematcher.always(): raise error.ProgrammingError('version 01 changegroups do not support ' @@ -1275,7 +1283,7 @@ filematcher) fn = _packermap[version][0] - return fn(repo, filematcher, bundlecaps, ellipses=ellipses, + return fn(repo, filematcher, oldfilematcher, bundlecaps, ellipses=ellipses, shallow=shallow, ellipsisroots=ellipsisroots, fullnodes=fullnodes)