diff mercurial/statichttprepo.py @ 2956:6dddcba7596a

merge.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 18 Aug 2006 21:17:28 -0700
parents 345bac2bc4ec
children ff06fe0703ef
line wrap: on
line diff
--- a/mercurial/statichttprepo.py	Sun Jul 23 09:04:14 2006 -0700
+++ b/mercurial/statichttprepo.py	Fri Aug 18 21:17:28 2006 -0700
@@ -2,14 +2,15 @@
 #
 # This provides read-only repo access to repositories exported via static http
 #
-# Copyright 2005 Matt Mackall <mpm@selenic.com>
+# Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
 #
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-from demandload import demandload
+from demandload import *
+from i18n import gettext as _
 demandload(globals(), "changelog filelog httprangereader")
-demandload(globals(), "localrepo manifest os urllib urllib2")
+demandload(globals(), "localrepo manifest os urllib urllib2 util")
 
 class rangereader(httprangereader.httprangereader):
     def read(self, size=None):
@@ -30,6 +31,7 @@
 
 class statichttprepository(localrepo.localrepository):
     def __init__(self, ui, path):
+        self._url = path
         self.path = (path + "/.hg")
         self.ui = ui
         self.revlogversion = 0
@@ -41,8 +43,22 @@
         self.encodepats = None
         self.decodepats = None
 
+    def url(self):
+        return 'static-' + self._url
+
     def dev(self):
         return -1
 
     def local(self):
         return False
+
+def instance(ui, path, create):
+    if create:
+        raise util.Abort(_('cannot create new static-http repository'))
+    if path.startswith('old-http:'):
+        ui.warn(_("old-http:// syntax is deprecated, "
+                  "please use static-http:// instead\n"))
+        path = path[4:]
+    else:
+        path = path[7:]
+    return statichttprepository(ui, path)