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