changeset 49751:a6e2a668c746

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 03 Dec 2022 00:00:41 +0100
parents f075a9463ee7
children 611ccb631cbc
files mercurial/httppeer.py mercurial/interfaces/repository.py mercurial/localrepo.py mercurial/sshpeer.py
diffstat 4 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httppeer.py	Fri Dec 02 18:04:51 2022 +0100
+++ b/mercurial/httppeer.py	Sat Dec 03 00:00:41 2022 +0100
@@ -382,7 +382,7 @@
 
 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
--- a/mercurial/interfaces/repository.py	Fri Dec 02 18:04:51 2022 +0100
+++ b/mercurial/interfaces/repository.py	Sat Dec 03 00:00:41 2022 +0100
@@ -387,6 +387,12 @@
 
     limitedarguments = False
 
+    def __init__(
+        self,
+        ui,
+    ):
+        self.ui = ui
+
     def capable(self, name):
         caps = self.capabilities()
         if name in caps:
--- a/mercurial/localrepo.py	Fri Dec 02 18:04:51 2022 +0100
+++ b/mercurial/localrepo.py	Sat Dec 03 00:00:41 2022 +0100
@@ -304,12 +304,11 @@
     '''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)
--- a/mercurial/sshpeer.py	Fri Dec 02 18:04:51 2022 +0100
+++ b/mercurial/sshpeer.py	Sat Dec 03 00:00:41 2022 +0100
@@ -383,8 +383,8 @@
         ``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