##// END OF EJS Templates
introduce localrepo.spath for the store path, sopener fixes
Benoit Boissinot -
r3791:8643b9f9 default
parent child Browse files
Show More
@@ -199,8 +199,8 b' class bundlerepository(localrepo.localre'
199 else:
199 else:
200 raise util.Abort(_("%s: unknown bundle compression type")
200 raise util.Abort(_("%s: unknown bundle compression type")
201 % bundlename)
201 % bundlename)
202 self.changelog = bundlechangelog(self.opener, self.bundlefile)
202 self.changelog = bundlechangelog(self.sopener, self.bundlefile)
203 self.manifest = bundlemanifest(self.opener, self.bundlefile,
203 self.manifest = bundlemanifest(self.sopener, self.bundlefile,
204 self.changelog.rev)
204 self.changelog.rev)
205 # dict with the mapping 'filename' -> position in the bundle
205 # dict with the mapping 'filename' -> position in the bundle
206 self.bundlefilespos = {}
206 self.bundlefilespos = {}
@@ -223,10 +223,10 b' class bundlerepository(localrepo.localre'
223 f = f[1:]
223 f = f[1:]
224 if f in self.bundlefilespos:
224 if f in self.bundlefilespos:
225 self.bundlefile.seek(self.bundlefilespos[f])
225 self.bundlefile.seek(self.bundlefilespos[f])
226 return bundlefilelog(self.opener, f, self.bundlefile,
226 return bundlefilelog(self.sopener, f, self.bundlefile,
227 self.changelog.rev)
227 self.changelog.rev)
228 else:
228 else:
229 return filelog.filelog(self.opener, f)
229 return filelog.filelog(self.sopener, f)
230
230
231 def close(self):
231 def close(self):
232 """Close assigned bundle file immediately."""
232 """Close assigned bundle file immediately."""
@@ -129,11 +129,9 b' def clone(ui, source, dest=None, pull=Fa'
129
129
130 dest_repo = repository(ui, dest, create=True)
130 dest_repo = repository(ui, dest, create=True)
131
131
132 dest_path = None
133 dir_cleanup = None
132 dir_cleanup = None
134 if dest_repo.local():
133 if dest_repo.local():
135 dest_path = os.path.realpath(dest_repo.root)
134 dir_cleanup = DirCleanup(os.path.realpath(dest_repo.root))
136 dir_cleanup = DirCleanup(dest_path)
137
135
138 abspath = source
136 abspath = source
139 copy = False
137 copy = False
@@ -154,14 +152,16 b' def clone(ui, source, dest=None, pull=Fa'
154
152
155 if copy:
153 if copy:
156 # we lock here to avoid premature writing to the target
154 # we lock here to avoid premature writing to the target
157 dest_lock = lock.lock(os.path.join(dest_path, ".hg", "lock"))
155 src_store = os.path.realpath(src_repo.spath)
156 dest_store = os.path.realpath(dest_repo.spath)
157 dest_lock = lock.lock(os.path.join(dest_store, "lock"))
158
158
159 files = ("data",
159 files = ("data",
160 "00manifest.d", "00manifest.i",
160 "00manifest.d", "00manifest.i",
161 "00changelog.d", "00changelog.i")
161 "00changelog.d", "00changelog.i")
162 for f in files:
162 for f in files:
163 src = os.path.join(source, ".hg", f)
163 src = os.path.join(src_store, f)
164 dst = os.path.join(dest_path, ".hg", f)
164 dst = os.path.join(dest_store, f)
165 try:
165 try:
166 util.copyfiles(src, dst)
166 util.copyfiles(src, dst)
167 except OSError, inst:
167 except OSError, inst:
@@ -31,12 +31,15 b' class localrepository(repo.repository):'
31 " here (.hg not found)"))
31 " here (.hg not found)"))
32 path = p
32 path = p
33 self.path = os.path.join(path, ".hg")
33 self.path = os.path.join(path, ".hg")
34 self.spath = self.path
34
35
35 if not os.path.isdir(self.path):
36 if not os.path.isdir(self.path):
36 if create:
37 if create:
37 if not os.path.exists(path):
38 if not os.path.exists(path):
38 os.mkdir(path)
39 os.mkdir(path)
39 os.mkdir(self.path)
40 os.mkdir(self.path)
41 if self.spath != self.path:
42 os.mkdir(self.spath)
40 else:
43 else:
41 raise repo.RepoError(_("repository %s not found") % path)
44 raise repo.RepoError(_("repository %s not found") % path)
42 elif create:
45 elif create:
@@ -46,7 +49,7 b' class localrepository(repo.repository):'
46 self.origroot = path
49 self.origroot = path
47 self.ui = ui.ui(parentui=parentui)
50 self.ui = ui.ui(parentui=parentui)
48 self.opener = util.opener(self.path)
51 self.opener = util.opener(self.path)
49 self.sopener = util.opener(self.path)
52 self.sopener = util.opener(self.spath)
50 self.wopener = util.opener(self.root)
53 self.wopener = util.opener(self.root)
51
54
52 try:
55 try:
@@ -395,7 +398,7 b' class localrepository(repo.repository):'
395 return os.path.join(self.path, f)
398 return os.path.join(self.path, f)
396
399
397 def sjoin(self, f):
400 def sjoin(self, f):
398 return os.path.join(self.path, f)
401 return os.path.join(self.spath, f)
399
402
400 def wjoin(self, f):
403 def wjoin(self, f):
401 return os.path.join(self.root, f)
404 return os.path.join(self.root, f)
@@ -33,12 +33,13 b' class statichttprepository(localrepo.loc'
33 def __init__(self, ui, path):
33 def __init__(self, ui, path):
34 self._url = path
34 self._url = path
35 self.path = (path + "/.hg")
35 self.path = (path + "/.hg")
36 self.spath = self.path
36 self.ui = ui
37 self.ui = ui
37 self.revlogversion = 0
38 self.revlogversion = 0
38 self.opener = opener(self.path)
39 self.opener = opener(self.path)
39 self.sopener = opener(self.path)
40 self.sopener = opener(self.spath)
40 self.manifest = manifest.manifest(self.opener)
41 self.manifest = manifest.manifest(self.sopener)
41 self.changelog = changelog.changelog(self.opener)
42 self.changelog = changelog.changelog(self.sopener)
42 self.tagscache = None
43 self.tagscache = None
43 self.nodetagscache = None
44 self.nodetagscache = None
44 self.encodepats = None
45 self.encodepats = None
@@ -78,7 +78,7 b' def stream_out(repo, fileobj):'
78 repo.ui.debug('scanning\n')
78 repo.ui.debug('scanning\n')
79 entries = []
79 entries = []
80 total_bytes = 0
80 total_bytes = 0
81 for name, size in walkrepo(repo.path):
81 for name, size in walkrepo(repo.spath):
82 entries.append((name, size))
82 entries.append((name, size))
83 total_bytes += size
83 total_bytes += size
84 repolock.release()
84 repolock.release()
@@ -89,7 +89,7 b' def stream_out(repo, fileobj):'
89 for name, size in entries:
89 for name, size in entries:
90 repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
90 repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
91 fileobj.write('%s\0%d\n' % (name, size))
91 fileobj.write('%s\0%d\n' % (name, size))
92 for chunk in util.filechunkiter(repo.opener(name), limit=size):
92 for chunk in util.filechunkiter(repo.sopener(name), limit=size):
93 fileobj.write(chunk)
93 fileobj.write(chunk)
94 flush = getattr(fileobj, 'flush', None)
94 flush = getattr(fileobj, 'flush', None)
95 if flush: flush()
95 if flush: flush()
General Comments 0
You need to be logged in to leave comments. Login now