hgkw/keyword.py
branchself_initializing_hook
changeset 87 c193da9eb3e4
parent 86 790aa37e93aa
child 88 ffec227fced3
equal deleted inserted replaced
86:790aa37e93aa 87:c193da9eb3e4
   127                 text = re_kw.sub(r'$\1$', text)
   127                 text = re_kw.sub(r'$\1$', text)
   128             return super(kwfilelog, self).cmp(node, text)
   128             return super(kwfilelog, self).cmp(node, text)
   129 
   129 
   130     filelog.filelog = kwfilelog
   130     filelog.filelog = kwfilelog
   131     repo.__class__ = kwrepo
   131     repo.__class__ = kwrepo
   132     # import keyword from pretxncommit hook even if it is not in hgext folder
   132     # make pretxncommit hook import kwmodule regardless of where it's located
   133     sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
   133     moddir = os.path.abspath(os.path.dirname(__file__))
   134     ui.setconfig('hooks', 'pretxncommit.keyword', 'python:%s.pretxnkw'
   134     if os.path.dirname(moddir) in sys.path:
   135             % os.path.splitext(os.path.basename(__file__))[0])
   135         moddir = os.path.split(moddir)[1]+'.'
       
   136     else:
       
   137         sys.path.insert(0, moddir)
       
   138         moddir = ''
       
   139     ui.setconfig('hooks', 'pretxncommit.keyword', 'python:%s%s.pretxnkw'
       
   140             % (moddir, os.path.splitext(os.path.basename(__file__))[0]))
       
   141     del moddir
   136 
   142 
   137 
   143 
   138 def pretxnkw(ui, repo, hooktype, **args):
   144 def pretxnkw(ui, repo, hooktype, **args):
   139     '''pretxncommit hook that collects candidates for keyword expansion
   145     '''pretxncommit hook that collects candidates for keyword expansion
   140     on commit and expands keywords in working dir.'''
   146     on commit and expands keywords in working dir.'''