Mercurial > hg-stable
changeset 6028:6605a03cbf87
make static-http work with empty repos (issue965)
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 08 Feb 2008 11:50:37 +0100 |
parents | cee68264ed92 |
children | 5b6190dfb344 012ad48a07fa |
files | mercurial/statichttprepo.py tests/test-static-http tests/test-static-http.out |
diffstat | 3 files changed, 38 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/statichttprepo.py Wed Feb 06 23:09:13 2008 +0100 +++ b/mercurial/statichttprepo.py Fri Feb 08 11:50:37 2008 +0100 @@ -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 @@ 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:
--- a/tests/test-static-http Wed Feb 06 23:09:13 2008 +0100 +++ b/tests/test-static-http Fri Feb 08 11:50:37 2008 +0100 @@ -63,4 +63,19 @@ 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 $!
--- a/tests/test-static-http.out Wed Feb 06 23:09:13 2008 +0100 +++ b/tests/test-static-http.out Fri Feb 08 11:50:37 2008 +0100 @@ -42,3 +42,14 @@ 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!