[PATCH] make static-http work with empty repos (issue965)

Dirkjan Ochtman dirkjan at ochtman.nl
Thu Feb 7 11:21:10 CST 2008


# HG changeset patch
# User Dirkjan Ochtman <dirkjan at ochtman.nl>
# Date 1202386845 -3600
# Node ID f89f7ecf017ec0c9a92d466aa682c737e98f8190
# Parent  9360a58a09e6aa11d76a572304eafc6f5c765551
make static-http work with empty repos (issue965)

diff -r 9360a58a09e6 -r f89f7ecf017e mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py	Thu Feb 07 12:31:29 2008 +0100
+++ b/mercurial/statichttprepo.py	Thu Feb 07 13:20:45 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])
 
diff -r 9360a58a09e6 -r f89f7ecf017e tests/test-static-http
--- a/tests/test-static-http	Thu Feb 07 12:31:29 2008 +0100
+++ b/tests/test-static-http	Thu Feb 07 13:20:45 2008 +0100
@@ -63,4 +63,14 @@
 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]*/,/,'
+
 kill $!
diff -r 9360a58a09e6 -r f89f7ecf017e tests/test-static-http.out
--- a/tests/test-static-http.out	Thu Feb 07 12:31:29 2008 +0100
+++ b/tests/test-static-http.out	Thu Feb 07 13:20:45 2008 +0100
@@ -42,3 +42,12 @@
 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


More information about the Mercurial-devel mailing list