##// END OF EJS Templates
localrepo: read requirements file in makelocalrepository()...
Gregory Szorc -
r39728:6a3162ed default
parent child Browse files
Show More
@@ -408,6 +408,18 b' def makelocalrepository(baseui, path, in'
408 408
409 409 raise error.RepoError(_(b'repository %s not found') % path)
410 410
411 # .hg/requires file contains a newline-delimited list of
412 # features/capabilities the opener (us) must have in order to use
413 # the repository. This file was introduced in Mercurial 0.9.2,
414 # which means very old repositories may not have one. We assume
415 # a missing file translates to no requirements.
416 try:
417 requirements = set(hgvfs.read(b'requires').splitlines())
418 except IOError as e:
419 if e.errno != errno.ENOENT:
420 raise
421 requirements = set()
422
411 423 # The .hg/hgrc file may load extensions or contain config options
412 424 # that influence repository construction. Attempt to load it and
413 425 # process any new extensions that it may have pulled in.
@@ -424,6 +436,7 b' def makelocalrepository(baseui, path, in'
424 436 origroot=path,
425 437 wdirvfs=wdirvfs,
426 438 hgvfs=hgvfs,
439 requirements=requirements,
427 440 intents=intents)
428 441
429 442 @interfaceutil.implementer(repository.completelocalrepository)
@@ -476,7 +489,8 b' class localrepository(object):'
476 489 'bisect.state',
477 490 }
478 491
479 def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, intents=None):
492 def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, requirements,
493 intents=None):
480 494 """Create a new local repository instance.
481 495
482 496 Most callers should use ``hg.repository()``, ``localrepo.instance()``,
@@ -500,6 +514,9 b' class localrepository(object):'
500 514 hgvfs
501 515 ``vfs.vfs`` rooted at .hg/
502 516
517 requirements
518 ``set`` of bytestrings representing repository opening requirements.
519
503 520 intents
504 521 ``set`` of system strings indicating what this repo will be used
505 522 for.
@@ -545,12 +562,23 b' class localrepository(object):'
545 562 if engine.revlogheader():
546 563 self.supported.add('exp-compression-%s' % name)
547 564
548 try:
549 self.requirements = scmutil.readrequires(self.vfs, self.supported)
550 except IOError as inst:
551 if inst.errno != errno.ENOENT:
552 raise
553 self.requirements = set()
565 # Validate that all seen repository requirements are supported.
566 missingrequirements = []
567 for r in requirements:
568 if r not in self.supported:
569 if not r or not r[0:1].isalnum():
570 raise error.RequirementError(
571 _(".hg/requires file is corrupt"))
572 missingrequirements.append(r)
573 missingrequirements.sort()
574 if missingrequirements:
575 raise error.RequirementError(
576 _("repository requires features unknown to this Mercurial: %s")
577 % " ".join(missingrequirements),
578 hint=_("see https://mercurial-scm.org/wiki/MissingRequirement"
579 " for more information"))
580
581 self.requirements = requirements
554 582
555 583 cachepath = self.vfs.join('cache')
556 584 self.sharedpath = self.path
General Comments 0
You need to be logged in to leave comments. Login now