Show More
@@ -408,6 +408,18 b' def makelocalrepository(baseui, path, in' | |||||
408 |
|
408 | |||
409 | raise error.RepoError(_(b'repository %s not found') % path) |
|
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 | # The .hg/hgrc file may load extensions or contain config options |
|
423 | # The .hg/hgrc file may load extensions or contain config options | |
412 | # that influence repository construction. Attempt to load it and |
|
424 | # that influence repository construction. Attempt to load it and | |
413 | # process any new extensions that it may have pulled in. |
|
425 | # process any new extensions that it may have pulled in. | |
@@ -424,6 +436,7 b' def makelocalrepository(baseui, path, in' | |||||
424 | origroot=path, |
|
436 | origroot=path, | |
425 | wdirvfs=wdirvfs, |
|
437 | wdirvfs=wdirvfs, | |
426 | hgvfs=hgvfs, |
|
438 | hgvfs=hgvfs, | |
|
439 | requirements=requirements, | |||
427 | intents=intents) |
|
440 | intents=intents) | |
428 |
|
441 | |||
429 | @interfaceutil.implementer(repository.completelocalrepository) |
|
442 | @interfaceutil.implementer(repository.completelocalrepository) | |
@@ -476,7 +489,8 b' class localrepository(object):' | |||||
476 | 'bisect.state', |
|
489 | 'bisect.state', | |
477 | } |
|
490 | } | |
478 |
|
491 | |||
479 |
def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, |
|
492 | def __init__(self, baseui, ui, origroot, wdirvfs, hgvfs, requirements, | |
|
493 | intents=None): | |||
480 | """Create a new local repository instance. |
|
494 | """Create a new local repository instance. | |
481 |
|
495 | |||
482 | Most callers should use ``hg.repository()``, ``localrepo.instance()``, |
|
496 | Most callers should use ``hg.repository()``, ``localrepo.instance()``, | |
@@ -500,6 +514,9 b' class localrepository(object):' | |||||
500 | hgvfs |
|
514 | hgvfs | |
501 | ``vfs.vfs`` rooted at .hg/ |
|
515 | ``vfs.vfs`` rooted at .hg/ | |
502 |
|
516 | |||
|
517 | requirements | |||
|
518 | ``set`` of bytestrings representing repository opening requirements. | |||
|
519 | ||||
503 | intents |
|
520 | intents | |
504 | ``set`` of system strings indicating what this repo will be used |
|
521 | ``set`` of system strings indicating what this repo will be used | |
505 | for. |
|
522 | for. | |
@@ -545,12 +562,23 b' class localrepository(object):' | |||||
545 | if engine.revlogheader(): |
|
562 | if engine.revlogheader(): | |
546 | self.supported.add('exp-compression-%s' % name) |
|
563 | self.supported.add('exp-compression-%s' % name) | |
547 |
|
564 | |||
548 | try: |
|
565 | # Validate that all seen repository requirements are supported. | |
549 | self.requirements = scmutil.readrequires(self.vfs, self.supported) |
|
566 | missingrequirements = [] | |
550 | except IOError as inst: |
|
567 | for r in requirements: | |
551 | if inst.errno != errno.ENOENT: |
|
568 | if r not in self.supported: | |
552 | raise |
|
569 | if not r or not r[0:1].isalnum(): | |
553 |
|
|
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 | cachepath = self.vfs.join('cache') |
|
583 | cachepath = self.vfs.join('cache') | |
556 | self.sharedpath = self.path |
|
584 | self.sharedpath = self.path |
General Comments 0
You need to be logged in to leave comments.
Login now