Show More
@@ -480,7 +480,14 b' def reposetup(ui, repo):' | |||
|
480 | 480 | # other extensions can still wrap repo.commitctx directly |
|
481 | 481 | self.commitctx = self.kwcommitctx |
|
482 | 482 | try: |
|
483 | return super(kwrepo, self).commit(*args, **opts) | |
|
483 | self._kwcommithooks = {} | |
|
484 | n = super(kwrepo, self).commit(*args, **opts) | |
|
485 | if self._kwcommithooks: | |
|
486 | xp1, xp2 = self._kwxp1, self._kwxp2 | |
|
487 | for name, cmd in self._kwcommithooks.iteritems(): | |
|
488 | ui.setconfig('hooks', name, cmd) | |
|
489 | self.hook('commit', node=n, parent1=xp1, parent2=xp2) | |
|
490 | return n | |
|
484 | 491 | finally: |
|
485 | 492 | del self.commitctx |
|
486 | 493 | |
@@ -490,23 +497,18 b' def reposetup(ui, repo):' | |||
|
490 | 497 | wlock = self.wlock() |
|
491 | 498 | lock = self.lock() |
|
492 | 499 | # store and postpone commit hooks |
|
493 | commithooks = {} | |
|
494 | 500 | for name, cmd in ui.configitems('hooks'): |
|
495 | 501 | if name.split('.', 1)[0] == 'commit': |
|
496 | commithooks[name] = cmd | |
|
502 | self._kwcommithooks[name] = cmd | |
|
497 | 503 | ui.setconfig('hooks', name, None) |
|
498 | if commithooks: | |
|
504 | if self._kwcommithooks: | |
|
499 | 505 | # store parents for commit hooks |
|
500 | 506 | p1, p2 = ctx.p1(), ctx.p2() |
|
501 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
|
507 | self._kwxp1, self._kwxp2 = p1.hex(), p2 and p2.hex() or '' | |
|
502 | 508 | |
|
503 | 509 | n = super(kwrepo, self).commitctx(ctx, error) |
|
504 | 510 | |
|
505 | 511 | kwt.overwrite(n, True, None) |
|
506 | if commithooks: | |
|
507 | for name, cmd in commithooks.iteritems(): | |
|
508 | ui.setconfig('hooks', name, cmd) | |
|
509 | self.hook('commit', node=n, parent1=xp1, parent2=xp2) | |
|
510 | 512 | return n |
|
511 | 513 | finally: |
|
512 | 514 | release(lock, wlock) |
@@ -846,6 +846,8 b' class localrepository(repo.repository):' | |||
|
846 | 846 | msgfile.close() |
|
847 | 847 | |
|
848 | 848 | try: |
|
849 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') | |
|
850 | self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2) | |
|
849 | 851 | ret = self.commitctx(cctx, True) |
|
850 | 852 | except: |
|
851 | 853 | if edited: |
@@ -861,15 +863,14 b' class localrepository(repo.repository):' | |||
|
861 | 863 | self.dirstate.forget(f) |
|
862 | 864 | self.dirstate.setparents(ret) |
|
863 | 865 | ms.reset() |
|
864 | ||
|
865 | return ret | |
|
866 | ||
|
867 | 866 | finally: |
|
868 | 867 | wlock.release() |
|
869 | 868 | |
|
869 | self.hook("commit", node=hex(ret), parent1=hookp1, parent2=hookp2) | |
|
870 | return ret | |
|
871 | ||
|
870 | 872 | def commitctx(self, ctx, error=False): |
|
871 | 873 | """Add a new revision to current repository. |
|
872 | ||
|
873 | 874 | Revision information is passed via the context argument. |
|
874 | 875 | """ |
|
875 | 876 | |
@@ -880,9 +881,6 b' class localrepository(repo.repository):' | |||
|
880 | 881 | m2 = p2.manifest() |
|
881 | 882 | user = ctx.user() |
|
882 | 883 | |
|
883 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
|
884 | self.hook("precommit", throw=True, parent1=xp1, parent2=xp2) | |
|
885 | ||
|
886 | 884 | lock = self.lock() |
|
887 | 885 | try: |
|
888 | 886 | tr = self.transaction() |
@@ -925,6 +923,7 b' class localrepository(repo.repository):' | |||
|
925 | 923 | trp, p1.node(), p2.node(), |
|
926 | 924 | user, ctx.date(), ctx.extra().copy()) |
|
927 | 925 | p = lambda: self.changelog.writepending() and self.root or "" |
|
926 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
|
928 | 927 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
929 | 928 | parent2=xp2, pending=p) |
|
930 | 929 | self.changelog.finalize(trp) |
@@ -932,8 +931,6 b' class localrepository(repo.repository):' | |||
|
932 | 931 | |
|
933 | 932 | if self._branchcache: |
|
934 | 933 | self.branchtags() |
|
935 | ||
|
936 | self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) | |
|
937 | 934 | return n |
|
938 | 935 | finally: |
|
939 | 936 | del tr |
@@ -511,8 +511,9 b' def update(repo, node, branchmerge, forc' | |||
|
511 | 511 | repo.dirstate.setparents(fp1, fp2) |
|
512 | 512 | if not branchmerge and not fastforward: |
|
513 | 513 | repo.dirstate.setbranch(p2.branch()) |
|
514 | repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) | |
|
515 | ||
|
516 | return stats | |
|
517 | 514 | finally: |
|
518 | 515 | wlock.release() |
|
516 | ||
|
517 | if not partial: | |
|
518 | repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) | |
|
519 | return stats |
@@ -205,8 +205,8 b" echo '# make sure --traceback works'" | |||
|
205 | 205 | echo '[hooks]' > .hg/hgrc |
|
206 | 206 | echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc |
|
207 | 207 | |
|
208 |
echo a |
|
|
209 |
hg --traceback commit - |
|
|
208 | echo aa > a | |
|
209 | hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback' | |
|
210 | 210 | |
|
211 | 211 | cd .. |
|
212 | 212 | hg init c |
@@ -224,9 +224,9 b" echo 'hookext = hookext.py' >> .hg/hgrc" | |||
|
224 | 224 | |
|
225 | 225 | touch foo |
|
226 | 226 | hg add foo |
|
227 | hg ci -m 'add foo' | |
|
227 | hg ci -d '0 0' -m 'add foo' | |
|
228 | 228 | echo >> foo |
|
229 | hg ci --debug -m 'change foo' | sed -e 's/ at .*>/>/' | |
|
229 | hg ci --debug -d '0 0' -m 'change foo' | sed -e 's/ at .*>/>/' | |
|
230 | 230 | |
|
231 | 231 | hg showconfig hooks | sed -e 's/ at .*>/>/' |
|
232 | 232 | |
@@ -246,7 +246,7 b" echo '[hooks]' > ../repo/.hg/hgrc" | |||
|
246 | 246 | echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc |
|
247 | 247 | |
|
248 | 248 | cd ../repo |
|
249 | hg commit | |
|
249 | hg commit -d '0 0' | |
|
250 | 250 | |
|
251 | 251 | cd ../../b |
|
252 | 252 | echo '# make sure --traceback works on hook import failure' |
@@ -260,6 +260,14 b" echo '[hooks]' > .hg/hgrc" | |||
|
260 | 260 | echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc |
|
261 | 261 | |
|
262 | 262 | echo a >> a |
|
263 |
hg --traceback commit - |
|
|
263 | hg --traceback commit -d '0 0' -ma 2>&1 | egrep '^(exception|Traceback|ImportError)' | |
|
264 | ||
|
265 | echo '# commit and update hooks should run after command completion (issue 1827)' | |
|
266 | echo '[hooks]' > .hg/hgrc | |
|
267 | echo 'commit = hg id' >> .hg/hgrc | |
|
268 | echo 'update = hg id' >> .hg/hgrc | |
|
269 | echo bb > a | |
|
270 | hg ci -d '0 0' -ma | |
|
271 | hg up 0 | |
|
264 | 272 | |
|
265 | 273 | exit 0 |
@@ -171,3 +171,7 b' exception from second failed import atte' | |||
|
171 | 171 | Traceback (most recent call last): |
|
172 | 172 | ImportError: No module named hgext_importfail |
|
173 | 173 | Traceback (most recent call last): |
|
174 | # commit and update hooks should run after command completion (issue 1827) | |
|
175 | 8da618c33484 tip | |
|
176 | 29b62aeb769f | |
|
177 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
General Comments 0
You need to be logged in to leave comments.
Login now