diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -9,14 +9,16 @@ from i18n import _ import changelog, filelog, httprangereader -import repo, localrepo, manifest, os, urllib, urllib2, util +import repo, localrepo, manifest, util +import urllib, urllib2, errno class rangereader(httprangereader.httprangereader): def read(self, size=None): try: return httprangereader.httprangereader.read(self, size) except urllib2.HTTPError, inst: - raise IOError(None, inst) + num = inst.code == 404 and errno.ENOENT or None + raise IOError(num, inst) except urllib2.URLError, inst: raise IOError(None, inst.reason[1]) @@ -35,11 +37,17 @@ class statichttprepository(localrepo.loc self.path = path.rstrip('/') + "/.hg" self.opener = opener(self.path) + # find requirements try: requirements = self.opener("requires").read().splitlines() - except IOError: - requirements = [] + except IOError, inst: + if inst.errno == errno.ENOENT: + msg = _("'%s' does not appear to be an hg repository") % path + raise repo.RepoError(msg) + else: + requirements = [] + # check them for r in requirements: if r not in self.supported: diff --git a/tests/test-static-http b/tests/test-static-http --- a/tests/test-static-http +++ b/tests/test-static-http @@ -63,4 +63,19 @@ hg verify cat a hg paths | sed -e 's,:[0-9][0-9]*/,/,' +echo '% test with empty repo (issue965)' +cd .. +hg init remotempty + +http_proxy= hg clone static-http://localhost:$HGPORT/remotempty local3 | sed -e 's,:[0-9][0-9]*/,/,' + +cd local3 +hg verify +hg paths | sed -e 's,:[0-9][0-9]*/,/,' + +echo '% test with non-repo' +cd .. +mkdir notarepo +http_proxy= hg clone static-http://localhost:$HGPORT/notarepo local3 2>&1 | sed -e 's,:[0-9][0-9]*/,/,' + kill $! diff --git a/tests/test-static-http.out b/tests/test-static-http.out --- a/tests/test-static-http.out +++ b/tests/test-static-http.out @@ -42,3 +42,14 @@ checking files 1 files, 1 changesets, 1 total revisions a default = static-http://localhost/ +% test with empty repo (issue965) +no changes found +0 files updated, 0 files merged, 0 files removed, 0 files unresolved +checking changesets +checking manifests +crosschecking files in changesets and manifests +checking files +0 files, 0 changesets, 0 total revisions +default = static-http://localhost/remotempty +% test with non-repo +abort: 'http://localhost/notarepo' does not appear to be an hg repository!