Mercurial > public > mercurial-scm > hg
comparison mercurial/httprepo.py @ 5176:664a1c312972
fix-up references to repo.RepoError
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 15 Aug 2007 16:10:24 -0500 |
parents | 79373ec3f27d |
children | 86e95b93559a |
comparison
equal
deleted
inserted
replaced
5175:012dbf88b9b2 | 5176:664a1c312972 |
---|---|
7 # of the GNU General Public License, incorporated herein by reference. | 7 # of the GNU General Public License, incorporated herein by reference. |
8 | 8 |
9 from node import * | 9 from node import * |
10 from remoterepo import * | 10 from remoterepo import * |
11 from i18n import _ | 11 from i18n import _ |
12 import hg, os, urllib, urllib2, urlparse, zlib, util, httplib | 12 import repo, os, urllib, urllib2, urlparse, zlib, util, httplib |
13 import errno, keepalive, tempfile, socket, changegroup | 13 import errno, keepalive, tempfile, socket, changegroup |
14 | 14 |
15 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): | 15 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): |
16 def __init__(self, ui): | 16 def __init__(self, ui): |
17 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) | 17 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
275 | 275 |
276 def get_caps(self): | 276 def get_caps(self): |
277 if self.caps is None: | 277 if self.caps is None: |
278 try: | 278 try: |
279 self.caps = self.do_read('capabilities').split() | 279 self.caps = self.do_read('capabilities').split() |
280 except hg.RepoError: | 280 except repo.RepoError: |
281 self.caps = () | 281 self.caps = () |
282 self.ui.debug(_('capabilities: %s\n') % | 282 self.ui.debug(_('capabilities: %s\n') % |
283 (' '.join(self.caps or ['none']))) | 283 (' '.join(self.caps or ['none']))) |
284 return self.caps | 284 return self.caps |
285 | 285 |
327 # accept old "text/plain" and "application/hg-changegroup" for now | 327 # accept old "text/plain" and "application/hg-changegroup" for now |
328 if not (proto.startswith('application/mercurial-') or | 328 if not (proto.startswith('application/mercurial-') or |
329 proto.startswith('text/plain') or | 329 proto.startswith('text/plain') or |
330 proto.startswith('application/hg-changegroup')): | 330 proto.startswith('application/hg-changegroup')): |
331 self.ui.debug(_("Requested URL: '%s'\n") % cu) | 331 self.ui.debug(_("Requested URL: '%s'\n") % cu) |
332 raise hg.RepoError(_("'%s' does not appear to be an hg repository") | 332 raise repo.RepoError(_("'%s' does not appear to be an hg repository") |
333 % self._url) | 333 % self._url) |
334 | 334 |
335 if proto.startswith('application/mercurial-'): | 335 if proto.startswith('application/mercurial-'): |
336 try: | 336 try: |
337 version = proto.split('-', 1)[1] | 337 version = proto.split('-', 1)[1] |
338 version_info = tuple([int(n) for n in version.split('.')]) | 338 version_info = tuple([int(n) for n in version.split('.')]) |
339 except ValueError: | 339 except ValueError: |
340 raise hg.RepoError(_("'%s' sent a broken Content-type " | 340 raise repo.RepoError(_("'%s' sent a broken Content-type " |
341 "header (%s)") % (self._url, proto)) | 341 "header (%s)") % (self._url, proto)) |
342 if version_info > (0, 1): | 342 if version_info > (0, 1): |
343 raise hg.RepoError(_("'%s' uses newer protocol %s") % | 343 raise repo.RepoError(_("'%s' uses newer protocol %s") % |
344 (self._url, version)) | 344 (self._url, version)) |
345 | 345 |
346 return resp | 346 return resp |
347 | 347 |
348 def do_read(self, cmd, **args): | 348 def do_read(self, cmd, **args): |
356 def lookup(self, key): | 356 def lookup(self, key): |
357 d = self.do_cmd("lookup", key = key).read() | 357 d = self.do_cmd("lookup", key = key).read() |
358 success, data = d[:-1].split(' ', 1) | 358 success, data = d[:-1].split(' ', 1) |
359 if int(success): | 359 if int(success): |
360 return bin(data) | 360 return bin(data) |
361 raise hg.RepoError(data) | 361 raise repo.RepoError(data) |
362 | 362 |
363 def heads(self): | 363 def heads(self): |
364 d = self.do_read("heads") | 364 d = self.do_read("heads") |
365 try: | 365 try: |
366 return map(bin, d[:-1].split(" ")) | 366 return map(bin, d[:-1].split(" ")) |