Mercurial > hg
comparison mercurial/bundle2.py @ 43131:c17a63eb5d4c
sidedata: apply basic but tight security around exchange
We don't currently have code to deal with exchange between repository using
sidedata and repository not using sidedata. Until we implement such code (eg:
dropping side data when pushing to a non-sidedata repo) we prevent the two kind
of repo to speak to each other. This is somewhere similar to what 'treemanifest'
does.
Note that sidedata exchange is broken unless one use changegroup v3 anyway. See
next changeset for details.
Differential Revision: https://phab.mercurial-scm.org/D6939
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 06 Oct 2019 23:36:51 -0400 |
parents | 8ff1ecfadcd1 |
children | be384a2052aa ea25b4673231 |
comparison
equal
deleted
inserted
replaced
43130:c88075eb28e3 | 43131:c17a63eb5d4c |
---|---|
1709 b'%ln and secret()', outgoing.missingheads | 1709 b'%ln and secret()', outgoing.missingheads |
1710 ): | 1710 ): |
1711 part.addparam( | 1711 part.addparam( |
1712 b'targetphase', b'%d' % phases.secret, mandatory=False | 1712 b'targetphase', b'%d' % phases.secret, mandatory=False |
1713 ) | 1713 ) |
1714 if b'exp-sidedata-flag' in repo.requirements: | |
1715 part.addparam(b'exp-sidedata', b'1') | |
1714 | 1716 |
1715 if opts.get(b'streamv2', False): | 1717 if opts.get(b'streamv2', False): |
1716 addpartbundlestream2(bundler, repo, stream=True) | 1718 addpartbundlestream2(bundler, repo, stream=True) |
1717 | 1719 |
1718 if opts.get(b'tagsfnodescache', True): | 1720 if opts.get(b'tagsfnodescache', True): |
1928 result = -1 + changedheads | 1930 result = -1 + changedheads |
1929 return result | 1931 return result |
1930 | 1932 |
1931 | 1933 |
1932 @parthandler( | 1934 @parthandler( |
1933 b'changegroup', (b'version', b'nbchanges', b'treemanifest', b'targetphase') | 1935 b'changegroup', |
1936 ( | |
1937 b'version', | |
1938 b'nbchanges', | |
1939 b'exp-sidedata', | |
1940 b'treemanifest', | |
1941 b'targetphase', | |
1942 ), | |
1934 ) | 1943 ) |
1935 def handlechangegroup(op, inpart): | 1944 def handlechangegroup(op, inpart): |
1936 """apply a changegroup part on the repo | 1945 """apply a changegroup part on the repo |
1937 | 1946 |
1938 This is a very early implementation that will massive rework before being | 1947 This is a very early implementation that will massive rework before being |
1963 op.repo.requirements.add(b'treemanifest') | 1972 op.repo.requirements.add(b'treemanifest') |
1964 op.repo.svfs.options = localrepo.resolvestorevfsoptions( | 1973 op.repo.svfs.options = localrepo.resolvestorevfsoptions( |
1965 op.repo.ui, op.repo.requirements, op.repo.features | 1974 op.repo.ui, op.repo.requirements, op.repo.features |
1966 ) | 1975 ) |
1967 op.repo._writerequirements() | 1976 op.repo._writerequirements() |
1977 | |
1978 bundlesidedata = bool(b'exp-sidedata' in inpart.params) | |
1979 reposidedata = bool(b'exp-sidedata-flag' in op.repo.requirements) | |
1980 if reposidedata and not bundlesidedata: | |
1981 msg = b"repository is using sidedata but the bundle source do not" | |
1982 hint = b'this is currently unsupported' | |
1983 raise error.Abort(msg, hint=hint) | |
1984 | |
1968 extrakwargs = {} | 1985 extrakwargs = {} |
1969 targetphase = inpart.params.get(b'targetphase') | 1986 targetphase = inpart.params.get(b'targetphase') |
1970 if targetphase is not None: | 1987 if targetphase is not None: |
1971 extrakwargs[r'targetphase'] = int(targetphase) | 1988 extrakwargs[r'targetphase'] = int(targetphase) |
1972 ret = _processchangegroup( | 1989 ret = _processchangegroup( |
2549 | 2566 |
2550 part = bundler.newpart(b'changegroup', data=cgdata) | 2567 part = bundler.newpart(b'changegroup', data=cgdata) |
2551 part.addparam(b'version', cgversion) | 2568 part.addparam(b'version', cgversion) |
2552 if b'treemanifest' in repo.requirements: | 2569 if b'treemanifest' in repo.requirements: |
2553 part.addparam(b'treemanifest', b'1') | 2570 part.addparam(b'treemanifest', b'1') |
2571 if b'exp-sidedata-flag' in repo.requirements: | |
2572 part.addparam(b'exp-sidedata', b'1') | |
2554 | 2573 |
2555 return bundler | 2574 return bundler |