Show More
@@ -209,12 +209,12 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
209 | 209 | if isinstance(source, str): |
|
210 | 210 | origsource = ui.expandpath(source) |
|
211 | 211 | source, branch = parseurl(origsource, branch) |
|
212 |
src |
|
|
212 | srcrepo = repository(ui, source) | |
|
213 | 213 | else: |
|
214 |
src |
|
|
214 | srcrepo = source | |
|
215 | 215 | branch = (None, branch or []) |
|
216 |
origsource = source = src |
|
|
217 |
rev, checkout = addbranchrevs(src |
|
|
216 | origsource = source = srcrepo.url() | |
|
217 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branch, rev) | |
|
218 | 218 | |
|
219 | 219 | if dest is None: |
|
220 | 220 | dest = defaultdest(source) |
@@ -241,17 +241,17 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
241 | 241 | if self.dir_: |
|
242 | 242 | self.rmtree(self.dir_, True) |
|
243 | 243 | |
|
244 |
src |
|
|
244 | srclock = destlock = dircleanup = None | |
|
245 | 245 | try: |
|
246 | 246 | abspath = origsource |
|
247 | 247 | if islocal(origsource): |
|
248 | 248 | abspath = os.path.abspath(util.localpath(origsource)) |
|
249 | 249 | |
|
250 | 250 | if islocal(dest): |
|
251 |
dir |
|
|
251 | dircleanup = DirCleanup(dest) | |
|
252 | 252 | |
|
253 | 253 | copy = False |
|
254 |
if src |
|
|
254 | if srcrepo.cancopy() and islocal(dest): | |
|
255 | 255 | copy = not pull and not rev |
|
256 | 256 | |
|
257 | 257 | if copy: |
@@ -260,40 +260,40 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
260 | 260 | # can end up with extra data in the cloned revlogs that's |
|
261 | 261 | # not pointed to by changesets, thus causing verify to |
|
262 | 262 | # fail |
|
263 |
src |
|
|
263 | srclock = srcrepo.lock(wait=False) | |
|
264 | 264 | except error.LockError: |
|
265 | 265 | copy = False |
|
266 | 266 | |
|
267 | 267 | if copy: |
|
268 |
src |
|
|
268 | srcrepo.hook('preoutgoing', throw=True, source='clone') | |
|
269 | 269 | hgdir = os.path.realpath(os.path.join(dest, ".hg")) |
|
270 | 270 | if not os.path.exists(dest): |
|
271 | 271 | os.mkdir(dest) |
|
272 | 272 | else: |
|
273 | 273 | # only clean up directories we create ourselves |
|
274 |
dir |
|
|
274 | dircleanup.dir_ = hgdir | |
|
275 | 275 | try: |
|
276 |
dest |
|
|
277 |
util.makedir(dest |
|
|
276 | destpath = hgdir | |
|
277 | util.makedir(destpath, notindexed=True) | |
|
278 | 278 | except OSError, inst: |
|
279 | 279 | if inst.errno == errno.EEXIST: |
|
280 |
dir |
|
|
280 | dircleanup.close() | |
|
281 | 281 | raise util.Abort(_("destination '%s' already exists") |
|
282 | 282 | % dest) |
|
283 | 283 | raise |
|
284 | 284 | |
|
285 | 285 | hardlink = None |
|
286 | 286 | num = 0 |
|
287 |
for f in src |
|
|
288 |
src = os.path.join(src |
|
|
289 |
dst = os.path.join(dest |
|
|
287 | for f in srcrepo.store.copylist(): | |
|
288 | src = os.path.join(srcrepo.sharedpath, f) | |
|
289 | dst = os.path.join(destpath, f) | |
|
290 | 290 | dstbase = os.path.dirname(dst) |
|
291 | 291 | if dstbase and not os.path.exists(dstbase): |
|
292 | 292 | os.mkdir(dstbase) |
|
293 | 293 | if os.path.exists(src): |
|
294 | 294 | if dst.endswith('data'): |
|
295 | 295 | # lock to avoid premature writing to the target |
|
296 |
dest |
|
|
296 | destlock = lock.lock(os.path.join(dstbase, "lock")) | |
|
297 | 297 | hardlink, n = util.copyfiles(src, dst, hardlink) |
|
298 | 298 | num += n |
|
299 | 299 | if hardlink: |
@@ -303,82 +303,82 b' def clone(ui, source, dest=None, pull=Fa' | |||
|
303 | 303 | |
|
304 | 304 | # we need to re-init the repo after manually copying the data |
|
305 | 305 | # into it |
|
306 |
dest |
|
|
307 |
src |
|
|
306 | destrepo = repository(ui, dest) | |
|
307 | srcrepo.hook('outgoing', source='clone', | |
|
308 | 308 | node=node.hex(node.nullid)) |
|
309 | 309 | else: |
|
310 | 310 | try: |
|
311 |
dest |
|
|
311 | destrepo = repository(ui, dest, create=True) | |
|
312 | 312 | except OSError, inst: |
|
313 | 313 | if inst.errno == errno.EEXIST: |
|
314 |
dir |
|
|
314 | dircleanup.close() | |
|
315 | 315 | raise util.Abort(_("destination '%s' already exists") |
|
316 | 316 | % dest) |
|
317 | 317 | raise |
|
318 | 318 | |
|
319 | 319 | revs = None |
|
320 | 320 | if rev: |
|
321 |
if 'lookup' not in src |
|
|
321 | if 'lookup' not in srcrepo.capabilities: | |
|
322 | 322 | raise util.Abort(_("src repository does not support " |
|
323 | 323 | "revision lookup and so doesn't " |
|
324 | 324 | "support clone by revision")) |
|
325 |
revs = [src |
|
|
325 | revs = [srcrepo.lookup(r) for r in rev] | |
|
326 | 326 | checkout = revs[0] |
|
327 |
if dest |
|
|
328 |
dest |
|
|
329 |
elif src |
|
|
330 |
src |
|
|
327 | if destrepo.local(): | |
|
328 | destrepo.clone(srcrepo, heads=revs, stream=stream) | |
|
329 | elif srcrepo.local(): | |
|
330 | srcrepo.push(destrepo, revs=revs) | |
|
331 | 331 | else: |
|
332 | 332 | raise util.Abort(_("clone from remote to remote not supported")) |
|
333 | 333 | |
|
334 |
if dir |
|
|
335 |
dir |
|
|
334 | if dircleanup: | |
|
335 | dircleanup.close() | |
|
336 | 336 | |
|
337 |
if dest |
|
|
338 |
fp = dest |
|
|
337 | if destrepo.local(): | |
|
338 | fp = destrepo.opener("hgrc", "w", text=True) | |
|
339 | 339 | fp.write("[paths]\n") |
|
340 | 340 | fp.write("default = %s\n" % abspath) |
|
341 | 341 | fp.close() |
|
342 | 342 | |
|
343 |
dest |
|
|
343 | destrepo.ui.setconfig('paths', 'default', abspath) | |
|
344 | 344 | |
|
345 | 345 | if update: |
|
346 | 346 | if update is not True: |
|
347 | 347 | checkout = update |
|
348 |
if src |
|
|
349 |
checkout = src |
|
|
348 | if srcrepo.local(): | |
|
349 | checkout = srcrepo.lookup(update) | |
|
350 | 350 | for test in (checkout, 'default', 'tip'): |
|
351 | 351 | if test is None: |
|
352 | 352 | continue |
|
353 | 353 | try: |
|
354 |
uprev = dest |
|
|
354 | uprev = destrepo.lookup(test) | |
|
355 | 355 | break |
|
356 | 356 | except error.RepoLookupError: |
|
357 | 357 | continue |
|
358 |
bn = dest |
|
|
359 |
dest |
|
|
360 |
_update(dest |
|
|
358 | bn = destrepo[uprev].branch() | |
|
359 | destrepo.ui.status(_("updating to branch %s\n") % bn) | |
|
360 | _update(destrepo, uprev) | |
|
361 | 361 | |
|
362 | 362 | # clone all bookmarks |
|
363 |
if dest |
|
|
364 |
rb = src |
|
|
363 | if destrepo.local() and srcrepo.capable("pushkey"): | |
|
364 | rb = srcrepo.listkeys('bookmarks') | |
|
365 | 365 | for k, n in rb.iteritems(): |
|
366 | 366 | try: |
|
367 |
m = dest |
|
|
368 |
dest |
|
|
367 | m = destrepo.lookup(n) | |
|
368 | destrepo._bookmarks[k] = m | |
|
369 | 369 | except error.RepoLookupError: |
|
370 | 370 | pass |
|
371 | 371 | if rb: |
|
372 |
bookmarks.write(dest |
|
|
373 |
elif src |
|
|
374 |
for k, n in src |
|
|
375 |
dest |
|
|
372 | bookmarks.write(destrepo) | |
|
373 | elif srcrepo.local() and destrepo.capable("pushkey"): | |
|
374 | for k, n in srcrepo._bookmarks.iteritems(): | |
|
375 | destrepo.pushkey('bookmarks', k, '', hex(n)) | |
|
376 | 376 | |
|
377 |
return src |
|
|
377 | return srcrepo, destrepo | |
|
378 | 378 | finally: |
|
379 |
release(src |
|
|
380 |
if dir |
|
|
381 |
dir |
|
|
379 | release(srclock, destlock) | |
|
380 | if dircleanup is not None: | |
|
381 | dircleanup.cleanup() | |
|
382 | 382 | |
|
383 | 383 | def _showstats(repo, stats): |
|
384 | 384 | repo.ui.status(_("%d files updated, %d files merged, " |
General Comments 0
You need to be logged in to leave comments.
Login now