[PATCH] Add ability to clone from all-history bundles
John Mulligan
phlogistonjohn at asynchrono.us
Mon Mar 10 23:30:16 UTC 2008
try #2
# HG changeset patch
# User John Mulligan <phlogistonjohn at asynchrono.us>
# Date 1205190859 14400
# Node ID 9f3ed715452ea1b726a682b98432b886c7d333f1
# Parent d2353ed8b153eb38dc804b704aa73b7edd4315bb
Add ability to clone from all-history bundles
- Don't copy a bundle like a normal localrepo on clone
- bundlerepos can be cloned from, 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 @@
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,
@@ -152,7 +152,13 @@
class bundlerepository(localrepo.localrepository):
def __init__(self, ui, path, bundlename):
- localrepo.localrepository.__init__(self, ui, path)
+ _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
@@ -254,6 +260,9 @@
tempfile = getattr(self, 'tempfile', None)
if tempfile is not None:
os.unlink(tempfile)
+ tempparent = getattr(self, '_tempparent', None)
+ if tempparent:
+ shutil.rmtree(tempparent, True)
def instance(ui, path, create):
if create:
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -148,7 +148,8 @@
abspath = origsource
copy = False
- if src_repo.local() and islocal(dest):
+ bundlesrc = isinstance(src_repo, bundlerepo.bundlerepository)
+ if src_repo.local() and islocal(dest) and not bundlesrc:
abspath = os.path.abspath(util.drop_scheme('file', origsource))
copy = not pull and not rev
More information about the Mercurial-devel
mailing list