mercurial/bundle2.py
changeset 50521 58adcabc295f
parent 50516 3c0da0fa0eed
child 50529 116da6bb7e3b
equal deleted inserted replaced
50520:a6543983b8f4 50521:58adcabc295f
  1669         if not streamsupported or not featuresupported:
  1669         if not streamsupported or not featuresupported:
  1670             caps.pop(b'stream')
  1670             caps.pop(b'stream')
  1671     # Else always advertise support on client, because payload support
  1671     # Else always advertise support on client, because payload support
  1672     # should always be advertised.
  1672     # should always be advertised.
  1673 
  1673 
       
  1674     if repo.ui.configbool(b'experimental', b'stream-v3'):
       
  1675         if b'stream' in caps:
       
  1676             caps[b'stream'] += (b'v3-exp',)
       
  1677 
  1674     # b'rev-branch-cache is no longer advertised, but still supported
  1678     # b'rev-branch-cache is no longer advertised, but still supported
  1675     # for legacy clients.
  1679     # for legacy clients.
  1676 
  1680 
  1677     return caps
  1681     return caps
  1678 
  1682 
  1890         msg = _(
  1894         msg = _(
  1891             b'stream data requested but supported streaming clone versions were not specified'
  1895             b'stream data requested but supported streaming clone versions were not specified'
  1892         )
  1896         )
  1893         hint = _(b'the client seems buggy')
  1897         hint = _(b'the client seems buggy')
  1894         raise error.Abort(msg, hint=hint)
  1898         raise error.Abort(msg, hint=hint)
  1895     if not (b'v2' in bundler.capabilities[b'stream']):
  1899     client_supported = set(bundler.capabilities[b'stream'])
  1896         raise error.Abort(_(b'the client does not support streamclone v2'))
  1900     server_supported = set(getrepocaps(repo, role=b'client').get(b'stream', []))
       
  1901     common_supported = client_supported & server_supported
       
  1902     if not common_supported:
       
  1903         msg = _(b'no common supported version with the client: %s; %s')
       
  1904         str_server = b','.join(sorted(server_supported))
       
  1905         str_client = b','.join(sorted(client_supported))
       
  1906         msg %= (str_server, str_client)
       
  1907         raise error.Abort(msg)
       
  1908     version = max(common_supported)
  1897 
  1909 
  1898     # Stream clones don't compress well. And compression undermines a
  1910     # Stream clones don't compress well. And compression undermines a
  1899     # goal of stream clones, which is to be fast. Communicate the desire
  1911     # goal of stream clones, which is to be fast. Communicate the desire
  1900     # to avoid compression to consumers of the bundle.
  1912     # to avoid compression to consumers of the bundle.
  1901     bundler.prefercompressed = False
  1913     bundler.prefercompressed = False
  1922                 )
  1934                 )
  1923             )
  1935             )
  1924         elif repo.obsstore._version in remoteversions:
  1936         elif repo.obsstore._version in remoteversions:
  1925             includeobsmarkers = True
  1937             includeobsmarkers = True
  1926 
  1938 
  1927     filecount, bytecount, it = streamclone.generatev2(
  1939     if version == b"v2":
  1928         repo, includepats, excludepats, includeobsmarkers
  1940         filecount, bytecount, it = streamclone.generatev2(
  1929     )
  1941             repo, includepats, excludepats, includeobsmarkers
  1930     requirements = streamclone.streamed_requirements(repo)
  1942         )
  1931     requirements = _formatrequirementsspec(requirements)
  1943         requirements = streamclone.streamed_requirements(repo)
  1932     part = bundler.newpart(b'stream2', data=it)
  1944         requirements = _formatrequirementsspec(requirements)
  1933     part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True)
  1945         part = bundler.newpart(b'stream2', data=it)
  1934     part.addparam(b'filecount', b'%d' % filecount, mandatory=True)
  1946         part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True)
  1935     part.addparam(b'requirements', requirements, mandatory=True)
  1947         part.addparam(b'filecount', b'%d' % filecount, mandatory=True)
       
  1948         part.addparam(b'requirements', requirements, mandatory=True)
       
  1949     elif version == b"v3-exp":
       
  1950         filecount, bytecount, it = streamclone.generatev2(
       
  1951             repo, includepats, excludepats, includeobsmarkers
       
  1952         )
       
  1953         requirements = streamclone.streamed_requirements(repo)
       
  1954         requirements = _formatrequirementsspec(requirements)
       
  1955         part = bundler.newpart(b'stream3', data=it)
       
  1956         part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True)
       
  1957         part.addparam(b'filecount', b'%d' % filecount, mandatory=True)
       
  1958         part.addparam(b'requirements', requirements, mandatory=True)
  1936 
  1959 
  1937 
  1960 
  1938 def buildobsmarkerspart(bundler, markers, mandatory=True):
  1961 def buildobsmarkerspart(bundler, markers, mandatory=True):
  1939     """add an obsmarker part to the bundler with <markers>
  1962     """add an obsmarker part to the bundler with <markers>
  1940 
  1963 
  2586 
  2609 
  2587     repo.ui.debug(b'applying stream bundle\n')
  2610     repo.ui.debug(b'applying stream bundle\n')
  2588     streamclone.applybundlev2(repo, part, filecount, bytecount, requirements)
  2611     streamclone.applybundlev2(repo, part, filecount, bytecount, requirements)
  2589 
  2612 
  2590 
  2613 
       
  2614 @parthandler(b'stream3', (b'requirements', b'filecount', b'bytecount'))
       
  2615 def handlestreamv3bundle(op, part):
       
  2616     return handlestreamv2bundle(op, part)
       
  2617 
       
  2618 
  2591 def widen_bundle(
  2619 def widen_bundle(
  2592     bundler, repo, oldmatcher, newmatcher, common, known, cgversion, ellipses
  2620     bundler, repo, oldmatcher, newmatcher, common, known, cgversion, ellipses
  2593 ):
  2621 ):
  2594     """generates bundle2 for widening a narrow clone
  2622     """generates bundle2 for widening a narrow clone
  2595 
  2623