# HG changeset patch # User Pierre-Yves David # Date 2022-12-02 23:00:41 # Node ID a6e2a668c746e55506381a9cb4121fab753c351d # Parent f075a9463ee7a55ef2c3ca51c292b5ed8ab62148 peer: have a common constructor and use it For now it does not do much, but we will extend it to also store a path object soon. diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -382,7 +382,7 @@ def parsev1commandresponse(ui, baseurl, class httppeer(wireprotov1peer.wirepeer): def __init__(self, ui, path, url, opener, requestbuilder, caps): - self.ui = ui + super().__init__(ui) self._path = path self._url = url self._caps = caps diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -387,6 +387,12 @@ class peer: limitedarguments = False + def __init__( + self, + ui, + ): + self.ui = ui + def capable(self, name): caps = self.capabilities() if name in caps: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -304,12 +304,11 @@ class localpeer(repository.peer): '''peer for a local repo; reflects only the most recent API''' def __init__(self, repo, caps=None): - super(localpeer, self).__init__() + super(localpeer, self).__init__(repo.ui) if caps is None: caps = moderncaps.copy() self._repo = repo.filtered(b'served') - self.ui = repo.ui if repo._wanted_sidedata: formatted = bundle2.format_remote_wanted_sidedata(repo) diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -383,8 +383,8 @@ class sshv1peer(wireprotov1peer.wirepeer ``autoreadstderr`` denotes whether to automatically read from stderr and to forward its output. """ + super().__init__(ui) self._url = url - self.ui = ui # self._subprocess is unused. Keeping a handle on the process # holds a reference and prevents it from being garbage collected. self._subprocess = proc