comparison mercurial/localrepo.py @ 39705:f19bba3f4d3f

localrepo: copy ui in makelocalrepository() We will want to load the .hg/hgrc file from makelocalrepository() so we can consult its options as part of deriving the repository type. This means we need to create our ui instance copy in that function. Differential Revision: https://phab.mercurial-scm.org/D4565
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 12 Sep 2018 11:34:02 -0700
parents 2f9cdb5b3644
children e0c5017124b3
comparison
equal deleted inserted replaced
39704:2f9cdb5b3644 39705:f19bba3f4d3f
374 # The function receives a set of requirement strings that the repository 374 # The function receives a set of requirement strings that the repository
375 # is capable of opening. Functions will typically add elements to the 375 # is capable of opening. Functions will typically add elements to the
376 # set to reflect that the extension knows how to handle that requirements. 376 # set to reflect that the extension knows how to handle that requirements.
377 featuresetupfuncs = set() 377 featuresetupfuncs = set()
378 378
379 def makelocalrepository(ui, path, intents=None): 379 def makelocalrepository(baseui, path, intents=None):
380 """Create a local repository object. 380 """Create a local repository object.
381 381
382 Given arguments needed to construct a local repository, this function 382 Given arguments needed to construct a local repository, this function
383 derives a type suitable for representing that repository and returns an 383 derives a type suitable for representing that repository and returns an
384 instance of it. 384 instance of it.
385 385
386 The returned object conforms to the ``repository.completelocalrepository`` 386 The returned object conforms to the ``repository.completelocalrepository``
387 interface. 387 interface.
388 """ 388 """
389 ui = baseui.copy()
390 # Prevent copying repo configuration.
391 ui.copy = baseui.copy
392
389 # Working directory VFS rooted at repository root. 393 # Working directory VFS rooted at repository root.
390 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True) 394 wdirvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
391 395
392 # Main VFS for .hg/ directory. 396 # Main VFS for .hg/ directory.
393 hgpath = wdirvfs.join(b'.hg') 397 hgpath = wdirvfs.join(b'.hg')
394 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True) 398 hgvfs = vfsmod.vfs(hgpath, cacheaudited=True)
395 399
396 return localrepository( 400 return localrepository(
397 ui, path, 401 baseui=baseui,
402 ui=ui,
403 origroot=path,
398 wdirvfs=wdirvfs, 404 wdirvfs=wdirvfs,
399 hgvfs=hgvfs, 405 hgvfs=hgvfs,
400 intents=intents) 406 intents=intents)
401 407
402 @interfaceutil.implementer(repository.completelocalrepository) 408 @interfaceutil.implementer(repository.completelocalrepository)
447 # this changeset was introduced. Someone should fix 453 # this changeset was introduced. Someone should fix
448 # the remainig bit and drop this line 454 # the remainig bit and drop this line
449 'bisect.state', 455 'bisect.state',
450 } 456 }
451 457
452 def __init__(self, baseui, origroot, wdirvfs, hgvfs, intents=None): 458 def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, intents=None):
453 """Create a new local repository instance. 459 """Create a new local repository instance.
454 460
455 Most callers should use ``hg.repository()``, ``localrepo.instance()``, 461 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
456 or ``localrepo.makelocalrepository()`` for obtaining a new repository 462 or ``localrepo.makelocalrepository()`` for obtaining a new repository
457 object. 463 object.
458 464
459 Arguments: 465 Arguments:
460 466
461 baseui 467 baseui
462 ``ui.ui`` instance to use. A copy will be made (since new config 468 ``ui.ui`` instance that ``ui`` argument was based off of.
463 options may be loaded into it). 469
470 ui
471 ``ui.ui`` instance for use by the repository.
464 472
465 origroot 473 origroot
466 ``bytes`` path to working directory root of this repository. 474 ``bytes`` path to working directory root of this repository.
467 475
468 wdirvfs 476 wdirvfs
474 intents 482 intents
475 ``set`` of system strings indicating what this repo will be used 483 ``set`` of system strings indicating what this repo will be used
476 for. 484 for.
477 """ 485 """
478 self.baseui = baseui 486 self.baseui = baseui
479 self.ui = baseui.copy() 487 self.ui = ui
480 self.ui.copy = baseui.copy # prevent copying repo configuration
481
482 self.origroot = origroot 488 self.origroot = origroot
483 # vfs rooted at working directory. 489 # vfs rooted at working directory.
484 self.wvfs = wdirvfs 490 self.wvfs = wdirvfs
485 self.root = wdirvfs.base 491 self.root = wdirvfs.base
486 # vfs rooted at .hg/. Used to access most non-store paths. 492 # vfs rooted at .hg/. Used to access most non-store paths.