[PATCH 2 of 5] introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot
benoit.boissinot at ens-lyon.org
Fri Dec 1 11:35:31 UTC 2006
# HG changeset patch
# User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
# Date 1164964906 -3600
# Node ID e6ff1d2c0b87ced2253581c0cd156a74f84fc3a3
# Parent 5ba7c5033cabef68382b157c11324d15f397e44c
introduce localrepo.spath for the store path, sopener fixes
diff -r 5ba7c5033cab -r e6ff1d2c0b87 mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py Fri Dec 01 10:20:07 2006 +0100
+++ b/mercurial/bundlerepo.py Fri Dec 01 10:21:46 2006 +0100
@@ -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 -r 5ba7c5033cab -r e6ff1d2c0b87 mercurial/hg.py
--- a/mercurial/hg.py Fri Dec 01 10:20:07 2006 +0100
+++ b/mercurial/hg.py Fri Dec 01 10:21:46 2006 +0100
@@ -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 -r 5ba7c5033cab -r e6ff1d2c0b87 mercurial/localrepo.py
--- a/mercurial/localrepo.py Fri Dec 01 10:20:07 2006 +0100
+++ b/mercurial/localrepo.py Fri Dec 01 10:21:46 2006 +0100
@@ -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:
@@ -382,7 +385,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 -r 5ba7c5033cab -r e6ff1d2c0b87 mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py Fri Dec 01 10:20:07 2006 +0100
+++ b/mercurial/statichttprepo.py Fri Dec 01 10:21:46 2006 +0100
@@ -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 -r 5ba7c5033cab -r e6ff1d2c0b87 mercurial/streamclone.py
--- a/mercurial/streamclone.py Fri Dec 01 10:20:07 2006 +0100
+++ b/mercurial/streamclone.py Fri Dec 01 10:21:46 2006 +0100
@@ -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()
More information about the Mercurial-devel
mailing list