hgkw/keyword.py
branchkwmap-templates
changeset 172 ad0da655bd12
parent 171 8713a7a3f5ab
child 173 5329863fb64e
equal deleted inserted replaced
171:8713a7a3f5ab 172:ad0da655bd12
   234         def file(self, f):
   234         def file(self, f):
   235             if f[0] == '/':
   235             if f[0] == '/':
   236                 f = f[1:]
   236                 f = f[1:]
   237             # only use kwfilelog when needed
   237             # only use kwfilelog when needed
   238             if kwfmatcher(f):
   238             if kwfmatcher(f):
   239                 kwt = kwtemplater(repo.ui, repo, path=f)
   239                 kwt = kwtemplater(repo.ui, self, path=f)
   240                 return kwfilelog(repo.sopener, f, kwt)
   240                 return kwfilelog(self.sopener, f, kwt)
   241             else:
   241             else:
   242                 return filelog.filelog(repo.sopener, f)
   242                 return filelog.filelog(self.sopener, f)
   243 
   243 
   244         def commit(self, files=None, text="", user=None, date=None,
   244         def commit(self, files=None, text="", user=None, date=None,
   245                    match=util.always, force=False, lock=None, wlock=None,
   245                    match=util.always, force=False, lock=None, wlock=None,
   246                    force_editor=False, p1=None, p2=None, extra={}):
   246                    force_editor=False, p1=None, p2=None, extra={}):
   247             '''Wraps commit, expanding keywords of committed and
   247             '''Wraps commit, expanding keywords of committed and
   248             configured files in working directory.'''
   248             configured files in working directory.'''
   249             wrelease = False
   249             wrelease = False
   250             if not wlock:
   250             if not wlock:
   251                 wlock = repo.wlock()
   251                 wlock = self.wlock()
   252                 wrelease = True
   252                 wrelease = True
   253             try:
   253             try:
   254                 removed = repo.status(node1=p1, node2=p2, files=files,
   254                 removed = self.status(node1=p1, node2=p2, files=files,
   255                                       match=match, wlock=wlock)[2]
   255                                       match=match, wlock=wlock)[2]
   256 
   256 
   257                 node = super(kwrepo,
   257                 node = super(kwrepo,
   258                              self).commit(files=files, text=text, user=user,
   258                              self).commit(files=files, text=text, user=user,
   259                                           date=date, match=match, force=force,
   259                                           date=date, match=match, force=force,
   261                                           force_editor=force_editor,
   261                                           force_editor=force_editor,
   262                                           p1=p1, p2=p2, extra=extra)
   262                                           p1=p1, p2=p2, extra=extra)
   263                 if node is None:
   263                 if node is None:
   264                     return node
   264                     return node
   265 
   265 
   266                 candidates = repo.changelog.read(node)[3]
   266                 candidates = self.changelog.read(node)[3]
   267                 candidates = [f for f in candidates if kwfmatcher(f)
   267                 candidates = [f for f in candidates if kwfmatcher(f)
   268                               and f not in removed
   268                               and f not in removed
   269                               and not os.path.islink(self.wjoin(f))]
   269                               and not os.path.islink(self.wjoin(f))]
   270                 if not candidates:
   270                 if not candidates:
   271                     return node
   271                     return node
   272 
   272 
   273                 kwt = kwtemplater(repo.ui, repo, node=node)
   273                 kwt = kwtemplater(repo.ui, self, node=node)
   274                 kwt.overwrite(candidates)
   274                 kwt.overwrite(candidates)
   275                 return node
   275                 return node
   276             finally:
   276             finally:
   277                 if wrelease:
   277                 if wrelease:
   278                     wlock.release()
   278                     wlock.release()