Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 6903:0642d9d7ec80
clone: get a list of files to clone from store
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 13 Aug 2008 20:18:44 -0500 |
parents | cfeeac24fc1e |
children | 7e5f3480c45b |
comparison
equal
deleted
inserted
replaced
6902:93f761c25dea | 6903:0642d9d7ec80 |
---|---|
162 src_lock = src_repo.lock() | 162 src_lock = src_repo.lock() |
163 except lock.LockException: | 163 except lock.LockException: |
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: |
177 dest_path = os.path.realpath(os.path.join(dest, ".hg")) | 170 dest_path = os.path.realpath(os.path.join(dest, ".hg")) |
178 os.mkdir(dest_path) | 171 os.mkdir(dest_path) |
180 if inst.errno == errno.EEXIST: | 173 if inst.errno == errno.EEXIST: |
181 dir_cleanup.close() | 174 dir_cleanup.close() |
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: | 178 |
186 # XXX racy | 179 for f in src_repo.store.copylist(): |
187 dummy_changelog = os.path.join(dest_path, "00changelog.i") | 180 src = os.path.join(src_repo.path, f) |
188 # copy the dummy changelog | 181 if os.path.exists(src): |
189 force_copy(src_repo.join("00changelog.i"), dummy_changelog) | 182 dst = os.path.join(dest_path, f) |
190 dest_store = os.path.join(dest_path, "store") | 183 dstbase = os.path.dirname(dst) |
191 os.mkdir(dest_store) | 184 if not os.path.exists(dstbase): |
192 else: | 185 os.mkdir(dstbase) |
193 dest_store = dest_path | 186 if dst.endswith('data'): |
194 # copy the requires file | 187 # lock to avoid premature writing to the target |
195 force_copy(src_repo.join("requires"), | 188 dest_lock = lock.lock(os.path.join(dstbase, "lock")) |
196 os.path.join(dest_path, "requires")) | 189 util.copyfiles(src, dst) |
197 # we lock here to avoid premature writing to the target | |
198 dest_lock = lock.lock(os.path.join(dest_store, "lock")) | |
199 | |
200 files = ("data", | |
201 "00manifest.d", "00manifest.i", | |
202 "00changelog.d", "00changelog.i") | |
203 for f in files: | |
204 src = os.path.join(src_store, f) | |
205 dst = os.path.join(dest_store, f) | |
206 force_copy(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 |
210 dest_repo = repository(ui, dest) | 193 dest_repo = repository(ui, dest) |
211 | 194 |