Mercurial > hg
comparison mercurial/bundle2.py @ 50399:bcf54837241d
bundle: prevent implicite bundling of internal changeset
Now that the two mains source of on-disk bundle are preventing the inclusion of
internal changesets in their bundling. We can add a lower level check that
would prevent any other leakage of internal-phase changesets.
We keep the door open to some usage, like the temporary bundle using during
strip for example.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 08 Mar 2023 11:01:11 +0100 |
parents | 385a4f8056e5 |
children | cd2a2963b982 |
comparison
equal
deleted
inserted
replaced
50398:cc712ce3361f | 50399:bcf54837241d |
---|---|
1701 outgoing, | 1701 outgoing, |
1702 opts, | 1702 opts, |
1703 vfs=None, | 1703 vfs=None, |
1704 compression=None, | 1704 compression=None, |
1705 compopts=None, | 1705 compopts=None, |
1706 allow_internal=False, | |
1706 ): | 1707 ): |
1707 if bundletype.startswith(b'HG10'): | 1708 if bundletype.startswith(b'HG10'): |
1708 cg = changegroup.makechangegroup(repo, outgoing, b'01', source) | 1709 cg = changegroup.makechangegroup(repo, outgoing, b'01', source) |
1709 return writebundle( | 1710 return writebundle( |
1710 ui, | 1711 ui, |
1715 compression=compression, | 1716 compression=compression, |
1716 compopts=compopts, | 1717 compopts=compopts, |
1717 ) | 1718 ) |
1718 elif not bundletype.startswith(b'HG20'): | 1719 elif not bundletype.startswith(b'HG20'): |
1719 raise error.ProgrammingError(b'unknown bundle type: %s' % bundletype) | 1720 raise error.ProgrammingError(b'unknown bundle type: %s' % bundletype) |
1721 | |
1722 # enforce that no internal phase are to be bundled | |
1723 bundled_internal = repo.revs(b"%ln and _internal()", outgoing.ancestorsof) | |
1724 if bundled_internal and not allow_internal: | |
1725 count = len(repo.revs(b'%ln and _internal()', outgoing.missing)) | |
1726 msg = "backup bundle would contains %d internal changesets" | |
1727 msg %= count | |
1728 raise error.ProgrammingError(msg) | |
1720 | 1729 |
1721 caps = {} | 1730 caps = {} |
1722 if opts.get(b'obsolescence', False): | 1731 if opts.get(b'obsolescence', False): |
1723 caps[b'obsmarkers'] = (b'V1',) | 1732 caps[b'obsmarkers'] = (b'V1',) |
1724 bundle = bundle20(ui, caps) | 1733 bundle = bundle20(ui, caps) |