--- a/mercurial/hg.py Sat Aug 27 14:21:25 2005 -0700
+++ b/mercurial/hg.py Sat Aug 27 14:31:41 2005 -0700
@@ -13,34 +13,6 @@
from demandload import *
demandload(globals(), "localrepo httprepo sshrepo")
-# used to avoid circular references so destructors work
-def opener(base):
- p = base
- def o(path, mode="r"):
- if p.startswith("http://"):
- f = os.path.join(p, urllib.quote(path))
- return httprangereader.httprangereader(f)
-
- f = os.path.join(p, path)
-
- mode += "b" # for that other OS
-
- if mode[0] != "r":
- try:
- s = os.stat(f)
- except OSError:
- d = os.path.dirname(f)
- if not os.path.isdir(d):
- os.makedirs(d)
- else:
- if s.st_nlink > 1:
- file(f + ".tmp", "wb").write(file(f, "rb").read())
- util.rename(f+".tmp", f)
-
- return file(f, mode)
-
- return o
-
def repository(ui, path=None, create=0):
if path:
if path.startswith("http://"):
@@ -52,8 +24,8 @@
ui, path.replace("hg://", "http://"))
if path.startswith("old-http://"):
return localrepo.localrepository(
- ui, opener, path.replace("old-http://", "http://"))
+ ui, util.opener, path.replace("old-http://", "http://"))
if path.startswith("ssh://"):
return sshrepo.sshrepository(ui, path)
- return localrepo.localrepository(ui, opener, path, create)
+ return localrepo.localrepository(ui, util.opener, path, create)