hgkw/keyword.py
changeset 700 bf7b214673e2
parent 699 57f8b7f021e8
child 701 ad66e72df159
equal deleted inserted replaced
699:57f8b7f021e8 700:bf7b214673e2
   166         '''Overwrites selected files expanding/shrinking keywords.'''
   166         '''Overwrites selected files expanding/shrinking keywords.'''
   167         ctx = self.repo[node]
   167         ctx = self.repo[node]
   168         mf = ctx.manifest()
   168         mf = ctx.manifest()
   169         if node is not None:     # commit
   169         if node is not None:     # commit
   170             files = [f for f in ctx.files() if f in mf]
   170             files = [f for f in ctx.files() if f in mf]
   171             notify = self.ui.debug
       
   172         else:                    # kwexpand/kwshrink
       
   173             notify = self.ui.note
       
   174         candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
   171         candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
   175         if candidates:
   172         if candidates:
   176             self.restrict = True # do not expand when reading
   173             self.restrict = True # do not expand when reading
   177             msg = (expand and _('overwriting %s expanding keywords\n')
   174             msg = (expand and _('overwriting %s expanding keywords\n')
   178                    or _('overwriting %s shrinking keywords\n'))
   175                    or _('overwriting %s shrinking keywords\n'))
   187                     data, found = self.substitute(data, f, ctx,
   184                     data, found = self.substitute(data, f, ctx,
   188                                                   self.re_kw.subn)
   185                                                   self.re_kw.subn)
   189                 else:
   186                 else:
   190                     found = self.re_kw.search(data)
   187                     found = self.re_kw.search(data)
   191                 if found:
   188                 if found:
   192                     notify(msg % f)
   189                     self.ui.note(msg % f)
   193                     self.repo.wwrite(f, data, mf.flags(f))
   190                     self.repo.wwrite(f, data, mf.flags(f))
   194                     if node is None:
   191                     if node is None:
   195                         self.repo.dirstate.normal(f)
   192                         self.repo.dirstate.normal(f)
   196             self.restrict = False
   193             self.restrict = False
   197 
   194