Mercurial > hg-stable
changeset 1325:57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Fri, 23 Sep 2005 00:05:16 -0700 |
parents | 60200b3fc839 |
children | 76b2c7096d08 |
files | mercurial/commands.py mercurial/revlog.py mercurial/statichttprepo.py |
diffstat | 3 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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")
--- 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
--- 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):