hgkw/keyword.py
changeset 819 8f2c2cc51789
parent 818 b742a071ad9c
child 836 53a9228f13de
equal deleted inserted replaced
818:b742a071ad9c 819:8f2c2cc51789
    96 
    96 
    97 # hg commands that trigger expansion only when writing to working dir,
    97 # hg commands that trigger expansion only when writing to working dir,
    98 # not when reading filelog, and unexpand when reading from working dir
    98 # not when reading filelog, and unexpand when reading from working dir
    99 restricted = 'merge kwexpand kwshrink record qrecord resolve transplant'
    99 restricted = 'merge kwexpand kwshrink record qrecord resolve transplant'
   100 
   100 
   101 # commands using dorecord
       
   102 recordcommands = 'record qrecord'
       
   103 # names of extensions using dorecord
   101 # names of extensions using dorecord
   104 recordextensions = 'record'
   102 recordextensions = 'record'
   105 
   103 
   106 # date like in cvs' $Date
   104 # date like in cvs' $Date
   107 utcdate = lambda x: util.datestr((x[0], 0), '%Y/%m/%d %H:%M:%S')
   105 utcdate = lambda x: util.datestr((x[0], 0), '%Y/%m/%d %H:%M:%S')
   153     def __init__(self, ui, repo, inc, exc):
   151     def __init__(self, ui, repo, inc, exc):
   154         self.ui = ui
   152         self.ui = ui
   155         self.repo = repo
   153         self.repo = repo
   156         self.match = match.match(repo.root, '', [], inc, exc)
   154         self.match = match.match(repo.root, '', [], inc, exc)
   157         self.restrict = kwtools['hgcmd'] in restricted.split()
   155         self.restrict = kwtools['hgcmd'] in restricted.split()
   158         self.record = kwtools['hgcmd'] in recordcommands.split()
   156         self.record = False
   159 
   157 
   160         kwmaps = self.ui.configitems('keywordmaps')
   158         kwmaps = self.ui.configitems('keywordmaps')
   161         if kwmaps: # override default templates
   159         if kwmaps: # override default templates
   162             self.templates = dict((k, templater.parsestring(v, False))
   160             self.templates = dict((k, templater.parsestring(v, False))
   163                                   for k, v in kwmaps)
   161                                   for k, v in kwmaps)
   568         '''Wraps record.dorecord expanding keywords after recording.'''
   566         '''Wraps record.dorecord expanding keywords after recording.'''
   569         wlock = repo.wlock()
   567         wlock = repo.wlock()
   570         try:
   568         try:
   571             # record returns 0 even when nothing has changed
   569             # record returns 0 even when nothing has changed
   572             # therefore compare nodes before and after
   570             # therefore compare nodes before and after
       
   571             kwt.record = True
   573             ctx = repo['.']
   572             ctx = repo['.']
   574             modified, added = repo[None].status()[:2]
   573             modified, added = repo[None].status()[:2]
   575             ret = orig(ui, repo, commitfunc, *pats, **opts)
   574             ret = orig(ui, repo, commitfunc, *pats, **opts)
   576             recctx = repo['.']
   575             recctx = repo['.']
   577             if ctx != recctx:
   576             if ctx != recctx: