Show More
@@ -13,10 +13,18 b' from i18n import _, gettext' | |||||
13 | _order = [] |
|
13 | _order = [] | |
14 | _ignore = ['hbisect', 'bookmarks', 'parentrevspec', 'interhg'] |
|
14 | _ignore = ['hbisect', 'bookmarks', 'parentrevspec', 'interhg'] | |
15 |
|
15 | |||
16 | def extensions(): |
|
16 | def extensions(ui=None): | |
|
17 | if ui: | |||
|
18 | def enabled(name): | |||
|
19 | for format in ['%s', 'hgext.%s']: | |||
|
20 | conf = ui.config('extensions', format % name) | |||
|
21 | if conf is not None and not conf.startswith('!'): | |||
|
22 | return True | |||
|
23 | else: | |||
|
24 | enabled = lambda name: True | |||
17 | for name in _order: |
|
25 | for name in _order: | |
18 | module = _extensions[name] |
|
26 | module = _extensions[name] | |
19 | if module: |
|
27 | if module and enabled(name): | |
20 | yield name, module |
|
28 | yield name, module | |
21 |
|
29 | |||
22 | def find(name): |
|
30 | def find(name): |
@@ -101,7 +101,7 b' def _peerorrepo(ui, path, create=False):' | |||||
101 | """return a repository object for the specified path""" |
|
101 | """return a repository object for the specified path""" | |
102 | obj = _peerlookup(path).instance(ui, path, create) |
|
102 | obj = _peerlookup(path).instance(ui, path, create) | |
103 | ui = getattr(obj, "ui", ui) |
|
103 | ui = getattr(obj, "ui", ui) | |
104 | for name, module in extensions.extensions(): |
|
104 | for name, module in extensions.extensions(ui): | |
105 | hook = getattr(module, 'reposetup', None) |
|
105 | hook = getattr(module, 'reposetup', None) | |
106 | if hook: |
|
106 | if hook: | |
107 | hook(ui, obj) |
|
107 | hook(ui, obj) |
@@ -417,6 +417,7 b' Show extensions:' | |||||
417 |
|
417 | |||
418 | Disabled extension commands: |
|
418 | Disabled extension commands: | |
419 |
|
419 | |||
|
420 | $ ORGHGRCPATH=$HGRCPATH | |||
420 | $ HGRCPATH= |
|
421 | $ HGRCPATH= | |
421 | $ export HGRCPATH |
|
422 | $ export HGRCPATH | |
422 | $ hg help email |
|
423 | $ hg help email | |
@@ -573,3 +574,134 b' Declare the version as supporting this h' | |||||
573 | ** Python * (glob) |
|
574 | ** Python * (glob) | |
574 | ** Mercurial Distributed SCM (*) (glob) |
|
575 | ** Mercurial Distributed SCM (*) (glob) | |
575 | ** Extensions loaded: throw |
|
576 | ** Extensions loaded: throw | |
|
577 | ||||
|
578 | Restore HGRCPATH | |||
|
579 | ||||
|
580 | $ HGRCPATH=$ORGHGRCPATH | |||
|
581 | $ export HGRCPATH | |||
|
582 | ||||
|
583 | Commands handling multiple repositories at a time should invoke only | |||
|
584 | "reposetup()" of extensions enabling in the target repository. | |||
|
585 | ||||
|
586 | $ mkdir reposetup-test | |||
|
587 | $ cd reposetup-test | |||
|
588 | ||||
|
589 | $ cat > $TESTTMP/reposetuptest.py <<EOF | |||
|
590 | > from mercurial import extensions | |||
|
591 | > def reposetup(ui, repo): | |||
|
592 | > ui.write('reposetup() for %s\n' % (repo.root)) | |||
|
593 | > EOF | |||
|
594 | $ hg init src | |||
|
595 | $ echo a > src/a | |||
|
596 | $ hg -R src commit -Am '#0 at src/a' | |||
|
597 | adding a | |||
|
598 | $ echo '[extensions]' >> src/.hg/hgrc | |||
|
599 | $ echo '# enable extension locally' >> src/.hg/hgrc | |||
|
600 | $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc | |||
|
601 | $ hg -R src status | |||
|
602 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
603 | ||||
|
604 | $ hg clone -U src clone-dst1 | |||
|
605 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
606 | $ hg init push-dst1 | |||
|
607 | $ hg -q -R src push push-dst1 | |||
|
608 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
609 | $ hg init pull-src1 | |||
|
610 | $ hg -q -R pull-src1 pull src | |||
|
611 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
612 | ||||
|
613 | $ echo '[extensions]' >> $HGRCPATH | |||
|
614 | $ echo '# disable extension globally and explicitly' >> $HGRCPATH | |||
|
615 | $ echo 'reposetuptest = !' >> $HGRCPATH | |||
|
616 | $ hg clone -U src clone-dst2 | |||
|
617 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
618 | $ hg init push-dst2 | |||
|
619 | $ hg -q -R src push push-dst2 | |||
|
620 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
621 | $ hg init pull-src2 | |||
|
622 | $ hg -q -R pull-src2 pull src | |||
|
623 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
624 | ||||
|
625 | $ echo '[extensions]' >> $HGRCPATH | |||
|
626 | $ echo '# enable extension globally' >> $HGRCPATH | |||
|
627 | $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> $HGRCPATH | |||
|
628 | $ hg clone -U src clone-dst3 | |||
|
629 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
630 | reposetup() for $TESTTMP/reposetup-test/clone-dst3 | |||
|
631 | $ hg init push-dst3 | |||
|
632 | reposetup() for $TESTTMP/reposetup-test/push-dst3 | |||
|
633 | $ hg -q -R src push push-dst3 | |||
|
634 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
635 | reposetup() for $TESTTMP/reposetup-test/push-dst3 | |||
|
636 | $ hg init pull-src3 | |||
|
637 | reposetup() for $TESTTMP/reposetup-test/pull-src3 | |||
|
638 | $ hg -q -R pull-src3 pull src | |||
|
639 | reposetup() for $TESTTMP/reposetup-test/pull-src3 | |||
|
640 | reposetup() for $TESTTMP/reposetup-test/src | |||
|
641 | ||||
|
642 | $ echo '[extensions]' >> src/.hg/hgrc | |||
|
643 | $ echo '# disable extension locally' >> src/.hg/hgrc | |||
|
644 | $ echo 'reposetuptest = !' >> src/.hg/hgrc | |||
|
645 | $ hg clone -U src clone-dst4 | |||
|
646 | reposetup() for $TESTTMP/reposetup-test/clone-dst4 | |||
|
647 | $ hg init push-dst4 | |||
|
648 | reposetup() for $TESTTMP/reposetup-test/push-dst4 | |||
|
649 | $ hg -q -R src push push-dst4 | |||
|
650 | reposetup() for $TESTTMP/reposetup-test/push-dst4 | |||
|
651 | $ hg init pull-src4 | |||
|
652 | reposetup() for $TESTTMP/reposetup-test/pull-src4 | |||
|
653 | $ hg -q -R pull-src4 pull src | |||
|
654 | reposetup() for $TESTTMP/reposetup-test/pull-src4 | |||
|
655 | ||||
|
656 | disabling in command line overlays with all configuration | |||
|
657 | $ hg --config extensions.reposetuptest=! clone -U src clone-dst5 | |||
|
658 | $ hg --config extensions.reposetuptest=! init push-dst5 | |||
|
659 | $ hg --config extensions.reposetuptest=! -q -R src push push-dst5 | |||
|
660 | $ hg --config extensions.reposetuptest=! init pull-src5 | |||
|
661 | $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src | |||
|
662 | ||||
|
663 | $ echo '[extensions]' >> $HGRCPATH | |||
|
664 | $ echo '# disable extension globally and explicitly' >> $HGRCPATH | |||
|
665 | $ echo 'reposetuptest = !' >> $HGRCPATH | |||
|
666 | $ hg init parent | |||
|
667 | $ hg init parent/sub1 | |||
|
668 | $ echo 1 > parent/sub1/1 | |||
|
669 | $ hg -R parent/sub1 commit -Am '#0 at parent/sub1' | |||
|
670 | adding 1 | |||
|
671 | $ hg init parent/sub2 | |||
|
672 | $ hg init parent/sub2/sub21 | |||
|
673 | $ echo 21 > parent/sub2/sub21/21 | |||
|
674 | $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21' | |||
|
675 | adding 21 | |||
|
676 | $ cat > parent/sub2/.hgsub <<EOF | |||
|
677 | > sub21 = sub21 | |||
|
678 | > EOF | |||
|
679 | $ hg -R parent/sub2 commit -Am '#0 at parent/sub2' | |||
|
680 | adding .hgsub | |||
|
681 | $ hg init parent/sub3 | |||
|
682 | $ echo 3 > parent/sub3/3 | |||
|
683 | $ hg -R parent/sub3 commit -Am '#0 at parent/sub3' | |||
|
684 | adding 3 | |||
|
685 | $ cat > parent/.hgsub <<EOF | |||
|
686 | > sub1 = sub1 | |||
|
687 | > sub2 = sub2 | |||
|
688 | > sub3 = sub3 | |||
|
689 | > EOF | |||
|
690 | $ hg -R parent commit -Am '#0 at parent' | |||
|
691 | adding .hgsub | |||
|
692 | $ echo '[extensions]' >> parent/.hg/hgrc | |||
|
693 | $ echo '# enable extension locally' >> parent/.hg/hgrc | |||
|
694 | $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc | |||
|
695 | $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc | |||
|
696 | $ hg -R parent status -S -A | |||
|
697 | reposetup() for $TESTTMP/reposetup-test/parent | |||
|
698 | reposetup() for $TESTTMP/reposetup-test/parent/sub2 | |||
|
699 | C .hgsub | |||
|
700 | C .hgsubstate | |||
|
701 | C sub1/1 | |||
|
702 | C sub2/.hgsub | |||
|
703 | C sub2/.hgsubstate | |||
|
704 | C sub2/sub21/21 | |||
|
705 | C sub3/3 | |||
|
706 | ||||
|
707 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now