tests/test-extension.t
changeset 40729 c93d046d4300
parent 40463 cfa564037789
child 40872 07e181ed82ef
equal deleted inserted replaced
40728:2cd5f1fac788 40729:c93d046d4300
    22   > def uisetup(ui):
    22   > def uisetup(ui):
    23   >     ui.debug(b"uisetup called [debug]\\n")
    23   >     ui.debug(b"uisetup called [debug]\\n")
    24   >     ui.write(b"uisetup called\\n")
    24   >     ui.write(b"uisetup called\\n")
    25   >     ui.status(b"uisetup called [status]\\n")
    25   >     ui.status(b"uisetup called [status]\\n")
    26   >     ui.flush()
    26   >     ui.flush()
       
    27   > def uipopulate(ui):
       
    28   >     ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1
       
    29   >     ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt)
    27   > def reposetup(ui, repo):
    30   > def reposetup(ui, repo):
    28   >     ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
    31   >     ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
    29   >     ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
    32   >     ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
    30   >     ui.flush()
    33   >     ui.flush()
    31   > @command(b'foo', [], b'hg foo')
    34   > @command(b'foo', [], b'hg foo')
    52   $ echo '[extensions]' >> $HGRCPATH
    55   $ echo '[extensions]' >> $HGRCPATH
    53   $ echo "foobar = $abspath" >> $HGRCPATH
    56   $ echo "foobar = $abspath" >> $HGRCPATH
    54   $ hg foo
    57   $ hg foo
    55   uisetup called
    58   uisetup called
    56   uisetup called [status]
    59   uisetup called [status]
       
    60   uipopulate called (1 times)
       
    61   uipopulate called (1 times)
       
    62   uipopulate called (1 times)
    57   reposetup called for a
    63   reposetup called for a
    58   ui == repo.ui
    64   ui == repo.ui
       
    65   uipopulate called (1 times) (chg !)
       
    66   uipopulate called (1 times) (chg !)
       
    67   uipopulate called (1 times) (chg !)
       
    68   uipopulate called (1 times) (chg !)
       
    69   uipopulate called (1 times) (chg !)
    59   reposetup called for a (chg !)
    70   reposetup called for a (chg !)
    60   ui == repo.ui (chg !)
    71   ui == repo.ui (chg !)
    61   Foo
    72   Foo
    62   $ hg foo --quiet
    73   $ hg foo --quiet
    63   uisetup called (no-chg !)
    74   uisetup called (no-chg !)
       
    75   uipopulate called (1 times)
       
    76   uipopulate called (1 times)
       
    77   uipopulate called (1 times) (chg !)
       
    78   uipopulate called (1 times) (chg !)
       
    79   uipopulate called (1 times) (chg !)
    64   reposetup called for a (chg !)
    80   reposetup called for a (chg !)
    65   ui == repo.ui
    81   ui == repo.ui
    66   Foo
    82   Foo
    67   $ hg foo --debug
    83   $ hg foo --debug
    68   uisetup called [debug] (no-chg !)
    84   uisetup called [debug] (no-chg !)
    69   uisetup called (no-chg !)
    85   uisetup called (no-chg !)
    70   uisetup called [status] (no-chg !)
    86   uisetup called [status] (no-chg !)
       
    87   uipopulate called (1 times)
       
    88   uipopulate called (1 times)
       
    89   uipopulate called (1 times) (chg !)
       
    90   uipopulate called (1 times) (chg !)
       
    91   uipopulate called (1 times) (chg !)
    71   reposetup called for a (chg !)
    92   reposetup called for a (chg !)
    72   ui == repo.ui
    93   ui == repo.ui
    73   Foo
    94   Foo
    74 
    95 
    75   $ cd ..
    96   $ cd ..
    76   $ hg clone a b
    97   $ hg clone a b
    77   uisetup called (no-chg !)
    98   uisetup called (no-chg !)
    78   uisetup called [status] (no-chg !)
    99   uisetup called [status] (no-chg !)
       
   100   uipopulate called (1 times)
       
   101   uipopulate called (1 times) (chg !)
       
   102   uipopulate called (1 times) (chg !)
    79   reposetup called for a
   103   reposetup called for a
    80   ui == repo.ui
   104   ui == repo.ui
       
   105   uipopulate called (1 times)
    81   reposetup called for b
   106   reposetup called for b
    82   ui == repo.ui
   107   ui == repo.ui
    83   updating to branch default
   108   updating to branch default
    84   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   109   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    85 
   110 
    86   $ hg bar
   111   $ hg bar
    87   uisetup called (no-chg !)
   112   uisetup called (no-chg !)
    88   uisetup called [status] (no-chg !)
   113   uisetup called [status] (no-chg !)
       
   114   uipopulate called (1 times)
       
   115   uipopulate called (1 times) (chg !)
    89   Bar
   116   Bar
    90   $ echo 'foobar = !' >> $HGRCPATH
   117   $ echo 'foobar = !' >> $HGRCPATH
    91 
   118 
    92 module/__init__.py-style
   119 module/__init__.py-style
    93 
   120 
    94   $ echo "barfoo = $barfoopath" >> $HGRCPATH
   121   $ echo "barfoo = $barfoopath" >> $HGRCPATH
    95   $ cd a
   122   $ cd a
    96   $ hg foo
   123   $ hg foo
    97   uisetup called
   124   uisetup called
    98   uisetup called [status]
   125   uisetup called [status]
       
   126   uipopulate called (1 times)
       
   127   uipopulate called (1 times)
       
   128   uipopulate called (1 times)
    99   reposetup called for a
   129   reposetup called for a
   100   ui == repo.ui
   130   ui == repo.ui
       
   131   uipopulate called (1 times) (chg !)
       
   132   uipopulate called (1 times) (chg !)
       
   133   uipopulate called (1 times) (chg !)
       
   134   uipopulate called (1 times) (chg !)
       
   135   uipopulate called (1 times) (chg !)
   101   reposetup called for a (chg !)
   136   reposetup called for a (chg !)
   102   ui == repo.ui (chg !)
   137   ui == repo.ui (chg !)
   103   Foo
   138   Foo
   104   $ echo 'barfoo = !' >> $HGRCPATH
   139   $ echo 'barfoo = !' >> $HGRCPATH
   105 
   140 
   112   > print("1) %s imported" % name, flush=True)
   147   > print("1) %s imported" % name, flush=True)
   113   > def uisetup(ui):
   148   > def uisetup(ui):
   114   >     print("2) %s uisetup" % name, flush=True)
   149   >     print("2) %s uisetup" % name, flush=True)
   115   > def extsetup():
   150   > def extsetup():
   116   >     print("3) %s extsetup" % name, flush=True)
   151   >     print("3) %s extsetup" % name, flush=True)
       
   152   > def uipopulate(ui):
       
   153   >     print("4) %s uipopulate" % name, flush=True)
   117   > def reposetup(ui, repo):
   154   > def reposetup(ui, repo):
   118   >    print("4) %s reposetup" % name, flush=True)
   155   >     print("5) %s reposetup" % name, flush=True)
   119   > 
   156   > 
   120   > bytesname = name.encode('utf-8')
   157   > bytesname = name.encode('utf-8')
   121   > # custom predicate to check registration of functions at loading
   158   > # custom predicate to check registration of functions at loading
   122   > from mercurial import (
   159   > from mercurial import (
   123   >     registrar,
   160   >     registrar,
   141   1) bar imported
   178   1) bar imported
   142   2) foo uisetup
   179   2) foo uisetup
   143   2) bar uisetup
   180   2) bar uisetup
   144   3) foo extsetup
   181   3) foo extsetup
   145   3) bar extsetup
   182   3) bar extsetup
   146   4) foo reposetup
   183   4) foo uipopulate
   147   4) bar reposetup
   184   4) bar uipopulate
       
   185   4) foo uipopulate
       
   186   4) bar uipopulate
       
   187   4) foo uipopulate
       
   188   4) bar uipopulate
       
   189   5) foo reposetup
       
   190   5) bar reposetup
   148   0:c24b9ac61126
   191   0:c24b9ac61126
   149 
   192 
   150 Check hgweb's load order of extensions and registration of functions
   193 Check hgweb's load order of extensions and registration of functions
   151 
   194 
   152   $ cat > hgweb.cgi <<EOF
   195   $ cat > hgweb.cgi <<EOF
   165   1) bar imported
   208   1) bar imported
   166   2) foo uisetup
   209   2) foo uisetup
   167   2) bar uisetup
   210   2) bar uisetup
   168   3) foo extsetup
   211   3) foo extsetup
   169   3) bar extsetup
   212   3) bar extsetup
   170   4) foo reposetup
   213   4) foo uipopulate
   171   4) bar reposetup
   214   4) bar uipopulate
       
   215   4) foo uipopulate
       
   216   4) bar uipopulate
       
   217   5) foo reposetup
       
   218   5) bar reposetup
   172 
   219 
   173 (check that revset predicate foo() and bar() are available)
   220 (check that revset predicate foo() and bar() are available)
   174 
   221 
   175 #if msys
   222 #if msys
   176   $ PATH_INFO='//shortlog'
   223   $ PATH_INFO='//shortlog'