comparison mercurial/httprepo.py @ 9467:4c041f1ee1b4

do not attempt to translate ui.debug output
author Martin Geisler <mg@lazybytes.net>
date Sat, 19 Sep 2009 01:15:38 +0200
parents f8ff65a83169
children 67e5d5a2f625
comparison
equal deleted inserted replaced
9466:1214c64c592b 9467:4c041f1ee1b4
33 33
34 # urllib cannot handle URLs with embedded user or passwd 34 # urllib cannot handle URLs with embedded user or passwd
35 self._url, authinfo = url.getauthinfo(path) 35 self._url, authinfo = url.getauthinfo(path)
36 36
37 self.ui = ui 37 self.ui = ui
38 self.ui.debug(_('using %s\n') % self._url) 38 self.ui.debug('using %s\n' % self._url)
39 39
40 self.urlopener = url.opener(ui, authinfo) 40 self.urlopener = url.opener(ui, authinfo)
41 41
42 def __del__(self): 42 def __del__(self):
43 for h in self.urlopener.handlers: 43 for h in self.urlopener.handlers:
54 if self.caps is None: 54 if self.caps is None:
55 try: 55 try:
56 self.caps = set(self.do_read('capabilities').split()) 56 self.caps = set(self.do_read('capabilities').split())
57 except error.RepoError: 57 except error.RepoError:
58 self.caps = set() 58 self.caps = set()
59 self.ui.debug(_('capabilities: %s\n') % 59 self.ui.debug('capabilities: %s\n' %
60 (' '.join(self.caps or ['none']))) 60 (' '.join(self.caps or ['none'])))
61 return self.caps 61 return self.caps
62 62
63 capabilities = property(get_caps) 63 capabilities = property(get_caps)
64 64
66 raise util.Abort(_('operation not supported over http')) 66 raise util.Abort(_('operation not supported over http'))
67 67
68 def do_cmd(self, cmd, **args): 68 def do_cmd(self, cmd, **args):
69 data = args.pop('data', None) 69 data = args.pop('data', None)
70 headers = args.pop('headers', {}) 70 headers = args.pop('headers', {})
71 self.ui.debug(_("sending %s command\n") % cmd) 71 self.ui.debug("sending %s command\n" % cmd)
72 q = {"cmd": cmd} 72 q = {"cmd": cmd}
73 q.update(args) 73 q.update(args)
74 qs = '?%s' % urllib.urlencode(q) 74 qs = '?%s' % urllib.urlencode(q)
75 cu = "%s%s" % (self._url, qs) 75 cu = "%s%s" % (self._url, qs)
76 try: 76 try:
77 if data: 77 if data:
78 self.ui.debug(_("sending %s bytes\n") % len(data)) 78 self.ui.debug("sending %s bytes\n" % len(data))
79 resp = self.urlopener.open(urllib2.Request(cu, data, headers)) 79 resp = self.urlopener.open(urllib2.Request(cu, data, headers))
80 except urllib2.HTTPError, inst: 80 except urllib2.HTTPError, inst:
81 if inst.code == 401: 81 if inst.code == 401:
82 raise util.Abort(_('authorization failed')) 82 raise util.Abort(_('authorization failed'))
83 raise 83 raise
84 except httplib.HTTPException, inst: 84 except httplib.HTTPException, inst:
85 self.ui.debug(_('http error while sending %s command\n') % cmd) 85 self.ui.debug('http error while sending %s command\n' % cmd)
86 self.ui.traceback() 86 self.ui.traceback()
87 raise IOError(None, inst) 87 raise IOError(None, inst)
88 except IndexError: 88 except IndexError:
89 # this only happens with Python 2.3, later versions raise URLError 89 # this only happens with Python 2.3, later versions raise URLError
90 raise util.Abort(_('http error, possibly caused by proxy setting')) 90 raise util.Abort(_('http error, possibly caused by proxy setting'))
103 safeurl = url.hidepassword(self._url) 103 safeurl = url.hidepassword(self._url)
104 # accept old "text/plain" and "application/hg-changegroup" for now 104 # accept old "text/plain" and "application/hg-changegroup" for now
105 if not (proto.startswith('application/mercurial-') or 105 if not (proto.startswith('application/mercurial-') or
106 proto.startswith('text/plain') or 106 proto.startswith('text/plain') or
107 proto.startswith('application/hg-changegroup')): 107 proto.startswith('application/hg-changegroup')):
108 self.ui.debug(_("requested URL: '%s'\n") % url.hidepassword(cu)) 108 self.ui.debug("requested URL: '%s'\n" % url.hidepassword(cu))
109 raise error.RepoError(_("'%s' does not appear to be an hg repository") 109 raise error.RepoError(_("'%s' does not appear to be an hg repository")
110 % safeurl) 110 % safeurl)
111 111
112 if proto.startswith('application/mercurial-'): 112 if proto.startswith('application/mercurial-'):
113 try: 113 try: