hgkw/keyword.py
branchkwmap-templates
changeset 175 f8e5cafa7b99
parent 174 c5f655d5d8b4
child 176 3aed363c9eaf
equal deleted inserted replaced
174:c5f655d5d8b4 175:f8e5cafa7b99
   230             exc.append(pat)
   230             exc.append(pat)
   231     if not inc:
   231     if not inc:
   232         return
   232         return
   233 
   233 
   234     kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
   234     kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
       
   235     ui = repo.ui
   235 
   236 
   236     class kwrepo(repo.__class__):
   237     class kwrepo(repo.__class__):
   237         '''
   238         '''
   238         Subclass of repo's class attribute to wrap its file and commit methods.
   239         Subclass of repo's class attribute to wrap its file and commit methods.
   239         '''
   240         '''
   241         def file(self, f):
   242         def file(self, f):
   242             '''Opens kwfilelog instead of filelog if needed.'''
   243             '''Opens kwfilelog instead of filelog if needed.'''
   243             if f[0] == '/':
   244             if f[0] == '/':
   244                 f = f[1:]
   245                 f = f[1:]
   245             if kwfmatcher(f):
   246             if kwfmatcher(f):
   246                 kwt = kwtemplater(repo.ui, self, path=f)
   247                 kwt = kwtemplater(ui, self, path=f)
   247                 return kwfilelog(self.sopener, f, kwt)
   248                 return kwfilelog(self.sopener, f, kwt)
   248             else:
   249             else:
   249                 return filelog.filelog(self.sopener, f)
   250                 return filelog.filelog(self.sopener, f)
   250 
   251 
   251         def commit(self, files=None, text="", user=None, date=None,
   252         def commit(self, files=None, text="", user=None, date=None,
   275                               and f not in removed
   276                               and f not in removed
   276                               and not os.path.islink(self.wjoin(f))]
   277                               and not os.path.islink(self.wjoin(f))]
   277                 if not candidates:
   278                 if not candidates:
   278                     return node
   279                     return node
   279 
   280 
   280                 kwt = kwtemplater(repo.ui, self, node=node)
   281                 kwt = kwtemplater(ui, self, node=node)
   281                 kwt.overwrite(candidates)
   282                 kwt.overwrite(candidates)
   282                 return node
   283                 return node
   283             finally:
   284             finally:
   284                 if wrelease:
   285                 if wrelease:
   285                     wlock.release()
   286                     wlock.release()