Show More
@@ -1490,11 +1490,18 b" capabilities = {'HG20': ()," | |||||
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))) |
@@ -543,7 +543,7 b' def getremotechanges(ui, repo, other, on' | |||||
543 | kwargs = {} |
|
543 | kwargs = {} | |
544 | kwargs[r'common'] = common |
|
544 | kwargs[r'common'] = common | |
545 | kwargs[r'heads'] = rheads |
|
545 | kwargs[r'heads'] = rheads | |
546 | kwargs[r'bundlecaps'] = exchange.caps20to10(repo) |
|
546 | kwargs[r'bundlecaps'] = exchange.caps20to10(repo, role='client') | |
547 | kwargs[r'cg'] = True |
|
547 | kwargs[r'cg'] = True | |
548 | b2 = other.getbundle('incoming', **kwargs) |
|
548 | b2 = other.getbundle('incoming', **kwargs) | |
549 | fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), |
|
549 | fname = bundle = changegroup.writechunks(ui, b2._forwardchunks(), |
@@ -1015,7 +1015,8 b' def _pushbundle2(pushop):' | |||||
1015 |
|
1015 | |||
1016 | # create reply capability |
|
1016 | # create reply capability | |
1017 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, |
|
1017 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo, | |
1018 |
allowpushback=pushback |
|
1018 | allowpushback=pushback, | |
|
1019 | role='client')) | |||
1019 | bundler.newpart('replycaps', data=capsblob) |
|
1020 | bundler.newpart('replycaps', data=capsblob) | |
1020 | replyhandlers = [] |
|
1021 | replyhandlers = [] | |
1021 | for partgenname in b2partsgenorder: |
|
1022 | for partgenname in b2partsgenorder: | |
@@ -1448,7 +1449,7 b' def _pullbundle2(pullop):' | |||||
1448 | """pull data using bundle2 |
|
1449 | """pull data using bundle2 | |
1449 |
|
1450 | |||
1450 | For now, the only supported data are changegroup.""" |
|
1451 | For now, the only supported data are changegroup.""" | |
1451 | kwargs = {'bundlecaps': caps20to10(pullop.repo)} |
|
1452 | kwargs = {'bundlecaps': caps20to10(pullop.repo, role='client')} | |
1452 |
|
1453 | |||
1453 | # make ui easier to access |
|
1454 | # make ui easier to access | |
1454 | ui = pullop.repo.ui |
|
1455 | ui = pullop.repo.ui | |
@@ -1680,10 +1681,10 b' def _pullobsolete(pullop):' | |||||
1680 | pullop.repo.invalidatevolatilesets() |
|
1681 | pullop.repo.invalidatevolatilesets() | |
1681 | return tr |
|
1682 | return tr | |
1682 |
|
1683 | |||
1683 | def caps20to10(repo): |
|
1684 | def caps20to10(repo, role): | |
1684 | """return a set with appropriate options to use bundle20 during getbundle""" |
|
1685 | """return a set with appropriate options to use bundle20 during getbundle""" | |
1685 | caps = {'HG20'} |
|
1686 | caps = {'HG20'} | |
1686 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
|
1687 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, role=role)) | |
1687 | caps.add('bundle2=' + urlreq.quote(capsblob)) |
|
1688 | caps.add('bundle2=' + urlreq.quote(capsblob)) | |
1688 | return caps |
|
1689 | return caps | |
1689 |
|
1690 |
@@ -577,7 +577,8 b' class localrepository(object):' | |||||
577 | def _restrictcapabilities(self, caps): |
|
577 | def _restrictcapabilities(self, caps): | |
578 | if self.ui.configbool('experimental', 'bundle2-advertise'): |
|
578 | if self.ui.configbool('experimental', 'bundle2-advertise'): | |
579 | caps = set(caps) |
|
579 | caps = set(caps) | |
580 |
capsblob = bundle2.encodecaps(bundle2.getrepocaps(self |
|
580 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(self, | |
|
581 | role='client')) | |||
581 | caps.add('bundle2=' + urlreq.quote(capsblob)) |
|
582 | caps.add('bundle2=' + urlreq.quote(capsblob)) | |
582 | return caps |
|
583 | return caps | |
583 |
|
584 |
@@ -780,7 +780,7 b' def _capabilities(repo, proto):' | |||||
780 | else: |
|
780 | else: | |
781 | caps.append('streamreqs=%s' % ','.join(sorted(requiredformats))) |
|
781 | caps.append('streamreqs=%s' % ','.join(sorted(requiredformats))) | |
782 | if repo.ui.configbool('experimental', 'bundle2-advertise'): |
|
782 | if repo.ui.configbool('experimental', 'bundle2-advertise'): | |
783 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) |
|
783 | capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo, role='server')) | |
784 | caps.append('bundle2=' + urlreq.quote(capsblob)) |
|
784 | caps.append('bundle2=' + urlreq.quote(capsblob)) | |
785 | caps.append('unbundle=%s' % ','.join(bundle2.bundlepriority)) |
|
785 | caps.append('unbundle=%s' % ','.join(bundle2.bundlepriority)) | |
786 |
|
786 |
General Comments 0
You need to be logged in to leave comments.
Login now