hgkw/keyword.py
branchkwmap-templates
changeset 142 aedce5bcc9eb
parent 141 edf9299112d1
child 143 3485b0ef99c4
equal deleted inserted replaced
141:edf9299112d1 142:aedce5bcc9eb
    74 try:
    74 try:
    75     from mercurial.demandload import * # stable
    75     from mercurial.demandload import * # stable
    76     from mercurial.i18n import gettext as _
    76     from mercurial.i18n import gettext as _
    77     demandload(globals(), 'mercurial:cmdutil,templater,util')
    77     demandload(globals(), 'mercurial:cmdutil,templater,util')
    78     demandload(globals(), 'mercurial:context,filelog,revlog')
    78     demandload(globals(), 'mercurial:context,filelog,revlog')
    79     demandload(globals(), 'os.path re time')
    79     demandload(globals(), 're time')
    80 except ImportError: # demandimport
    80 except ImportError: # demandimport
    81     from mercurial.i18n import _
    81     from mercurial.i18n import _
    82     from mercurial import cmdutil, templater, util
    82     from mercurial import cmdutil, templater, util
    83     from mercurial import context, filelog, revlog
    83     from mercurial import context, filelog, revlog
    84     import os.path, re, time
    84     import re, time
    85 
    85 
    86 deftemplates = {
    86 deftemplates = {
    87         'Revision': '{node|short}',
    87         'Revision': '{node|short}',
    88         'Author': '{author|user}',
    88         'Author': '{author|user}',
    89         'Date': '{date|utcdate}',
    89         'Date': '{date|utcdate}',
   190                 match=util.always, force=False, lock=None, wlock=None,
   190                 match=util.always, force=False, lock=None, wlock=None,
   191                 force_editor=False, p1=None, p2=None, extra={}):
   191                 force_editor=False, p1=None, p2=None, extra={}):
   192             '''Wraps commit, expanding keywords of committed and
   192             '''Wraps commit, expanding keywords of committed and
   193             configured files in working directory.'''
   193             configured files in working directory.'''
   194 
   194 
       
   195             removed = self.status()[2]
       
   196 
   195             node = super(kwrepo, self).commit(files=files,
   197             node = super(kwrepo, self).commit(files=files,
   196                     text=text, user=user, date=date,
   198                     text=text, user=user, date=date,
   197                     match=match, force=force, lock=lock, wlock=wlock,
   199                     match=match, force=force, lock=lock, wlock=wlock,
   198                     force_editor=force_editor, p1=p1, p2=p2, extra=extra)
   200                     force_editor=force_editor, p1=p1, p2=p2, extra=extra)
   199             if node is None:
   201             if node is None:
   200                 return node
   202                 return node
   201 
   203 
   202             candidates = self.changelog.read(node)[3]
   204             candidates = self.changelog.read(node)[3]
   203             candidates = [f for f in candidates
   205             candidates = [f for f in candidates if f not in removed
   204                     if self.kwfmatcher(f) and os.path.isfile(self.wjoin(f))]
   206                     and not self._link(f) and self.kwfmatcher(f)]
   205             if not candidates:
   207             if not candidates:
   206                 return node
   208                 return node
   207 
   209 
   208             kwt = kwtemplater(self.ui, self)
   210             kwt = kwtemplater(self.ui, self)
   209             kwt.overwrite(candidates, node)
   211             kwt.overwrite(candidates, node)