##// END OF EJS Templates
make static-http work with empty repos (issue965)
Dirkjan Ochtman -
r6028:6605a03c default
parent child Browse files
Show More
@@ -9,14 +9,16 b''
9
9
10 from i18n import _
10 from i18n import _
11 import changelog, filelog, httprangereader
11 import changelog, filelog, httprangereader
12 import repo, localrepo, manifest, os, urllib, urllib2, util
12 import repo, localrepo, manifest, util
13 import urllib, urllib2, errno
13
14
14 class rangereader(httprangereader.httprangereader):
15 class rangereader(httprangereader.httprangereader):
15 def read(self, size=None):
16 def read(self, size=None):
16 try:
17 try:
17 return httprangereader.httprangereader.read(self, size)
18 return httprangereader.httprangereader.read(self, size)
18 except urllib2.HTTPError, inst:
19 except urllib2.HTTPError, inst:
19 raise IOError(None, inst)
20 num = inst.code == 404 and errno.ENOENT or None
21 raise IOError(num, inst)
20 except urllib2.URLError, inst:
22 except urllib2.URLError, inst:
21 raise IOError(None, inst.reason[1])
23 raise IOError(None, inst.reason[1])
22
24
@@ -35,11 +37,17 b' class statichttprepository(localrepo.loc'
35
37
36 self.path = path.rstrip('/') + "/.hg"
38 self.path = path.rstrip('/') + "/.hg"
37 self.opener = opener(self.path)
39 self.opener = opener(self.path)
40
38 # find requirements
41 # find requirements
39 try:
42 try:
40 requirements = self.opener("requires").read().splitlines()
43 requirements = self.opener("requires").read().splitlines()
41 except IOError:
44 except IOError, inst:
42 requirements = []
45 if inst.errno == errno.ENOENT:
46 msg = _("'%s' does not appear to be an hg repository") % path
47 raise repo.RepoError(msg)
48 else:
49 requirements = []
50
43 # check them
51 # check them
44 for r in requirements:
52 for r in requirements:
45 if r not in self.supported:
53 if r not in self.supported:
@@ -63,4 +63,19 b' hg verify'
63 cat a
63 cat a
64 hg paths | sed -e 's,:[0-9][0-9]*/,/,'
64 hg paths | sed -e 's,:[0-9][0-9]*/,/,'
65
65
66 echo '% test with empty repo (issue965)'
67 cd ..
68 hg init remotempty
69
70 http_proxy= hg clone static-http://localhost:$HGPORT/remotempty local3 | sed -e 's,:[0-9][0-9]*/,/,'
71
72 cd local3
73 hg verify
74 hg paths | sed -e 's,:[0-9][0-9]*/,/,'
75
76 echo '% test with non-repo'
77 cd ..
78 mkdir notarepo
79 http_proxy= hg clone static-http://localhost:$HGPORT/notarepo local3 2>&1 | sed -e 's,:[0-9][0-9]*/,/,'
80
66 kill $!
81 kill $!
@@ -42,3 +42,14 b' checking files'
42 1 files, 1 changesets, 1 total revisions
42 1 files, 1 changesets, 1 total revisions
43 a
43 a
44 default = static-http://localhost/
44 default = static-http://localhost/
45 % test with empty repo (issue965)
46 no changes found
47 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
48 checking changesets
49 checking manifests
50 crosschecking files in changesets and manifests
51 checking files
52 0 files, 0 changesets, 0 total revisions
53 default = static-http://localhost/remotempty
54 % test with non-repo
55 abort: 'http://localhost/notarepo' does not appear to be an hg repository!
General Comments 0
You need to be logged in to leave comments. Login now