Mercurial > hg
comparison mercurial/statichttprepo.py @ 17192:1ac628cd7113
peer: introduce real peer classes
This change separates peer implementations from the repository implementation.
localpeer currently is a simple pass-through to localrepository, except for
legacy calls, which have already been removed from localpeer. This ensures that
the local client code only uses the most modern peer API when talking to local
repos.
Peers have a .local() method which returns either None or the underlying
localrepository (or descendant thereof). Repos have a .peer() method to return
a freshly constructed localpeer. The latter is used by hg.peer(), and also to
allow folks to pass either a peer or a repo to some generic helper methods.
We might want to get rid of .peer() eventually.
The only user of locallegacypeer is debugdiscovery, which uses it to pose as a
pre-setdiscovery client. But we decided to leave the old API defined in
locallegacypeer for clarity and maybe for other uses in the future.
It might be nice to actually define the peer API directly in peer.py as stub
methods. One problem there is, however, that localpeer implements
lock/addchangegroup, whereas the true remote peers implement unbundle.
It might be desireable to get rid of this distinction eventually.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Fri, 13 Jul 2012 21:47:06 +0200 |
parents | 7034365089bf |
children | 1d710fe5ee0e |
comparison
equal
deleted
inserted
replaced
17191:5884812686f7 | 17192:1ac628cd7113 |
---|---|
74 f = "/".join((self.base, urllib.quote(path))) | 74 f = "/".join((self.base, urllib.quote(path))) |
75 return httprangereader(f, urlopener) | 75 return httprangereader(f, urlopener) |
76 | 76 |
77 return statichttpopener | 77 return statichttpopener |
78 | 78 |
79 class statichttppeer(localrepo.localpeer): | |
80 def local(self): | |
81 return None | |
82 | |
79 class statichttprepository(localrepo.localrepository): | 83 class statichttprepository(localrepo.localrepository): |
80 def __init__(self, ui, path): | 84 def __init__(self, ui, path): |
81 self._url = path | 85 self._url = path |
82 self.ui = ui | 86 self.ui = ui |
83 | 87 |
114 self.spath = self.store.path | 118 self.spath = self.store.path |
115 self.sopener = self.store.opener | 119 self.sopener = self.store.opener |
116 self.svfs = self.sopener | 120 self.svfs = self.sopener |
117 self.sjoin = self.store.join | 121 self.sjoin = self.store.join |
118 self._filecache = {} | 122 self._filecache = {} |
123 self.requirements = requirements | |
119 | 124 |
120 self.manifest = manifest.manifest(self.sopener) | 125 self.manifest = manifest.manifest(self.sopener) |
121 self.changelog = changelog.changelog(self.sopener) | 126 self.changelog = changelog.changelog(self.sopener) |
122 self._tags = None | 127 self._tags = None |
123 self.nodetagscache = None | 128 self.nodetagscache = None |
124 self._branchcache = None | 129 self._branchcache = None |
125 self._branchcachetip = None | 130 self._branchcachetip = None |
126 self.encodepats = None | 131 self.encodepats = None |
127 self.decodepats = None | 132 self.decodepats = None |
128 self.capabilities.difference_update(["pushkey"]) | 133 |
134 def _restrictcapabilities(self, caps): | |
135 return caps.difference(["pushkey"]) | |
129 | 136 |
130 def url(self): | 137 def url(self): |
131 return self._url | 138 return self._url |
132 | 139 |
133 def local(self): | 140 def local(self): |
134 return False | 141 return False |
142 | |
143 def peer(self): | |
144 return statichttppeer(self) | |
135 | 145 |
136 def lock(self, wait=True): | 146 def lock(self, wait=True): |
137 raise util.Abort(_('cannot lock static-http repository')) | 147 raise util.Abort(_('cannot lock static-http repository')) |
138 | 148 |
139 def instance(ui, path, create): | 149 def instance(ui, path, create): |