hgkw/keyword.py
branch0.9.2compat
changeset 984 a4ea5c2d3ff3
parent 704 772628d1ccb5
parent 981 0b32ba113ad2
equal deleted inserted replaced
707:e5feed5534d7 984:a4ea5c2d3ff3
   336         else:
   336         else:
   337             islink = mf.linkf
   337             islink = mf.linkf
   338         candidates = [f for f in candidates if self.iskwfile(f, islink)]
   338         candidates = [f for f in candidates if self.iskwfile(f, islink)]
   339         if candidates:
   339         if candidates:
   340             self.restrict = True # do not expand when reading
   340             self.restrict = True # do not expand when reading
   341             msg = (expand and _('overwriting %s expanding keywords\n')
   341             if expand:
   342                    or _('overwriting %s shrinking keywords\n'))
   342                 msg = _('overwriting %s expanding keywords\n')
       
   343             else:
       
   344                 msg = _('overwriting %s shrinking keywords\n')
   343             overwritten = []
   345             overwritten = []
   344             for f in candidates:
   346             for f in candidates:
   345                 fp = self.repo.file(f)
   347                 fp = self.repo.file(f)
   346                 data = fp.read(mf[f])
   348                 data = fp.read(mf[f])
   347                 if not textsafe(data):
   349                 if not textsafe(data):
   352                                                   self.re_kw.subn)
   354                                                   self.re_kw.subn)
   353                 else:
   355                 else:
   354                     found = self.re_kw.search(data)
   356                     found = self.re_kw.search(data)
   355                 if found:
   357                 if found:
   356                     self.ui.note(msg % f)
   358                     self.ui.note(msg % f)
       
   359                     fpath = self.repo.wjoin(f)
       
   360                     mode = os.lstat(fpath).st_mode
   357                     self.repo.wwrite(f, data, mf.flags(f))
   361                     self.repo.wwrite(f, data, mf.flags(f))
       
   362                     os.chmod(fpath, mode)
   358                     overwritten.append(f)
   363                     overwritten.append(f)
   359             _normal(self.repo, overwritten)
   364             _normal(self.repo, overwritten)
   360             self.restrict = False
   365             self.restrict = False
   361 
   366 
   362     def shrinktext(self, text):
   367     def shrinktext(self, text):
   564     kwt = kwtools['templater']
   569     kwt = kwtools['templater']
   565     status = _status(ui, repo, kwt, *pats, **opts)
   570     status = _status(ui, repo, kwt, *pats, **opts)
   566     cwd = pats and repo.getcwd() or ''
   571     cwd = pats and repo.getcwd() or ''
   567     modified, added, removed, deleted, unknown, ignored, clean = status
   572     modified, added, removed, deleted, unknown, ignored, clean = status
   568     files = []
   573     files = []
   569     if not opts.get('unknown') or ops.get('all'):
   574     if not opts.get('unknown') or opts.get('all'):
   570         try:
   575         try:
   571             # f67d1468ac50
   576             # f67d1468ac50
   572             files = util.sort(modified + added + clean)
   577             files = util.sort(modified + added + clean)
   573         except AttributeError:
   578         except AttributeError:
   574             files = modified + added + clean
   579             files = modified + added + clean