hgkw/keyword.py
branchkwmap-templates
changeset 176 3aed363c9eaf
parent 175 f8e5cafa7b99
child 177 261a6844145e
equal deleted inserted replaced
175:f8e5cafa7b99 176:3aed363c9eaf
    80 from mercurial.i18n import gettext as _
    80 from mercurial.i18n import gettext as _
    81 from mercurial import commands, fancyopts, templater, util
    81 from mercurial import commands, fancyopts, templater, util
    82 from mercurial import cmdutil, context, filelog
    82 from mercurial import cmdutil, context, filelog
    83 # findcmd might be in cmdutil or commands
    83 # findcmd might be in cmdutil or commands
    84 # depending on mercurial version
    84 # depending on mercurial version
    85 if hasattr(cmdutil, "findcmd"):
    85 if hasattr(cmdutil, 'findcmd'):
    86     findcmd = cmdutil.findcmd
    86     findcmd = cmdutil.findcmd
    87 else:
    87 else:
    88     findcmd = commands.findcmd
    88     findcmd = commands.findcmd
    89 import os, re, sys, time
    89 import os, re, sys, time
    90 
    90 
   247                 kwt = kwtemplater(ui, self, path=f)
   247                 kwt = kwtemplater(ui, self, path=f)
   248                 return kwfilelog(self.sopener, f, kwt)
   248                 return kwfilelog(self.sopener, f, kwt)
   249             else:
   249             else:
   250                 return filelog.filelog(self.sopener, f)
   250                 return filelog.filelog(self.sopener, f)
   251 
   251 
   252         def commit(self, files=None, text="", user=None, date=None,
   252         def commit(self, files=None, text='', user=None, date=None,
   253                    match=util.always, force=False, lock=None, wlock=None,
   253                    match=util.always, force=False, lock=None, wlock=None,
   254                    force_editor=False, p1=None, p2=None, extra={}):
   254                    force_editor=False, p1=None, p2=None, extra={}):
   255             '''Wraps commit, expanding keywords of committed and
   255             '''Wraps commit, expanding keywords of committed and
   256             configured files in working directory.'''
   256             configured files in working directory.'''
   257             wrelease = False
   257             wrelease = False
   273 
   273 
   274                 candidates = self.changelog.read(node)[3]
   274                 candidates = self.changelog.read(node)[3]
   275                 candidates = [f for f in candidates if kwfmatcher(f)
   275                 candidates = [f for f in candidates if kwfmatcher(f)
   276                               and f not in removed
   276                               and f not in removed
   277                               and not os.path.islink(self.wjoin(f))]
   277                               and not os.path.islink(self.wjoin(f))]
   278                 if not candidates:
   278                 if candidates:
   279                     return node
   279                     kwt = kwtemplater(ui, self, node=node)
   280 
   280                     kwt.overwrite(candidates)
   281                 kwt = kwtemplater(ui, self, node=node)
   281 
   282                 kwt.overwrite(candidates)
       
   283                 return node
   282                 return node
   284             finally:
   283             finally:
   285                 if wrelease:
   284                 if wrelease:
   286                     wlock.release()
   285                     wlock.release()
   287 
   286