comparison hgext/infinitepush/__init__.py @ 50782:014ff9a62501

wrapfunction: use sysstr instead of bytes as argument in "infinitepush" This is as valid and simpler, it will help us to eventually get ride of `safehasattr`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 03 Feb 2023 04:21:55 +0100
parents 68c4f8f3c9f4
children
comparison
equal deleted inserted replaced
50781:0fbc0c978053 50782:014ff9a62501
388 ) 388 )
389 newphaseheadshandler.params = orighandlephasehandler.params 389 newphaseheadshandler.params = orighandlephasehandler.params
390 bundle2.parthandlermapping[b'phase-heads'] = newphaseheadshandler 390 bundle2.parthandlermapping[b'phase-heads'] = newphaseheadshandler
391 391
392 extensions.wrapfunction( 392 extensions.wrapfunction(
393 localrepo.localrepository, b'listkeys', localrepolistkeys 393 localrepo.localrepository, 'listkeys', localrepolistkeys
394 ) 394 )
395 wireprotov1server.commands[b'lookup'] = ( 395 wireprotov1server.commands[b'lookup'] = (
396 _lookupwrap(wireprotov1server.commands[b'lookup'][0]), 396 _lookupwrap(wireprotov1server.commands[b'lookup'][0]),
397 b'key', 397 b'key',
398 ) 398 )
399 extensions.wrapfunction(exchange, b'getbundlechunks', getbundlechunks) 399 extensions.wrapfunction(exchange, 'getbundlechunks', getbundlechunks)
400 400
401 extensions.wrapfunction(bundle2, b'processparts', processparts) 401 extensions.wrapfunction(bundle2, 'processparts', processparts)
402 402
403 403
404 def clientextsetup(ui): 404 def clientextsetup(ui):
405 entry = extensions.wrapcommand(commands.table, b'push', _push) 405 entry = extensions.wrapcommand(commands.table, b'push', _push)
406 406
413 ) 413 )
414 ) 414 )
415 415
416 extensions.wrapcommand(commands.table, b'pull', _pull) 416 extensions.wrapcommand(commands.table, b'pull', _pull)
417 417
418 extensions.wrapfunction(discovery, b'checkheads', _checkheads) 418 extensions.wrapfunction(discovery, 'checkheads', _checkheads)
419 419
420 wireprotov1peer.wirepeer.listkeyspatterns = listkeyspatterns 420 wireprotov1peer.wirepeer.listkeyspatterns = listkeyspatterns
421 421
422 partorder = exchange.b2partsgenorder 422 partorder = exchange.b2partsgenorder
423 index = partorder.index(b'changeset') 423 index = partorder.index(b'changeset')
664 del origvalues[b'publishing'] 664 del origvalues[b'publishing']
665 origvalues.update(newphases) 665 origvalues.update(newphases)
666 return origvalues 666 return origvalues
667 667
668 extensions.wrapfunction( 668 extensions.wrapfunction(
669 localrepo.localrepository, b'listkeys', _listkeys 669 localrepo.localrepository, 'listkeys', _listkeys
670 ) 670 )
671 wrappedlistkeys = True 671 wrappedlistkeys = True
672 heads = list((set(newheads) | set(heads)) - set(scratchheads)) 672 heads = list((set(newheads) | set(heads)) - set(scratchheads))
673 result = orig( 673 result = orig(
674 repo, source, heads=heads, bundlecaps=bundlecaps, **kwargs 674 repo, source, heads=heads, bundlecaps=bundlecaps, **kwargs
676 finally: 676 finally:
677 if wrappedchangegrouppart: 677 if wrappedchangegrouppart:
678 exchange.getbundle2partsmapping[b'changegroup'] = oldchangegrouppart 678 exchange.getbundle2partsmapping[b'changegroup'] = oldchangegrouppart
679 if wrappedlistkeys: 679 if wrappedlistkeys:
680 extensions.unwrapfunction( 680 extensions.unwrapfunction(
681 localrepo.localrepository, b'listkeys', _listkeys 681 localrepo.localrepository, 'listkeys', _listkeys
682 ) 682 )
683 return result 683 return result
684 684
685 685
686 def _lookupwrap(orig): 686 def _lookupwrap(orig):
755 opts[b'rev'] = revs 755 opts[b'rev'] = revs
756 756
757 if scratchbookmarks or unknownnodes: 757 if scratchbookmarks or unknownnodes:
758 # Set anyincoming to True 758 # Set anyincoming to True
759 extensions.wrapfunction( 759 extensions.wrapfunction(
760 discovery, b'findcommonincoming', _findcommonincoming 760 discovery, 'findcommonincoming', _findcommonincoming
761 ) 761 )
762 try: 762 try:
763 # Remote scratch bookmarks will be deleted because remotenames doesn't 763 # Remote scratch bookmarks will be deleted because remotenames doesn't
764 # know about them. Let's save it before pull and restore after 764 # know about them. Let's save it before pull and restore after
765 remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, path.loc) 765 remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, path.loc)
773 else: 773 else:
774 _savelocalbookmarks(repo, scratchbookmarks) 774 _savelocalbookmarks(repo, scratchbookmarks)
775 return result 775 return result
776 finally: 776 finally:
777 if scratchbookmarks: 777 if scratchbookmarks:
778 extensions.unwrapfunction(discovery, b'findcommonincoming') 778 extensions.unwrapfunction(discovery, 'findcommonincoming')
779 779
780 780
781 def _readscratchremotebookmarks(ui, repo, other): 781 def _readscratchremotebookmarks(ui, repo, other):
782 if common.isremotebooksenabled(ui): 782 if common.isremotebooksenabled(ui):
783 remotenamesext = extensions.find(b'remotenames') 783 remotenamesext = extensions.find(b'remotenames')
866 # this is an infinitepush, we don't want the bookmark to be applied 866 # this is an infinitepush, we don't want the bookmark to be applied
867 # rather that should be stored in the bundlestore 867 # rather that should be stored in the bundlestore
868 opts[b'bookmark'] = [] 868 opts[b'bookmark'] = []
869 ui.setconfig(experimental, configscratchpush, True) 869 ui.setconfig(experimental, configscratchpush, True)
870 oldphasemove = extensions.wrapfunction( 870 oldphasemove = extensions.wrapfunction(
871 exchange, b'_localphasemove', _phasemove 871 exchange, '_localphasemove', _phasemove
872 ) 872 )
873 873
874 paths = list(urlutil.get_push_paths(repo, ui, dests)) 874 paths = list(urlutil.get_push_paths(repo, ui, dests))
875 if len(paths) > 1: 875 if len(paths) > 1:
876 msg = _(b'cannot push to multiple path with infinitepush') 876 msg = _(b'cannot push to multiple path with infinitepush')