##// END OF EJS Templates
keyword: make repo.commit use a custom commitctx wrapper...
Christian Ebert -
r8996:23e941d7 default
parent child Browse files
Show More
@@ -189,7 +189,8 b' class kwtemplater(object):'
189 if found:
189 if found:
190 notify(msg % f)
190 notify(msg % f)
191 self.repo.wwrite(f, data, mf.flags(f))
191 self.repo.wwrite(f, data, mf.flags(f))
192 self.repo.dirstate.normal(f)
192 if node is None:
193 self.repo.dirstate.normal(f)
193 self.restrict = False
194 self.restrict = False
194
195
195 def shrinktext(self, text):
196 def shrinktext(self, text):
@@ -460,8 +461,14 b' def reposetup(ui, repo):'
460
461
461 def commit(self, text='', user=None, date=None, match=None,
462 def commit(self, text='', user=None, date=None, match=None,
462 force=False, editor=None, extra={}):
463 force=False, editor=None, extra={}):
464 # use custom commitctx for user commands
465 # other extensions can still wrap repo.commitctx directly
466 repo.commitctx = self.kwcommitctx
467 return super(kwrepo, self).commit(text, user, date, match, force,
468 editor, extra)
469
470 def kwcommitctx(self, ctx, error=False):
463 wlock = lock = None
471 wlock = lock = None
464 _p1 = _p2 = None
465 try:
472 try:
466 wlock = self.wlock()
473 wlock = self.wlock()
467 lock = self.lock()
474 lock = self.lock()
@@ -472,23 +479,17 b' def reposetup(ui, repo):'
472 commithooks[name] = cmd
479 commithooks[name] = cmd
473 ui.setconfig('hooks', name, None)
480 ui.setconfig('hooks', name, None)
474 if commithooks:
481 if commithooks:
475 # store parents for commit hook environment
482 # store parents for commit hooks
476 _p1, _p2 = repo.dirstate.parents()
483 p1, p2 = ctx.p1(), ctx.p2()
477 _p1 = hex(_p1)
484 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
478 if _p2 == nullid:
485
479 _p2 = ''
486 n = super(kwrepo, self).commitctx(ctx, error)
480 else:
481 _p2 = hex(_p2)
482
487
483 n = super(kwrepo, self).commit(text, user, date, match, force,
488 kwt.overwrite(n, True, None)
484 editor, extra)
489 if commithooks:
485
490 for name, cmd in commithooks.iteritems():
486 # restore commit hooks
491 ui.setconfig('hooks', name, cmd)
487 for name, cmd in commithooks.iteritems():
492 repo.hook('commit', node=n, parent1=xp1, parent2=xp2)
488 ui.setconfig('hooks', name, cmd)
489 if n is not None:
490 kwt.overwrite(n, True, None)
491 repo.hook('commit', node=n, parent1=_p1, parent2=_p2)
492 return n
493 return n
493 finally:
494 finally:
494 release(lock, wlock)
495 release(lock, wlock)
General Comments 0
You need to be logged in to leave comments. Login now