# HG changeset patch # User John Mulligan # Date 2008-03-15 16:04:28 # Node ID 9a1c59283ad3e0a6a408d69b3ad50839129a8931 # Parent c5580db9c3aa2e114170b69f1d10c1b198144db4 Add ability to directly clone from all-history bundles bundlerepos can be used as clone src, even if CWD is not a repo diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -12,8 +12,8 @@ of the GNU General Public License, incor 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 bundlefilelog(bundlerevlog, filelo 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 @@ class bundlerepository(localrepo.localre 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: