comparison mercurial/exchange.py @ 37757:2a8ad00b8aed

exchange: use command executor interface for calling listkeys So the requests are compatible with version 2 peers. Differential Revision: https://phab.mercurial-scm.org/D3390
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 14 Apr 2018 18:36:00 -0700
parents fc114a16a484
children 5527aa808dea
comparison
equal deleted inserted replaced
37756:e7bf5a73e4e1 37757:2a8ad00b8aed
589 """discover the phase that needs to be pushed 589 """discover the phase that needs to be pushed
590 590
591 (computed for both success and failure case for changesets push)""" 591 (computed for both success and failure case for changesets push)"""
592 outgoing = pushop.outgoing 592 outgoing = pushop.outgoing
593 unfi = pushop.repo.unfiltered() 593 unfi = pushop.repo.unfiltered()
594 remotephases = pushop.remote.listkeys('phases') 594 remotephases = listkeys(pushop.remote, 'phases')
595
595 if (pushop.ui.configbool('ui', '_usedassubrepo') 596 if (pushop.ui.configbool('ui', '_usedassubrepo')
596 and remotephases # server supports phases 597 and remotephases # server supports phases
597 and not pushop.outgoing.missing # no changesets to be pushed 598 and not pushop.outgoing.missing # no changesets to be pushed
598 and remotephases.get('publishing', False)): 599 and remotephases.get('publishing', False)):
599 # When: 600 # When:
636 pushop.outdatedphases = future 637 pushop.outdatedphases = future
637 pushop.fallbackoutdatedphases = fallback 638 pushop.fallbackoutdatedphases = fallback
638 639
639 @pushdiscovery('obsmarker') 640 @pushdiscovery('obsmarker')
640 def _pushdiscoveryobsmarkers(pushop): 641 def _pushdiscoveryobsmarkers(pushop):
641 if (obsolete.isenabled(pushop.repo, obsolete.exchangeopt) 642 if not obsolete.isenabled(pushop.repo, obsolete.exchangeopt):
642 and pushop.repo.obsstore 643 return
643 and 'obsolete' in pushop.remote.listkeys('namespaces')): 644
644 repo = pushop.repo 645 if not pushop.repo.obsstore:
645 # very naive computation, that can be quite expensive on big repo. 646 return
646 # However: evolution is currently slow on them anyway. 647
647 nodes = (c.node() for c in repo.set('::%ln', pushop.futureheads)) 648 if 'obsolete' not in listkeys(pushop.remote, 'namespaces'):
648 pushop.outobsmarkers = pushop.repo.obsstore.relevantmarkers(nodes) 649 return
650
651 repo = pushop.repo
652 # very naive computation, that can be quite expensive on big repo.
653 # However: evolution is currently slow on them anyway.
654 nodes = (c.node() for c in repo.set('::%ln', pushop.futureheads))
655 pushop.outobsmarkers = pushop.repo.obsstore.relevantmarkers(nodes)
649 656
650 @pushdiscovery('bookmarks') 657 @pushdiscovery('bookmarks')
651 def _pushdiscoverybookmarks(pushop): 658 def _pushdiscoverybookmarks(pushop):
652 ui = pushop.ui 659 ui = pushop.ui
653 repo = pushop.repo.unfiltered() 660 repo = pushop.repo.unfiltered()
655 ui.debug("checking for updated bookmarks\n") 662 ui.debug("checking for updated bookmarks\n")
656 ancestors = () 663 ancestors = ()
657 if pushop.revs: 664 if pushop.revs:
658 revnums = map(repo.changelog.rev, pushop.revs) 665 revnums = map(repo.changelog.rev, pushop.revs)
659 ancestors = repo.changelog.ancestors(revnums, inclusive=True) 666 ancestors = repo.changelog.ancestors(revnums, inclusive=True)
660 remotebookmark = remote.listkeys('bookmarks') 667
668 remotebookmark = listkeys(remote, 'bookmarks')
661 669
662 explicit = set([repo._bookmarks.expandname(bookmark) 670 explicit = set([repo._bookmarks.expandname(bookmark)
663 for bookmark in pushop.bookmarks]) 671 for bookmark in pushop.bookmarks])
664 672
665 remotebookmark = bookmod.unhexlifybookmarks(remotebookmark) 673 remotebookmark = bookmod.unhexlifybookmarks(remotebookmark)
1166 1174
1167 def _pushsyncphase(pushop): 1175 def _pushsyncphase(pushop):
1168 """synchronise phase information locally and remotely""" 1176 """synchronise phase information locally and remotely"""
1169 cheads = pushop.commonheads 1177 cheads = pushop.commonheads
1170 # even when we don't push, exchanging phase data is useful 1178 # even when we don't push, exchanging phase data is useful
1171 remotephases = pushop.remote.listkeys('phases') 1179 remotephases = listkeys(pushop.remote, 'phases')
1172 if (pushop.ui.configbool('ui', '_usedassubrepo') 1180 if (pushop.ui.configbool('ui', '_usedassubrepo')
1173 and remotephases # server supports phases 1181 and remotephases # server supports phases
1174 and pushop.cgresult is None # nothing was pushed 1182 and pushop.cgresult is None # nothing was pushed
1175 and remotephases.get('publishing', False)): 1183 and remotephases.get('publishing', False)):
1176 # When: 1184 # When:
1389 1397
1390 def release(self): 1398 def release(self):
1391 """release transaction if created""" 1399 """release transaction if created"""
1392 if self._tr is not None: 1400 if self._tr is not None:
1393 self._tr.release() 1401 self._tr.release()
1402
1403 def listkeys(remote, namespace):
1404 with remote.commandexecutor() as e:
1405 return e.callcommand('listkeys', {'namespace': namespace}).result()
1394 1406
1395 def _fullpullbundle2(repo, pullop): 1407 def _fullpullbundle2(repo, pullop):
1396 # The server may send a partial reply, i.e. when inlining 1408 # The server may send a partial reply, i.e. when inlining
1397 # pre-computed bundles. In that case, update the common 1409 # pre-computed bundles. In that case, update the common
1398 # set based on the results and pull another bundle. 1410 # set based on the results and pull another bundle.
1527 return 1539 return
1528 if pullop.canusebundle2 and 'listkeys' in pullop.remotebundle2caps: 1540 if pullop.canusebundle2 and 'listkeys' in pullop.remotebundle2caps:
1529 # all known bundle2 servers now support listkeys, but lets be nice with 1541 # all known bundle2 servers now support listkeys, but lets be nice with
1530 # new implementation. 1542 # new implementation.
1531 return 1543 return
1532 books = pullop.remote.listkeys('bookmarks') 1544 books = listkeys(pullop.remote, 'bookmarks')
1533 pullop.remotebookmarks = bookmod.unhexlifybookmarks(books) 1545 pullop.remotebookmarks = bookmod.unhexlifybookmarks(books)
1534 1546
1535 1547
1536 @pulldiscovery('changegroup') 1548 @pulldiscovery('changegroup')
1537 def _pulldiscoverychangegroup(pullop): 1549 def _pulldiscoverychangegroup(pullop):
1739 1751
1740 def _pullphase(pullop): 1752 def _pullphase(pullop):
1741 # Get remote phases data from remote 1753 # Get remote phases data from remote
1742 if 'phases' in pullop.stepsdone: 1754 if 'phases' in pullop.stepsdone:
1743 return 1755 return
1744 remotephases = pullop.remote.listkeys('phases') 1756 remotephases = listkeys(pullop.remote, 'phases')
1745 _pullapplyphases(pullop, remotephases) 1757 _pullapplyphases(pullop, remotephases)
1746 1758
1747 def _pullapplyphases(pullop, remotephases): 1759 def _pullapplyphases(pullop, remotephases):
1748 """apply phase movement from observed remote state""" 1760 """apply phase movement from observed remote state"""
1749 if 'phases' in pullop.stepsdone: 1761 if 'phases' in pullop.stepsdone:
1803 return 1815 return
1804 pullop.stepsdone.add('obsmarkers') 1816 pullop.stepsdone.add('obsmarkers')
1805 tr = None 1817 tr = None
1806 if obsolete.isenabled(pullop.repo, obsolete.exchangeopt): 1818 if obsolete.isenabled(pullop.repo, obsolete.exchangeopt):
1807 pullop.repo.ui.debug('fetching remote obsolete markers\n') 1819 pullop.repo.ui.debug('fetching remote obsolete markers\n')
1808 remoteobs = pullop.remote.listkeys('obsolete') 1820 remoteobs = listkeys(pullop.remote, 'obsolete')
1809 if 'dump0' in remoteobs: 1821 if 'dump0' in remoteobs:
1810 tr = pullop.gettransaction() 1822 tr = pullop.gettransaction()
1811 markers = [] 1823 markers = []
1812 for key in sorted(remoteobs, reverse=True): 1824 for key in sorted(remoteobs, reverse=True):
1813 if key.startswith('dump'): 1825 if key.startswith('dump'):