hgkw/keyword.py
changeset 533 fa7d7d6ca1ad
parent 532 70220c2a4940
child 534 43d8c042ca20
equal deleted inserted replaced
530:09d1575f16c7 533:fa7d7d6ca1ad
   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'
   182             msg = (expand and _('overwriting %s expanding keywords\n')
       
   183                    or _('overwriting %s shrinking keywords\n'))
   183             for f in candidates:
   184             for f in candidates:
   184                 fp = self.repo.file(f)
   185                 fp = self.repo.file(f)
   185                 data = fp.read(mf[f])
   186                 data = fp.read(mf[f])
   186                 if util.binary(data):
   187                 if util.binary(data):
   187                     continue
   188                     continue
   191                     data, found = self.substitute(data, f, ctx,
   192                     data, found = self.substitute(data, f, ctx,
   192                                                   self.re_kw.subn)
   193                                                   self.re_kw.subn)
   193                 else:
   194                 else:
   194                     found = self.re_kw.search(data)
   195                     found = self.re_kw.search(data)
   195                 if found:
   196                 if found:
   196                     notify(_('overwriting %s %s keywords\n') % (f, action))
   197                     notify(msg % f)
   197                     self.repo.wwrite(f, data, mf.flags(f))
   198                     self.repo.wwrite(f, data, mf.flags(f))
   198                     self.repo.dirstate.normal(f)
   199                     self.repo.dirstate.normal(f)
   199             self.restrict = False
   200             self.restrict = False
   200 
   201 
   201     def shrinktext(self, text):
   202     def shrinktext(self, text):