Mercurial > public > mercurial-scm > hg
comparison mercurial/bundle2.py @ 35783:c97639ad6874
bundle2: specify what capabilities will be used for
We currently assume there is a symmetric relationship of bundle2
capabilities between client and server. However, this may not always be
the case.
We need a bundle2 capability to advertise bundle2 streaming clone support
on servers to differentiate it from the existing, legacy streaming clone
support.
However, servers may wish to disable streaming clone support. If bundle2
capabilities were the same between client and server, a client (which
may also be a server) that has disabled streaming clone support would
not be able to perform a streaming clone itself!
This commit introduces a "role" argument to bundle2.getrepocaps() that
explicitly defines the role being performed. This will allow us (and
extensions) to alter bundle2 capabilities depending on the operation
being performed.
Differential Revision: https://phab.mercurial-scm.org/D1923
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 20 Jan 2018 13:54:36 -0800 |
parents | 7eedbd5d4880 |
children | a84dbc87dae9 |
comparison
equal
deleted
inserted
replaced
35782:9d249f3de730 | 35783:c97639ad6874 |
---|---|
1488 'hgtagsfnodes': (), | 1488 'hgtagsfnodes': (), |
1489 'phases': ('heads',), | 1489 'phases': ('heads',), |
1490 'stream': ('v2',), | 1490 'stream': ('v2',), |
1491 } | 1491 } |
1492 | 1492 |
1493 def getrepocaps(repo, allowpushback=False): | 1493 def getrepocaps(repo, allowpushback=False, role=None): |
1494 """return the bundle2 capabilities for a given repo | 1494 """return the bundle2 capabilities for a given repo |
1495 | 1495 |
1496 Exists to allow extensions (like evolution) to mutate the capabilities. | 1496 Exists to allow extensions (like evolution) to mutate the capabilities. |
1497 | |
1498 The returned value is used for servers advertising their capabilities as | |
1499 well as clients advertising their capabilities to servers as part of | |
1500 bundle2 requests. The ``role`` argument specifies which is which. | |
1497 """ | 1501 """ |
1502 if role not in ('client', 'server'): | |
1503 raise error.ProgrammingError('role argument must be client or server') | |
1504 | |
1498 caps = capabilities.copy() | 1505 caps = capabilities.copy() |
1499 caps['changegroup'] = tuple(sorted( | 1506 caps['changegroup'] = tuple(sorted( |
1500 changegroup.supportedincomingversions(repo))) | 1507 changegroup.supportedincomingversions(repo))) |
1501 if obsolete.isenabled(repo, obsolete.exchangeopt): | 1508 if obsolete.isenabled(repo, obsolete.exchangeopt): |
1502 supportedformat = tuple('V%i' % v for v in obsolete.formats) | 1509 supportedformat = tuple('V%i' % v for v in obsolete.formats) |