Mercurial > hgsubversion
comparison hgsubversion/svnrepo.py @ 1519:aec176db232c
svnrepo: update with the latest upstream change
The Mercurial upstream had a massive change on wireproto interface recently.
Update code to be compatible with both versions.
author | Jun Wu <quark@fb.com> |
---|---|
date | Mon, 21 Aug 2017 15:19:12 -0700 |
parents | d890d8d4e168 |
children | ae01b360320b |
comparison
equal
deleted
inserted
replaced
1518:09476d758b59 | 1519:aec176db232c |
---|---|
18 | 18 |
19 from mercurial import error | 19 from mercurial import error |
20 from mercurial import localrepo | 20 from mercurial import localrepo |
21 from mercurial import util as hgutil | 21 from mercurial import util as hgutil |
22 | 22 |
23 peerapi = 0 | |
23 try: | 24 try: |
24 from mercurial.peer import peerrepository | 25 try: |
26 from mercurial.repository import peer as peerrepository | |
27 peerapi = 1 | |
28 except ImportError: | |
29 from mercurial.peer import peerrepository | |
25 from mercurial import httppeer | 30 from mercurial import httppeer |
26 except ImportError: | 31 except ImportError: |
27 from mercurial.repo import repository as peerrepository | 32 from mercurial.repo import repository as peerrepository |
28 from mercurial import httprepo as httppeer | 33 from mercurial import httprepo as httppeer |
29 | 34 |
120 | 125 |
121 class svnremoterepo(peerrepository): | 126 class svnremoterepo(peerrepository): |
122 """ the dumb wrapper for actual Subversion repositories """ | 127 """ the dumb wrapper for actual Subversion repositories """ |
123 | 128 |
124 def __init__(self, ui, path=None): | 129 def __init__(self, ui, path=None): |
125 self.ui = ui | 130 self._ui = ui |
126 if path is None: | 131 if path is None: |
127 path = self.ui.config('paths', 'default-push') | 132 path = self.ui.config('paths', 'default-push') |
128 if path is None: | 133 if path is None: |
129 path = self.ui.config('paths', 'default') | 134 path = self.ui.config('paths', 'default') |
130 if not path: | 135 if not path: |
131 raise hgutil.Abort('no Subversion URL specified. Expect[path] default= or [path] default-push= SVN URL entries in hgrc.') | 136 raise hgutil.Abort('no Subversion URL specified. Expect[path] default= or [path] default-push= SVN URL entries in hgrc.') |
132 self.path = path | 137 self.path = path |
133 self.capabilities = set(['lookup', 'subversion']) | 138 if peerapi == 1: |
139 self._capabilities = set(['lookup', 'subversion']) | |
140 elif peerapi == 0: | |
141 self.capabilities = set(['lookup', 'subversion']) | |
134 pws = self.ui.config('hgsubversion', 'password_stores', None) | 142 pws = self.ui.config('hgsubversion', 'password_stores', None) |
135 if pws is not None: | 143 if pws is not None: |
136 # Split pws at comas and strip neighbouring whitespace (whitespace | 144 # Split pws at comas and strip neighbouring whitespace (whitespace |
137 # at the beginning and end of pws has already been removed by the | 145 # at the beginning and end of pws has already been removed by the |
138 # config parser). | 146 # config parser). |
139 self.password_stores = re.split(r'\s*,\s*', pws) | 147 self.password_stores = re.split(r'\s*,\s*', pws) |
140 else: | 148 else: |
141 self.password_stores = None | 149 self.password_stores = None |
142 | 150 |
143 def _capabilities(self): | 151 if peerapi == 1: |
144 return self.capabilities | 152 def capabilities(self): |
153 return self._capabilities | |
154 elif peerapi == 0: | |
155 def _capabilities(self): | |
156 return self.capabilities | |
145 | 157 |
146 @propertycache | 158 @propertycache |
147 def svnauth(self): | 159 def svnauth(self): |
148 # DO NOT default the user to hg's getuser(). If you provide | 160 # DO NOT default the user to hg's getuser(). If you provide |
149 # *any* default username to Subversion, it won't use any remembered | 161 # *any* default username to Subversion, it won't use any remembered |
166 return svnwrap.SubversionRepo(auth[0], auth[1], auth[2], password_stores=self.password_stores) | 178 return svnwrap.SubversionRepo(auth[0], auth[1], auth[2], password_stores=self.password_stores) |
167 except svnwrap.SubversionConnectionException, e: | 179 except svnwrap.SubversionConnectionException, e: |
168 self.ui.traceback() | 180 self.ui.traceback() |
169 raise hgutil.Abort(e) | 181 raise hgutil.Abort(e) |
170 | 182 |
183 @property | |
184 def ui(self): | |
185 return self._ui | |
186 | |
171 def url(self): | 187 def url(self): |
172 return self.path | 188 return self.path |
173 | 189 |
174 def lookup(self, key): | 190 def lookup(self, key): |
175 return key | 191 return key |
187 def pushkey(self, namespace, key, old, new): | 203 def pushkey(self, namespace, key, old, new): |
188 return False | 204 return False |
189 | 205 |
190 def listkeys(self, namespace): | 206 def listkeys(self, namespace): |
191 return {} | 207 return {} |
208 | |
209 if peerapi == 1: | |
210 def canpush(self): | |
211 return True | |
212 | |
213 def close(self): | |
214 pass | |
215 | |
216 def iterbatch(self): | |
217 raise NotImplementedError | |
218 | |
219 def known(self): | |
220 raise NotImplementedError | |
221 | |
222 def getbundle(self): | |
223 raise NotImplementedError | |
224 | |
225 def local(self): | |
226 return None | |
227 | |
228 def peer(self): | |
229 return self | |
230 | |
231 def stream_out(self): | |
232 raise NotImplementedError | |
233 | |
234 def unbundle(self): | |
235 raise NotImplementedError | |
236 | |
237 def branchmap(self): | |
238 raise NotImplementedError | |
239 | |
240 def debugwireargs(self): | |
241 raise NotImplementedError | |
192 | 242 |
193 def instance(ui, url, create): | 243 def instance(ui, url, create): |
194 if url.startswith('http://') or url.startswith('https://'): | 244 if url.startswith('http://') or url.startswith('https://'): |
195 try: | 245 try: |
196 # may yield a bogus 'real URL...' message | 246 # may yield a bogus 'real URL...' message |