496 # both it and our ``bundlerepository`` class which overrides some |
496 # both it and our ``bundlerepository`` class which overrides some |
497 # functionality. We then change the type of the constructed repository |
497 # functionality. We then change the type of the constructed repository |
498 # to this new type and initialize the bundle-specific bits of it. |
498 # to this new type and initialize the bundle-specific bits of it. |
499 |
499 |
500 try: |
500 try: |
501 parentrepo = localrepo.instance(ui, repopath, create=False) |
501 repo = localrepo.instance(ui, repopath, create=False) |
502 tempparent = None |
502 tempparent = None |
503 except error.RepoError: |
503 except error.RepoError: |
504 tempparent = pycompat.mkdtemp() |
504 tempparent = pycompat.mkdtemp() |
505 try: |
505 try: |
506 parentrepo = localrepo.instance(ui, tempparent, create=True) |
506 repo = localrepo.instance(ui, tempparent, create=True) |
507 except Exception: |
507 except Exception: |
508 shutil.rmtree(tempparent) |
508 shutil.rmtree(tempparent) |
509 raise |
509 raise |
510 |
510 |
511 class derivedbundlerepository(bundlerepository, parentrepo.__class__): |
511 class derivedbundlerepository(bundlerepository, repo.__class__): |
512 pass |
512 pass |
513 |
513 |
514 repo = parentrepo |
|
515 repo.__class__ = derivedbundlerepository |
514 repo.__class__ = derivedbundlerepository |
516 bundlerepository.__init__(repo, bundlepath, url, tempparent) |
515 bundlerepository.__init__(repo, bundlepath, url, tempparent) |
517 |
516 |
518 return repo |
517 return repo |
519 |
518 |