hgkw/keyword.py
branchsolo-extension
changeset 61 1fe48bf82d05
parent 60 9771775ef322
child 63 5455c45db625
equal deleted inserted replaced
60:9771775ef322 61:1fe48bf82d05
   138     on commit and expands keywords in working dir.'''
   138     on commit and expands keywords in working dir.'''
   139 
   139 
   140     if hooktype != 'pretxncommit':
   140     if hooktype != 'pretxncommit':
   141         return True
   141         return True
   142 
   142 
   143     # reparse args, opts again as pretxncommit hook is silent about them
       
   144     cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]
   143     cmd, sysargs, globalopts, cmdopts = commands.parse(ui, sys.argv[1:])[1:]
   145     # exclude tag and import
       
   146     if repr(cmd).split()[1] in ('tag', 'import_'):
   144     if repr(cmd).split()[1] in ('tag', 'import_'):
   147         return False
   145         return False
   148 
   146 
   149     files, match, anypats = cmdutil.matchpats(repo, sysargs, cmdopts)
   147     files, match, anypats = cmdutil.matchpats(repo, sysargs, cmdopts)
   150     # validity checks should have been done already
       
   151     modified, added = repo.status(files=files, match=match)[:2]
   148     modified, added = repo.status(files=files, match=match)[:2]
   152     candidates = [f for f in modified + added if not f.startswith('.hg')]
   149     candidates = [f for f in modified + added if not f.startswith('.hg')]
   153     if not candidates:
   150     if not candidates:
   154         return False
   151         return False
   155 
   152 
   156     # only check files that are configured in keyword section
       
   157     files = []
   153     files = []
   158     for pat, opt in repo.ui.configitems('keyword'):
   154     for pat, opt in repo.ui.configitems('keyword'):
   159         if opt == 'expand':
   155         if opt == 'expand':
   160             mf = util.matcher(repo.root, '', [pat], [], [])[1]
   156             mf = util.matcher(repo.root, '', [pat], [], [])[1]
   161             for candidate in candidates:
   157             for candidate in candidates: