hgkw/keyword.py
changeset 979 6cabb1c47f21
parent 973 82015736cc7e
child 981 0b32ba113ad2
equal deleted inserted replaced
978:600f20908ede 979:6cabb1c47f21
   247         if not candidates:
   247         if not candidates:
   248             return
   248             return
   249         kwcmd = self.restrict and lookup # kwexpand/kwshrink
   249         kwcmd = self.restrict and lookup # kwexpand/kwshrink
   250         if self.restrict or expand and lookup:
   250         if self.restrict or expand and lookup:
   251             mf = ctx.manifest()
   251             mf = ctx.manifest()
       
   252         if self.restrict or rekw:
       
   253             re_kw = self.rekw
       
   254         else:
       
   255             re_kw = self.rekwexp
       
   256         if expand:
       
   257             msg = _('overwriting %s expanding keywords\n')
       
   258         else:
       
   259             msg = _('overwriting %s shrinking keywords\n')
   252         lctx = ctx
   260         lctx = ctx
   253         re_kw = (self.restrict or rekw) and self.rekw or self.rekwexp
       
   254         msg = (expand and _('overwriting %s expanding keywords\n')
       
   255                or _('overwriting %s shrinking keywords\n'))
       
   256         for f in candidates:
   261         for f in candidates:
   257             if self.restrict:
   262             if self.restrict:
   258                 data = self.repo.file(f).read(mf[f])
   263                 data = self.repo.file(f).read(mf[f])
   259             else:
   264             else:
   260                 data = self.repo.wread(f)
   265                 data = self.repo.wread(f)
   291         return lines
   296         return lines
   292 
   297 
   293     def wread(self, fname, data):
   298     def wread(self, fname, data):
   294         '''If in restricted mode returns data read from wdir with
   299         '''If in restricted mode returns data read from wdir with
   295         keyword substitutions removed.'''
   300         keyword substitutions removed.'''
   296         return self.restrict and self.shrink(fname, data) or data
   301         if self.restrict:
       
   302             return self.shrink(fname, data)
       
   303         return data
   297 
   304 
   298 class kwfilelog(filelog.filelog):
   305 class kwfilelog(filelog.filelog):
   299     '''
   306     '''
   300     Subclass of filelog to hook into its read, add, cmp methods.
   307     Subclass of filelog to hook into its read, add, cmp methods.
   301     Keywords are "stored" unexpanded, and processed on reading.
   308     Keywords are "stored" unexpanded, and processed on reading.
   410             ui.status(_('\tdisabling current template maps\n'))
   417             ui.status(_('\tdisabling current template maps\n'))
   411             for k, v in kwmaps.iteritems():
   418             for k, v in kwmaps.iteritems():
   412                 ui.setconfig('keywordmaps', k, v)
   419                 ui.setconfig('keywordmaps', k, v)
   413     else:
   420     else:
   414         ui.status(_('\n\tconfiguration using current keyword template maps\n'))
   421         ui.status(_('\n\tconfiguration using current keyword template maps\n'))
   415         kwmaps = dict(uikwmaps) or _defaultkwmaps(ui)
   422         if uikwmaps:
       
   423             kwmaps = dict(uikwmaps)
       
   424         else:
       
   425             kwmaps = _defaultkwmaps(ui)
   416 
   426 
   417     uisetup(ui)
   427     uisetup(ui)
   418     reposetup(ui, repo)
   428     reposetup(ui, repo)
   419     ui.write('[extensions]\nkeyword =\n')
   429     ui.write('[extensions]\nkeyword =\n')
   420     demoitems('keyword', ui.configitems('keyword'))
   430     demoitems('keyword', ui.configitems('keyword'))