Show More
@@ -446,6 +446,9 def makelocalrepository(baseui, path, in | |||
|
446 | 446 | # process any new extensions that it may have pulled in. |
|
447 | 447 | try: |
|
448 | 448 | ui.readconfig(hgvfs.join(b'hgrc'), root=wdirvfs.base) |
|
449 | # Run this before extensions.loadall() so extensions can be | |
|
450 | # automatically enabled. | |
|
451 | afterhgrcload(ui, wdirvfs, hgvfs, requirements) | |
|
449 | 452 | except IOError: |
|
450 | 453 | pass |
|
451 | 454 | else: |
@@ -572,6 +575,30 def makelocalrepository(baseui, path, in | |||
|
572 | 575 | features=features, |
|
573 | 576 | intents=intents) |
|
574 | 577 | |
|
578 | def afterhgrcload(ui, wdirvfs, hgvfs, requirements): | |
|
579 | """Perform additional actions after .hg/hgrc is loaded. | |
|
580 | ||
|
581 | This function is called during repository loading immediately after | |
|
582 | the .hg/hgrc file is loaded and before per-repo extensions are loaded. | |
|
583 | ||
|
584 | The function can be used to validate configs, automatically add | |
|
585 | options (including extensions) based on requirements, etc. | |
|
586 | """ | |
|
587 | ||
|
588 | # Map of requirements to list of extensions to load automatically when | |
|
589 | # requirement is present. | |
|
590 | autoextensions = { | |
|
591 | b'lfs': [b'lfs'], | |
|
592 | } | |
|
593 | ||
|
594 | for requirement, names in sorted(autoextensions.items()): | |
|
595 | if requirement not in requirements: | |
|
596 | continue | |
|
597 | ||
|
598 | for name in names: | |
|
599 | if not ui.hasconfig(b'extensions', name): | |
|
600 | ui.setconfig(b'extensions', name, b'', source='autoload') | |
|
601 | ||
|
575 | 602 | def gathersupportedrequirements(ui): |
|
576 | 603 | """Determine the complete set of recognized requirements.""" |
|
577 | 604 | # Start with all requirements supported by this file. |
@@ -1,5 +1,52 | |||
|
1 | 1 | #require no-reposimplestore no-chg |
|
2 | 2 | |
|
3 | $ hg init requirements | |
|
4 | $ cd requirements | |
|
5 | ||
|
6 | # LFS not loaded by default. | |
|
7 | ||
|
8 | $ hg config extensions | |
|
9 | [1] | |
|
10 | ||
|
11 | # Adding lfs to requires file will auto-load lfs extension. | |
|
12 | ||
|
13 | $ echo lfs >> .hg/requires | |
|
14 | $ hg config extensions | |
|
15 | extensions.lfs= | |
|
16 | ||
|
17 | # But only if there is no config entry for the extension already. | |
|
18 | ||
|
19 | $ cat > .hg/hgrc << EOF | |
|
20 | > [extensions] | |
|
21 | > lfs=! | |
|
22 | > EOF | |
|
23 | ||
|
24 | $ hg config extensions | |
|
25 | abort: repository requires features unknown to this Mercurial: lfs! | |
|
26 | (see https://mercurial-scm.org/wiki/MissingRequirement for more information) | |
|
27 | [255] | |
|
28 | ||
|
29 | $ cat > .hg/hgrc << EOF | |
|
30 | > [extensions] | |
|
31 | > lfs= | |
|
32 | > EOF | |
|
33 | ||
|
34 | $ hg config extensions | |
|
35 | extensions.lfs= | |
|
36 | ||
|
37 | $ cat > .hg/hgrc << EOF | |
|
38 | > [extensions] | |
|
39 | > lfs = missing.py | |
|
40 | > EOF | |
|
41 | ||
|
42 | $ hg config extensions | |
|
43 | *** failed to import extension lfs from missing.py: [Errno 2] $ENOENT$: 'missing.py' | |
|
44 | abort: repository requires features unknown to this Mercurial: lfs! | |
|
45 | (see https://mercurial-scm.org/wiki/MissingRequirement for more information) | |
|
46 | [255] | |
|
47 | ||
|
48 | $ cd .. | |
|
49 | ||
|
3 | 50 | # Initial setup |
|
4 | 51 | |
|
5 | 52 | $ cat >> $HGRCPATH << EOF |
General Comments 0
You need to be logged in to leave comments.
Login now