# HG changeset patch # User Bryan O'Sullivan # Date 1127459116 25200 # Node ID 57220daf40e9ee531617598161c1ce1efce71aa4 # Parent 60200b3fc83982cf383f7f16413b5770110ae70c Move urllib error handling from revlog into statichttprepo, where it belongs. diff -r 60200b3fc839 -r 57220daf40e9 mercurial/commands.py --- a/mercurial/commands.py Thu Sep 22 23:33:26 2005 -0700 +++ b/mercurial/commands.py Fri Sep 23 00:05:16 2005 -0700 @@ -2160,6 +2160,8 @@ u.warn("abort: %s\n" % inst) elif hasattr(inst, "reason"): u.warn("abort: error: %s\n" % inst.reason[1]) + elif getattr(inst, "strerror", None): + u.warn("abort: %s\n" % inst.strerror) elif hasattr(inst, "args") and inst[0] == errno.EPIPE: if u.debugflag: u.warn("broken pipe\n") diff -r 60200b3fc839 -r 57220daf40e9 mercurial/revlog.py --- a/mercurial/revlog.py Thu Sep 22 23:33:26 2005 -0700 +++ b/mercurial/revlog.py Fri Sep 23 00:05:16 2005 -0700 @@ -12,7 +12,7 @@ from node import * from demandload import demandload -demandload(globals(), "binascii errno heapq mdiff sha struct urllib2 zlib") +demandload(globals(), "binascii errno heapq mdiff sha struct zlib") def hash(text, p1, p2): """generate a hash from the given text and its parent hashes @@ -179,8 +179,6 @@ try: i = self.opener(self.indexfile).read() - except urllib2.URLError: - raise except IOError, inst: if inst.errno != errno.ENOENT: raise diff -r 60200b3fc839 -r 57220daf40e9 mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py Thu Sep 22 23:33:26 2005 -0700 +++ b/mercurial/statichttprepo.py Fri Sep 23 00:05:16 2005 -0700 @@ -7,15 +7,23 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, urllib -import localrepo, httprangereader, filelog, manifest, changelog +from demandload import demandload +demandload(globals(), "changelog filelog httprangereader") +demandload(globals(), "localrepo manifest os urllib urllib2") + +class rangereader(httprangereader.httprangereader): + def read(self, size=None): + try: + return httprangereader.httprangereader.read(self, size) + except urllib2.URLError, inst: + raise IOError(None, str(inst)) def opener(base): """return a function that opens files over http""" p = base def o(path, mode="r"): f = os.path.join(p, urllib.quote(path)) - return httprangereader.httprangereader(f) + return rangereader(f) return o class statichttprepository(localrepo.localrepository):