diff mercurial/bundlerepo.py @ 2740:386f04d6ecb3

clean up hg.py: move repo constructor code into each repo module
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Mon, 31 Jul 2006 07:11:12 -0700
parents 109a22f5434a
children b19360aa21e9
line wrap: on
line diff
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -237,3 +237,18 @@ class bundlerepository(localrepo.localre
             self.bundlefile.close()
         if self.tempfile is not None:
             os.unlink(self.tempfile)
+
+def instance(ui, path, create):
+    if create:
+        raise util.Abort(_('cannot create new bundle repository'))
+    path = util.drop_scheme('file', path)
+    if path.startswith('bundle:'):
+        path = util.drop_scheme('bundle', path)
+        s = path.split("+", 1)
+        if len(s) == 1:
+            repopath, bundlename = "", s[0]
+        else:
+            repopath, bundlename = s
+    else:
+        repopath, bundlename = '', path
+    return bundlerepository(ui, repopath, bundlename)