Mercurial > hg-stable
comparison mercurial/localrepo.py @ 1721:801756d0ca84
add pretxncommit hook.
hook allows check of changeset after create, but before transaction
is committed. hook failure rolls transaction back.
makes place for local policies like commit message must contain bug id
or reviewer signoff.
change also adds parent changeset ids to commit hook environment,
because is cheap and useful.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 14 Feb 2006 17:13:18 -0800 |
parents | 98072468ffde |
children | 56fb048b102c 0f1d2c75db5e |
comparison
equal
deleted
inserted
replaced
1720:55017891051b | 1721:801756d0ca84 |
---|---|
374 | 374 |
375 if not commit and not remove and not force and p2 == nullid: | 375 if not commit and not remove and not force and p2 == nullid: |
376 self.ui.status(_("nothing changed\n")) | 376 self.ui.status(_("nothing changed\n")) |
377 return None | 377 return None |
378 | 378 |
379 self.hook("precommit", throw=True) | 379 xp1 = hex(p1) |
380 if p2 == nullid: xp2 = '' | |
381 else: xp2 = hex(p2) | |
382 | |
383 self.hook("precommit", throw=True, p1=xp1, p2=xp2) | |
380 | 384 |
381 if not wlock: | 385 if not wlock: |
382 wlock = self.wlock() | 386 wlock = self.wlock() |
383 lock = self.lock() | 387 lock = self.lock() |
384 tr = self.transaction() | 388 tr = self.transaction() |
460 return None | 464 return None |
461 text = edittext | 465 text = edittext |
462 | 466 |
463 user = user or self.ui.username() | 467 user = user or self.ui.username() |
464 n = self.changelog.add(mn, changed + remove, text, tr, p1, p2, user, date) | 468 n = self.changelog.add(mn, changed + remove, text, tr, p1, p2, user, date) |
469 self.hook('pretxncommit', throw=True, node=hex(n), p1=xp1, p2=xp2) | |
465 tr.close() | 470 tr.close() |
466 | 471 |
467 self.dirstate.setparents(n) | 472 self.dirstate.setparents(n) |
468 self.dirstate.update(new, "n") | 473 self.dirstate.update(new, "n") |
469 self.dirstate.forget(remove) | 474 self.dirstate.forget(remove) |
470 | 475 |
471 self.hook("commit", node=hex(n)) | 476 self.hook("commit", node=hex(n), p1=xp1, p2=xp2) |
472 return n | 477 return n |
473 | 478 |
474 def walk(self, node=None, files=[], match=util.always): | 479 def walk(self, node=None, files=[], match=util.always): |
475 if node: | 480 if node: |
476 fdict = dict.fromkeys(files) | 481 fdict = dict.fromkeys(files) |