tests/test-extension.t
changeset 44987 a28d1eca6507
parent 44953 50005af3c7a8
child 45008 e1ea913da2ed
equal deleted inserted replaced
44986:0ff59434af72 44987:a28d1eca6507
   150 
   150 
   151   $ cat > foo.py <<EOF
   151   $ cat > foo.py <<EOF
   152   > from __future__ import print_function
   152   > from __future__ import print_function
   153   > import os
   153   > import os
   154   > from mercurial import exthelper
   154   > from mercurial import exthelper
       
   155   > from mercurial.utils import procutil
       
   156   > 
       
   157   > write = procutil.stdout.write
   155   > name = os.path.basename(__file__).rsplit('.', 1)[0]
   158   > name = os.path.basename(__file__).rsplit('.', 1)[0]
   156   > print("1) %s imported" % name, flush=True)
   159   > bytesname = name.encode('utf-8')
       
   160   > write(b"1) %s imported\n" % bytesname)
   157   > eh = exthelper.exthelper()
   161   > eh = exthelper.exthelper()
   158   > @eh.uisetup
   162   > @eh.uisetup
   159   > def _uisetup(ui):
   163   > def _uisetup(ui):
   160   >     print("2) %s uisetup" % name, flush=True)
   164   >     write(b"2) %s uisetup\n" % bytesname)
   161   > @eh.extsetup
   165   > @eh.extsetup
   162   > def _extsetup(ui):
   166   > def _extsetup(ui):
   163   >     print("3) %s extsetup" % name, flush=True)
   167   >     write(b"3) %s extsetup\n" % bytesname)
   164   > @eh.uipopulate
   168   > @eh.uipopulate
   165   > def _uipopulate(ui):
   169   > def _uipopulate(ui):
   166   >     print("4) %s uipopulate" % name, flush=True)
   170   >     write(b"4) %s uipopulate\n" % bytesname)
   167   > @eh.reposetup
   171   > @eh.reposetup
   168   > def _reposetup(ui, repo):
   172   > def _reposetup(ui, repo):
   169   >     print("5) %s reposetup" % name, flush=True)
   173   >     write(b"5) %s reposetup\n" % bytesname)
   170   > 
   174   > 
   171   > extsetup = eh.finalextsetup
   175   > extsetup = eh.finalextsetup
   172   > reposetup = eh.finalreposetup
   176   > reposetup = eh.finalreposetup
   173   > uipopulate = eh.finaluipopulate
   177   > uipopulate = eh.finaluipopulate
   174   > uisetup = eh.finaluisetup
   178   > uisetup = eh.finaluisetup
   175   > revsetpredicate = eh.revsetpredicate
   179   > revsetpredicate = eh.revsetpredicate
   176   > 
   180   > 
   177   > bytesname = name.encode('utf-8')
       
   178   > # custom predicate to check registration of functions at loading
   181   > # custom predicate to check registration of functions at loading
   179   > from mercurial import (
   182   > from mercurial import (
   180   >     smartset,
   183   >     smartset,
   181   > )
   184   > )
   182   > @eh.revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb
   185   > @eh.revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb