diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -199,8 +199,8 @@ class bundlerepository(localrepo.localre else: raise util.Abort(_("%s: unknown bundle compression type") % bundlename) - self.changelog = bundlechangelog(self.opener, self.bundlefile) - self.manifest = bundlemanifest(self.opener, self.bundlefile, + self.changelog = bundlechangelog(self.sopener, self.bundlefile) + self.manifest = bundlemanifest(self.sopener, self.bundlefile, self.changelog.rev) # dict with the mapping 'filename' -> position in the bundle self.bundlefilespos = {} @@ -223,10 +223,10 @@ class bundlerepository(localrepo.localre f = f[1:] if f in self.bundlefilespos: self.bundlefile.seek(self.bundlefilespos[f]) - return bundlefilelog(self.opener, f, self.bundlefile, + return bundlefilelog(self.sopener, f, self.bundlefile, self.changelog.rev) else: - return filelog.filelog(self.opener, f) + return filelog.filelog(self.sopener, f) def close(self): """Close assigned bundle file immediately.""" diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -129,11 +129,9 @@ def clone(ui, source, dest=None, pull=Fa dest_repo = repository(ui, dest, create=True) - dest_path = None dir_cleanup = None if dest_repo.local(): - dest_path = os.path.realpath(dest_repo.root) - dir_cleanup = DirCleanup(dest_path) + dir_cleanup = DirCleanup(os.path.realpath(dest_repo.root)) abspath = source copy = False @@ -154,14 +152,16 @@ def clone(ui, source, dest=None, pull=Fa if copy: # we lock here to avoid premature writing to the target - dest_lock = lock.lock(os.path.join(dest_path, ".hg", "lock")) + src_store = os.path.realpath(src_repo.spath) + dest_store = os.path.realpath(dest_repo.spath) + dest_lock = lock.lock(os.path.join(dest_store, "lock")) files = ("data", "00manifest.d", "00manifest.i", "00changelog.d", "00changelog.i") for f in files: - src = os.path.join(source, ".hg", f) - dst = os.path.join(dest_path, ".hg", f) + src = os.path.join(src_store, f) + dst = os.path.join(dest_store, f) try: util.copyfiles(src, dst) except OSError, inst: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -31,12 +31,15 @@ class localrepository(repo.repository): " here (.hg not found)")) path = p self.path = os.path.join(path, ".hg") + self.spath = self.path if not os.path.isdir(self.path): if create: if not os.path.exists(path): os.mkdir(path) os.mkdir(self.path) + if self.spath != self.path: + os.mkdir(self.spath) else: raise repo.RepoError(_("repository %s not found") % path) elif create: @@ -46,7 +49,7 @@ class localrepository(repo.repository): self.origroot = path self.ui = ui.ui(parentui=parentui) self.opener = util.opener(self.path) - self.sopener = util.opener(self.path) + self.sopener = util.opener(self.spath) self.wopener = util.opener(self.root) try: @@ -395,7 +398,7 @@ class localrepository(repo.repository): return os.path.join(self.path, f) def sjoin(self, f): - return os.path.join(self.path, f) + return os.path.join(self.spath, f) def wjoin(self, f): return os.path.join(self.root, f) diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -33,12 +33,13 @@ class statichttprepository(localrepo.loc def __init__(self, ui, path): self._url = path self.path = (path + "/.hg") + self.spath = self.path self.ui = ui self.revlogversion = 0 self.opener = opener(self.path) - self.sopener = opener(self.path) - self.manifest = manifest.manifest(self.opener) - self.changelog = changelog.changelog(self.opener) + self.sopener = opener(self.spath) + self.manifest = manifest.manifest(self.sopener) + self.changelog = changelog.changelog(self.sopener) self.tagscache = None self.nodetagscache = None self.encodepats = None diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -78,7 +78,7 @@ def stream_out(repo, fileobj): repo.ui.debug('scanning\n') entries = [] total_bytes = 0 - for name, size in walkrepo(repo.path): + for name, size in walkrepo(repo.spath): entries.append((name, size)) total_bytes += size repolock.release() @@ -89,7 +89,7 @@ def stream_out(repo, fileobj): for name, size in entries: repo.ui.debug('sending %s (%d bytes)\n' % (name, size)) fileobj.write('%s\0%d\n' % (name, size)) - for chunk in util.filechunkiter(repo.opener(name), limit=size): + for chunk in util.filechunkiter(repo.sopener(name), limit=size): fileobj.write(chunk) flush = getattr(fileobj, 'flush', None) if flush: flush()