##// END OF EJS Templates
clone: get a list of files to clone from store
Matt Mackall -
r6903:0642d9d7 default
parent child Browse files
Show More
@@ -164,13 +164,6 b' def clone(ui, source, dest=None, pull=Fa'
164 copy = False
164 copy = False
165
165
166 if copy:
166 if copy:
167 def force_copy(src, dst):
168 if not os.path.exists(src):
169 # Tolerate empty source repository and optional files
170 return
171 util.copyfiles(src, dst)
172
173 src_store = os.path.realpath(src_repo.spath)
174 if not os.path.exists(dest):
167 if not os.path.exists(dest):
175 os.mkdir(dest)
168 os.mkdir(dest)
176 try:
169 try:
@@ -182,28 +175,18 b' def clone(ui, source, dest=None, pull=Fa'
182 raise util.Abort(_("destination '%s' already exists")
175 raise util.Abort(_("destination '%s' already exists")
183 % dest)
176 % dest)
184 raise
177 raise
185 if src_repo.spath != src_repo.path:
186 # XXX racy
187 dummy_changelog = os.path.join(dest_path, "00changelog.i")
188 # copy the dummy changelog
189 force_copy(src_repo.join("00changelog.i"), dummy_changelog)
190 dest_store = os.path.join(dest_path, "store")
191 os.mkdir(dest_store)
192 else:
193 dest_store = dest_path
194 # copy the requires file
195 force_copy(src_repo.join("requires"),
196 os.path.join(dest_path, "requires"))
197 # we lock here to avoid premature writing to the target
198 dest_lock = lock.lock(os.path.join(dest_store, "lock"))
199
178
200 files = ("data",
179 for f in src_repo.store.copylist():
201 "00manifest.d", "00manifest.i",
180 src = os.path.join(src_repo.path, f)
202 "00changelog.d", "00changelog.i")
181 if os.path.exists(src):
203 for f in files:
182 dst = os.path.join(dest_path, f)
204 src = os.path.join(src_store, f)
183 dstbase = os.path.dirname(dst)
205 dst = os.path.join(dest_store, f)
184 if not os.path.exists(dstbase):
206 force_copy(src, dst)
185 os.mkdir(dstbase)
186 if dst.endswith('data'):
187 # lock to avoid premature writing to the target
188 dest_lock = lock.lock(os.path.join(dstbase, "lock"))
189 util.copyfiles(src, dst)
207
190
208 # we need to re-init the repo after manually copying the data
191 # we need to re-init the repo after manually copying the data
209 # into it
192 # into it
@@ -46,6 +46,8 b' def _calcmode(path):'
46 mode = None
46 mode = None
47 return mode
47 return mode
48
48
49 _data = 'data 00manifest.d 00manifest.i 00changelog.d 00changelog.i'
50
49 class basicstore:
51 class basicstore:
50 '''base class for local repository stores'''
52 '''base class for local repository stores'''
51 def __init__(self, path, opener):
53 def __init__(self, path, opener):
@@ -90,6 +92,9 b' class basicstore:'
90 for x in meta:
92 for x in meta:
91 yield x
93 yield x
92
94
95 def copylist(self):
96 return ['requires'] + _data.split()
97
93 class encodedstore(basicstore):
98 class encodedstore(basicstore):
94 def __init__(self, path, opener):
99 def __init__(self, path, opener):
95 self.path = os.path.join(path, 'store')
100 self.path = os.path.join(path, 'store')
@@ -109,6 +114,10 b' class encodedstore(basicstore):'
109 def join(self, f):
114 def join(self, f):
110 return os.path.join(self.path, encodefilename(f))
115 return os.path.join(self.path, encodefilename(f))
111
116
117 def copylist(self):
118 return (['requires', '00changelog.i'] +
119 ['store/' + f for f in _data.split()])
120
112 def store(requirements, path, opener):
121 def store(requirements, path, opener):
113 if 'store' in requirements:
122 if 'store' in requirements:
114 return encodedstore(path, opener)
123 return encodedstore(path, opener)
General Comments 0
You need to be logged in to leave comments. Login now