comparison mercurial/sshpeer.py @ 50440:3a2df812e1c7

pull: add --remote-hidden option and pass it through peer creation This option will allow to pull changesets that are hidden on the remote. This is useful when looking into a changeset’s evolution history, resolving evolution instability or mirroring a repository. The option is best effort and will only affect the pull when it can. The option will be ignored when it cannot be honored. Support for each type of peer is yet to be implemented. They currently all warn about lack of support. The warning code will get removed as peers gain support for this option. The option is still experimental, so we will have freedom to update the UI or implementation before it graduates out of experimental. Based on a changeset by Pierre-Yves David, which added the option.
author Manuel Jacob <me@manueljacob.de>
date Thu, 04 Apr 2019 18:07:30 +0200
parents ed052780ad5e
children 45c7bada5200
comparison
equal deleted inserted replaced
50439:4077d6222cf1 50440:3a2df812e1c7
370 return protoname, caps 370 return protoname, caps
371 371
372 372
373 class sshv1peer(wireprotov1peer.wirepeer): 373 class sshv1peer(wireprotov1peer.wirepeer):
374 def __init__( 374 def __init__(
375 self, ui, path, proc, stdin, stdout, stderr, caps, autoreadstderr=True 375 self,
376 ui,
377 path,
378 proc,
379 stdin,
380 stdout,
381 stderr,
382 caps,
383 autoreadstderr=True,
384 remotehidden=False,
376 ): 385 ):
377 """Create a peer from an existing SSH connection. 386 """Create a peer from an existing SSH connection.
378 387
379 ``proc`` is a handle on the underlying SSH process. 388 ``proc`` is a handle on the underlying SSH process.
380 ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio 389 ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio
381 pipes for that process. 390 pipes for that process.
382 ``caps`` is a set of capabilities supported by the remote. 391 ``caps`` is a set of capabilities supported by the remote.
383 ``autoreadstderr`` denotes whether to automatically read from 392 ``autoreadstderr`` denotes whether to automatically read from
384 stderr and to forward its output. 393 stderr and to forward its output.
385 """ 394 """
386 super().__init__(ui, path=path) 395 super().__init__(ui, path=path, remotehidden=remotehidden)
396 if remotehidden:
397 msg = _(
398 b"ignoring `--remote-hidden` request\n"
399 b"(access to hidden changeset for ssh peers not supported "
400 b"yet)\n"
401 )
402 ui.warn(msg)
387 # self._subprocess is unused. Keeping a handle on the process 403 # self._subprocess is unused. Keeping a handle on the process
388 # holds a reference and prevents it from being garbage collected. 404 # holds a reference and prevents it from being garbage collected.
389 self._subprocess = proc 405 self._subprocess = proc
390 406
391 # And we hook up our "doublepipe" wrapper to allow querying 407 # And we hook up our "doublepipe" wrapper to allow querying
566 self._pipeo.flush() 582 self._pipeo.flush()
567 if self._autoreadstderr: 583 if self._autoreadstderr:
568 self._readerr() 584 self._readerr()
569 585
570 586
571 def _make_peer(ui, path, proc, stdin, stdout, stderr, autoreadstderr=True): 587 def _make_peer(
588 ui,
589 path,
590 proc,
591 stdin,
592 stdout,
593 stderr,
594 autoreadstderr=True,
595 remotehidden=False,
596 ):
572 """Make a peer instance from existing pipes. 597 """Make a peer instance from existing pipes.
573 598
574 ``path`` and ``proc`` are stored on the eventual peer instance and may 599 ``path`` and ``proc`` are stored on the eventual peer instance and may
575 not be used for anything meaningful. 600 not be used for anything meaningful.
576 601
596 stdin, 621 stdin,
597 stdout, 622 stdout,
598 stderr, 623 stderr,
599 caps, 624 caps,
600 autoreadstderr=autoreadstderr, 625 autoreadstderr=autoreadstderr,
626 remotehidden=remotehidden,
601 ) 627 )
602 else: 628 else:
603 _cleanuppipes(ui, stdout, stdin, stderr, warn=None) 629 _cleanuppipes(ui, stdout, stdin, stderr, warn=None)
604 raise error.RepoError( 630 raise error.RepoError(
605 _(b'unknown version of SSH protocol: %s') % protoname 631 _(b'unknown version of SSH protocol: %s') % protoname
606 ) 632 )
607 633
608 634
609 def make_peer(ui, path, create, intents=None, createopts=None): 635 def make_peer(
636 ui, path, create, intents=None, createopts=None, remotehidden=False
637 ):
610 """Create an SSH peer. 638 """Create an SSH peer.
611 639
612 The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. 640 The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
613 """ 641 """
614 u = urlutil.url(path.loc, parsequery=False, parsefragment=False) 642 u = urlutil.url(path.loc, parsequery=False, parsefragment=False)
656 684
657 proc, stdin, stdout, stderr = _makeconnection( 685 proc, stdin, stdout, stderr = _makeconnection(
658 ui, sshcmd, args, remotecmd, remotepath, sshenv 686 ui, sshcmd, args, remotecmd, remotepath, sshenv
659 ) 687 )
660 688
661 peer = _make_peer(ui, path, proc, stdin, stdout, stderr) 689 peer = _make_peer(
690 ui, path, proc, stdin, stdout, stderr, remotehidden=remotehidden
691 )
662 692
663 # Finally, if supported by the server, notify it about our own 693 # Finally, if supported by the server, notify it about our own
664 # capabilities. 694 # capabilities.
665 if b'protocaps' in peer.capabilities(): 695 if b'protocaps' in peer.capabilities():
666 try: 696 try: