Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 46165:41d695a08e90
bundle: optional advisory obsolescence parts
It is useful to ship obsolescence markers as part of clonebundles or
pullbundles, but they shouldn't stop a non-evolution client from working.
Differential Revision: https://phab.mercurial-scm.org/D8480
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 24 Apr 2020 16:36:04 +0200 |
parents | 59fa3890d40a |
children | c511fef30290 |
comparison
equal
deleted
inserted
replaced
46164:a27aa754d6ba | 46165:41d695a08e90 |
---|---|
1737 if opts.get(b'revbranchcache', True): | 1737 if opts.get(b'revbranchcache', True): |
1738 addpartrevbranchcache(repo, bundler, outgoing) | 1738 addpartrevbranchcache(repo, bundler, outgoing) |
1739 | 1739 |
1740 if opts.get(b'obsolescence', False): | 1740 if opts.get(b'obsolescence', False): |
1741 obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing) | 1741 obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing) |
1742 buildobsmarkerspart(bundler, obsmarkers) | 1742 buildobsmarkerspart( |
1743 bundler, | |
1744 obsmarkers, | |
1745 mandatory=opts.get(b'obsolescence-mandatory', True), | |
1746 ) | |
1743 | 1747 |
1744 if opts.get(b'phases', False): | 1748 if opts.get(b'phases', False): |
1745 headsbyphase = phases.subsetphaseheads(repo, outgoing.missing) | 1749 headsbyphase = phases.subsetphaseheads(repo, outgoing.missing) |
1746 phasedata = phases.binaryencode(headsbyphase) | 1750 phasedata = phases.binaryencode(headsbyphase) |
1747 bundler.newpart(b'phase-heads', data=phasedata) | 1751 bundler.newpart(b'phase-heads', data=phasedata) |
1860 part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True) | 1864 part.addparam(b'bytecount', b'%d' % bytecount, mandatory=True) |
1861 part.addparam(b'filecount', b'%d' % filecount, mandatory=True) | 1865 part.addparam(b'filecount', b'%d' % filecount, mandatory=True) |
1862 part.addparam(b'requirements', requirements, mandatory=True) | 1866 part.addparam(b'requirements', requirements, mandatory=True) |
1863 | 1867 |
1864 | 1868 |
1865 def buildobsmarkerspart(bundler, markers): | 1869 def buildobsmarkerspart(bundler, markers, mandatory=True): |
1866 """add an obsmarker part to the bundler with <markers> | 1870 """add an obsmarker part to the bundler with <markers> |
1867 | 1871 |
1868 No part is created if markers is empty. | 1872 No part is created if markers is empty. |
1869 Raises ValueError if the bundler doesn't support any known obsmarker format. | 1873 Raises ValueError if the bundler doesn't support any known obsmarker format. |
1870 """ | 1874 """ |
1874 remoteversions = obsmarkersversion(bundler.capabilities) | 1878 remoteversions = obsmarkersversion(bundler.capabilities) |
1875 version = obsolete.commonversion(remoteversions) | 1879 version = obsolete.commonversion(remoteversions) |
1876 if version is None: | 1880 if version is None: |
1877 raise ValueError(b'bundler does not support common obsmarker format') | 1881 raise ValueError(b'bundler does not support common obsmarker format') |
1878 stream = obsolete.encodemarkers(markers, True, version=version) | 1882 stream = obsolete.encodemarkers(markers, True, version=version) |
1879 return bundler.newpart(b'obsmarkers', data=stream) | 1883 return bundler.newpart(b'obsmarkers', data=stream, mandatory=mandatory) |
1880 | 1884 |
1881 | 1885 |
1882 def writebundle( | 1886 def writebundle( |
1883 ui, cg, filename, bundletype, vfs=None, compression=None, compopts=None | 1887 ui, cg, filename, bundletype, vfs=None, compression=None, compopts=None |
1884 ): | 1888 ): |