changeset 6314:9a1c59283ad3

Add ability to directly clone from all-history bundles bundlerepos can be used as clone src, even if CWD is not a repo
author John Mulligan <phlogistonjohn@asynchrono.us>
date Sat, 15 Mar 2008 12:04:28 -0400
parents c5580db9c3aa
children 5c96a4bca66b
files mercurial/bundlerepo.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundlerepo.py	Thu Mar 20 11:12:35 2008 -0500
+++ b/mercurial/bundlerepo.py	Sat Mar 15 12:04:28 2008 -0400
@@ -12,8 +12,8 @@
 
 from node import hex, nullid, short
 from i18n import _
-import changegroup, util, os, struct, bz2, tempfile, mdiff
-import localrepo, changelog, manifest, filelog, revlog
+import changegroup, util, os, struct, bz2, tempfile, shutil, mdiff
+import repo, localrepo, changelog, manifest, filelog, revlog
 
 class bundlerevlog(revlog.revlog):
     def __init__(self, opener, indexfile, bundlefile,
@@ -153,7 +153,13 @@
 
 class bundlerepository(localrepo.localrepository):
     def __init__(self, ui, path, bundlename):
-        localrepo.localrepository.__init__(self, ui, path)
+        self._tempparent = None
+        try:
+            localrepo.localrepository.__init__(self, ui, path)
+        except repo.RepoError:
+            self._tempparent = tempfile.mkdtemp()
+            tmprepo = localrepo.instance(ui,self._tempparent,1)
+            localrepo.localrepository.__init__(self, ui, self._tempparent)
 
         if path:
             self._url = 'bundle:' + path + '+' + bundlename
@@ -252,6 +258,8 @@
         tempfile = getattr(self, 'tempfile', None)
         if tempfile is not None:
             os.unlink(tempfile)
+        if self._tempparent:
+            shutil.rmtree(self._tempparent, True)
 
 def instance(ui, path, create):
     if create: