hgkw/keyword.py
branchstable
changeset 746 72a272f1f756
parent 745 a72c2895fc26
child 747 25235530940d
equal deleted inserted replaced
744:62bfb4b0c1ea 746:72a272f1f756
   158         '''Returns true if path matches [keyword] pattern
   158         '''Returns true if path matches [keyword] pattern
   159         and is not a symbolic link.
   159         and is not a symbolic link.
   160         Caveat: localrepository._link fails on Windows.'''
   160         Caveat: localrepository._link fails on Windows.'''
   161         return self.match(path) and not 'l' in flagfunc(path)
   161         return self.match(path) and not 'l' in flagfunc(path)
   162 
   162 
   163     def overwrite(self, node, expand, candidates, recctx=None):
   163     def overwrite(self, node, expand, candidates):
   164         '''Overwrites selected files expanding/shrinking keywords.'''
   164         '''Overwrites selected files expanding/shrinking keywords.'''
   165         if recctx is None:
   165         ctx = self.repo[node]
   166             ctx = self.repo[node]
       
   167         else:
       
   168             ctx = recctx
       
   169         mf = ctx.manifest()
   166         mf = ctx.manifest()
   170         if node is not None:     # commit, record
   167         if node is not None:     # commit, record
   171             candidates = [f for f in ctx.files() if f in mf]
   168             candidates = [f for f in ctx.files() if f in mf]
   172         candidates = [f for f in candidates if self.iskwfile(f, ctx.flags)]
   169         candidates = [f for f in candidates if self.iskwfile(f, ctx.flags)]
   173         if candidates:
   170         if candidates:
   174             self.restrict = True # do not expand when reading
   171             self.restrict = True # do not expand when reading
   175             msg = (expand and _('overwriting %s expanding keywords\n')
   172             msg = (expand and _('overwriting %s expanding keywords\n')
   176                    or _('overwriting %s shrinking keywords\n'))
   173                    or _('overwriting %s shrinking keywords\n'))
   177             for f in candidates:
   174             for f in candidates:
   178                 if recctx is None:
   175                 if not self.record:
   179                     data = self.repo.file(f).read(mf[f])
   176                     data = self.repo.file(f).read(mf[f])
   180                 else:
   177                 else:
   181                     data = self.repo.wread(f)
   178                     data = self.repo.wread(f)
   182                 if util.binary(data):
   179                 if util.binary(data):
   183                     continue
   180                     continue
   505             # therefore compare nodes before and after
   502             # therefore compare nodes before and after
   506             ctx = repo['.']
   503             ctx = repo['.']
   507             ret = orig(ui, repo, commitfunc, *pats, **opts)
   504             ret = orig(ui, repo, commitfunc, *pats, **opts)
   508             recctx = repo['.']
   505             recctx = repo['.']
   509             if ctx != recctx:
   506             if ctx != recctx:
   510                 kwt.overwrite('.',  True, None, recctx)
   507                 kwt.overwrite('.',  True, None)
   511             return ret
   508             return ret
   512         finally:
   509         finally:
   513             wlock.release()
   510             wlock.release()
   514 
   511 
   515     repo.__class__ = kwrepo
   512     repo.__class__ = kwrepo