226 else: |
226 else: |
227 exc.append(pat) |
227 exc.append(pat) |
228 if not inc: |
228 if not inc: |
229 return |
229 return |
230 |
230 |
231 repo.kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
231 kwfmatcher = util.matcher(repo.root, inc=inc, exc=exc)[1] |
232 |
232 |
233 class kwrepo(repo.__class__): |
233 class kwrepo(repo.__class__): |
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 self.kwfmatcher(f): |
238 if kwfmatcher(f): |
239 kwt = kwtemplater(self.ui, self, path=f) |
239 kwt = kwtemplater(repo.ui, repo, path=f) |
240 return kwfilelog(self.sopener, f, kwt) |
240 return kwfilelog(repo.sopener, f, kwt) |
241 else: |
241 else: |
242 return filelog.filelog(self.sopener, f) |
242 return filelog.filelog(repo.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 = self.wlock() |
251 wlock = repo.wlock() |
252 wrelease = True |
252 wrelease = True |
253 try: |
253 try: |
254 removed = self.status()[2] |
254 removed = repo.status(node1=p1, node2=p2, files=files, |
|
255 match=match, wlock=wlock)[2] |
255 |
256 |
256 node = super(kwrepo, |
257 node = super(kwrepo, |
257 self).commit(files=files, text=text, user=user, |
258 self).commit(files=files, text=text, user=user, |
258 date=date, match=match, force=force, |
259 date=date, match=match, force=force, |
259 lock=lock, wlock=wlock, |
260 lock=lock, wlock=wlock, |
260 force_editor=force_editor, |
261 force_editor=force_editor, |
261 p1=p1, p2=p2, extra=extra) |
262 p1=p1, p2=p2, extra=extra) |
262 if node is None: |
263 if node is None: |
263 return node |
264 return node |
264 |
265 |
265 candidates = self.changelog.read(node)[3] |
266 candidates = repo.changelog.read(node)[3] |
266 candidates = [f for f in candidates if self.kwfmatcher(f) |
267 candidates = [f for f in candidates if kwfmatcher(f) |
267 and f not in removed |
268 and f not in removed |
268 and not os.path.islink(self.wjoin(f))] |
269 and not os.path.islink(self.wjoin(f))] |
269 if not candidates: |
270 if not candidates: |
270 return node |
271 return node |
271 |
272 |
272 kwt = kwtemplater(self.ui, self, node=node) |
273 kwt = kwtemplater(repo.ui, repo, node=node) |
273 kwt.overwrite(candidates) |
274 kwt.overwrite(candidates) |
274 return node |
275 return node |
275 finally: |
276 finally: |
276 if wrelease: |
277 if wrelease: |
277 wlock.release() |
278 wlock.release() |