hgkw/keyword.py
branchstable
changeset 531 f7865fb770fe
parent 529 7197324dfa4d
child 532 70220c2a4940
equal deleted inserted replaced
529:7197324dfa4d 531:f7865fb770fe
   177         else:                    # kwexpand/kwshrink
   177         else:                    # kwexpand/kwshrink
   178             notify = self.ui.note
   178             notify = self.ui.note
   179         candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
   179         candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
   180         if candidates:
   180         if candidates:
   181             self.restrict = True # do not expand when reading
   181             self.restrict = True # do not expand when reading
   182             action = expand and 'expanding' or 'shrinking'
       
   183             for f in candidates:
   182             for f in candidates:
   184                 fp = self.repo.file(f)
   183                 fp = self.repo.file(f)
   185                 data = fp.read(mf[f])
   184                 data = fp.read(mf[f])
   186                 if util.binary(data):
   185                 if util.binary(data):
   187                     continue
   186                     continue
   191                     data, found = self.substitute(data, f, ctx,
   190                     data, found = self.substitute(data, f, ctx,
   192                                                   self.re_kw.subn)
   191                                                   self.re_kw.subn)
   193                 else:
   192                 else:
   194                     found = self.re_kw.search(data)
   193                     found = self.re_kw.search(data)
   195                 if found:
   194                 if found:
   196                     notify(_('overwriting %s %s keywords\n') % (f, action))
   195                     if expand:
       
   196                         msg = _('overwriting %s expanding keywords\n')
       
   197                     else:
       
   198                         msg = _('overwriting %s shrinking keywords\n')
       
   199                     notify(msg % f)
   197                     self.repo.wwrite(f, data, mf.flags(f))
   200                     self.repo.wwrite(f, data, mf.flags(f))
   198                     self.repo.dirstate.normal(f)
   201                     self.repo.dirstate.normal(f)
   199             self.restrict = False
   202             self.restrict = False
   200 
   203 
   201     def shrinktext(self, text):
   204     def shrinktext(self, text):