147 src_lock = src_repo.lock() |
147 src_lock = src_repo.lock() |
148 except lock.LockException: |
148 except lock.LockException: |
149 copy = False |
149 copy = False |
150 |
150 |
151 if copy: |
151 if copy: |
152 # we lock here to avoid premature writing to the target |
152 def force_copy(src, dst): |
|
153 try: |
|
154 util.copyfiles(src, dst) |
|
155 except OSError, inst: |
|
156 if inst.errno != errno.ENOENT: |
|
157 raise |
|
158 |
153 src_store = os.path.realpath(src_repo.spath) |
159 src_store = os.path.realpath(src_repo.spath) |
154 dest_path = os.path.realpath(os.path.join(dest, ".hg")) |
160 dest_path = os.path.realpath(os.path.join(dest, ".hg")) |
155 dest_store = dest_path |
161 dest_store = dest_path |
156 if not os.path.exists(dest): |
162 if not os.path.exists(dest): |
157 os.mkdir(dest) |
163 os.mkdir(dest) |
158 os.mkdir(dest_path) |
164 os.mkdir(dest_path) |
|
165 # copy the requires file |
|
166 force_copy(src_repo.join("requires"), |
|
167 os.path.join(dest_path, "requires")) |
|
168 # we lock here to avoid premature writing to the target |
159 dest_lock = lock.lock(os.path.join(dest_store, "lock")) |
169 dest_lock = lock.lock(os.path.join(dest_store, "lock")) |
160 |
170 |
161 files = ("data", |
171 files = ("data", |
162 "00manifest.d", "00manifest.i", |
172 "00manifest.d", "00manifest.i", |
163 "00changelog.d", "00changelog.i") |
173 "00changelog.d", "00changelog.i") |
164 for f in files: |
174 for f in files: |
165 src = os.path.join(src_store, f) |
175 src = os.path.join(src_store, f) |
166 dst = os.path.join(dest_store, f) |
176 dst = os.path.join(dest_store, f) |
167 try: |
177 force_copy(src, dst) |
168 util.copyfiles(src, dst) |
|
169 except OSError, inst: |
|
170 if inst.errno != errno.ENOENT: |
|
171 raise |
|
172 |
178 |
173 # we need to re-init the repo after manually copying the data |
179 # we need to re-init the repo after manually copying the data |
174 # into it |
180 # into it |
175 dest_repo = repository(ui, dest) |
181 dest_repo = repository(ui, dest) |
176 |
182 |