Mercurial > hg-stable
changeset 39962:ad9ca365738b
narrow: factor out logic to create cg while widening into separate fn
This patch takes out the logic which generates a changegroup for widening a
narrow clone when ellipses are disabled. This is done because future patches
will introduce a narrow_widen() wireprotocol command which will send a
bundle2 with changegroup and will use this function.
The new function for now returns just the changegroup for compatibility with
existing code, but in future patches, when we establish a wireprotocol command
and call this function from there, this will return the required bundle2.
Differential Revision: https://phab.mercurial-scm.org/D4786
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Fri, 28 Sep 2018 19:18:17 +0300 |
parents | 1a7d901a0a0c |
children | fa2395659828 |
files | hgext/narrow/narrowbundle2.py |
diffstat | 1 files changed, 38 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/narrow/narrowbundle2.py Mon Oct 01 15:29:31 2018 -0700 +++ b/hgext/narrow/narrowbundle2.py Fri Sep 28 19:18:17 2018 +0300 @@ -51,6 +51,41 @@ caps[NARROWCAP] = ['v0'] return caps +def widen_bundle(repo, diffmatcher, common, known, cgversion, source, ellipses): + """generates changegroup for widening a narrow clone + + repo is the localrepository instance + diffmatcher is a differencemacther of '(newincludes, newexcludes) - + (oldincludes, oldexcludes)' + common is set of common revs between server and client + known is a set of revs known on the client side (used in ellipses) + cgversion is the changegroup version to send + source is the command which called this codepath + ellipses is boolean value telling whether to send ellipses data or not + + returns changegroup data of the changegroup built or return None if there + are no common revs + """ + # XXX: This patch will start sending bundle2 after couple of patches when + # called from the wireprotocol command + common = repo.revs("::%ln", common) + commonnodes = set() + cl = repo.changelog + for c in common: + commonnodes.add(cl.node(c)) + if commonnodes: + # XXX: we should only send the filelogs (and treemanifest). user + # already has the changelog and manifest + packer = changegroup.getbundler(cgversion, repo, + filematcher=diffmatcher, + fullnodes=commonnodes) + cgdata = packer.generate(set([nullid]), list(commonnodes), False, + source, changelog=False) + + return cgdata + + return None + def getbundlechangegrouppart_widen(bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, common=None, **kwargs): @@ -79,20 +114,9 @@ common = set(common or [nullid]) if (oldinclude != include or oldexclude != exclude): - common = repo.revs("::%ln", common) - commonnodes = set() - cl = repo.changelog - for c in common: - commonnodes.add(cl.node(c)) - if commonnodes: - # XXX: we should only send the filelogs (and treemanifest). user - # already has the changelog and manifest - packer = changegroup.getbundler(version, repo, - filematcher=diffmatch, - fullnodes=commonnodes) - cgdata = packer.generate(set([nullid]), list(commonnodes), False, - source, changelog=False) - + cgdata = widen_bundle(repo, diffmatch, common, [], version, + source, False) + if cgdata is not None: part = bundler.newpart('changegroup', data=cgdata) part.addparam('version', version) if 'treemanifest' in repo.requirements: