333 raise error.Abort(_("src repository does not support " |
333 raise error.Abort(_("src repository does not support " |
334 "revision lookup and so doesn't " |
334 "revision lookup and so doesn't " |
335 "support clone by revision")) |
335 "support clone by revision")) |
336 revs = [srcpeer.lookup(r) for r in rev] |
336 revs = [srcpeer.lookup(r) for r in rev] |
337 |
337 |
|
338 # Obtain a lock before checking for or cloning the pooled repo otherwise |
|
339 # 2 clients may race creating or populating it. |
|
340 pooldir = os.path.dirname(sharepath) |
|
341 # lock class requires the directory to exist. |
|
342 try: |
|
343 util.makedir(pooldir, False) |
|
344 except OSError as e: |
|
345 if e.errno != errno.EEXIST: |
|
346 raise |
|
347 |
|
348 poolvfs = scmutil.vfs(pooldir) |
338 basename = os.path.basename(sharepath) |
349 basename = os.path.basename(sharepath) |
339 |
350 |
340 if os.path.exists(sharepath): |
351 with lock.lock(poolvfs, '%s.lock' % basename): |
341 ui.status(_('(sharing from existing pooled repository %s)\n') % |
352 if os.path.exists(sharepath): |
342 basename) |
353 ui.status(_('(sharing from existing pooled repository %s)\n') % |
343 else: |
354 basename) |
344 ui.status(_('(sharing from new pooled repository %s)\n') % basename) |
355 else: |
345 # Always use pull mode because hardlinks in share mode don't work well. |
356 ui.status(_('(sharing from new pooled repository %s)\n') % basename) |
346 # Never update because working copies aren't necessary in share mode. |
357 # Always use pull mode because hardlinks in share mode don't work |
347 clone(ui, peeropts, source, dest=sharepath, pull=True, |
358 # well. Never update because working copies aren't necessary in |
348 rev=rev, update=False, stream=stream) |
359 # share mode. |
|
360 clone(ui, peeropts, source, dest=sharepath, pull=True, |
|
361 rev=rev, update=False, stream=stream) |
349 |
362 |
350 sharerepo = repository(ui, path=sharepath) |
363 sharerepo = repository(ui, path=sharepath) |
351 share(ui, sharerepo, dest=dest, update=update, bookmarks=False) |
364 share(ui, sharerepo, dest=dest, update=update, bookmarks=False) |
352 |
365 |
353 # We need to perform a pull against the dest repo to fetch bookmarks |
366 # We need to perform a pull against the dest repo to fetch bookmarks |