Show More
@@ -407,15 +407,13 class cg1unpacker(object): | |||||
407 | repo.invalidatevolatilesets() |
|
407 | repo.invalidatevolatilesets() | |
408 |
|
408 | |||
409 | if changesets > 0: |
|
409 | if changesets > 0: | |
410 | p = lambda: tr.writepending() and repo.root or "" |
|
|||
411 | if 'node' not in tr.hookargs: |
|
410 | if 'node' not in tr.hookargs: | |
412 | tr.hookargs['node'] = hex(cl.node(clstart)) |
|
411 | tr.hookargs['node'] = hex(cl.node(clstart)) | |
413 | hookargs = dict(tr.hookargs) |
|
412 | hookargs = dict(tr.hookargs) | |
414 | else: |
|
413 | else: | |
415 | hookargs = dict(tr.hookargs) |
|
414 | hookargs = dict(tr.hookargs) | |
416 | hookargs['node'] = hex(cl.node(clstart)) |
|
415 | hookargs['node'] = hex(cl.node(clstart)) | |
417 |
repo.hook('pretxnchangegroup', throw=True, |
|
416 | repo.hook('pretxnchangegroup', throw=True, **hookargs) | |
418 | **hookargs) |
|
|||
419 |
|
417 | |||
420 | added = [cl.node(r) for r in xrange(clstart, clend)] |
|
418 | added = [cl.node(r) for r in xrange(clstart, clend)] | |
421 | publishing = repo.publishing() |
|
419 | publishing = repo.publishing() |
@@ -118,6 +118,13 def _exthook(ui, repo, name, cmd, args, | |||||
118 |
|
118 | |||
119 | starttime = time.time() |
|
119 | starttime = time.time() | |
120 | env = {} |
|
120 | env = {} | |
|
121 | ||||
|
122 | # make in-memory changes visible to external process | |||
|
123 | tr = repo.currenttransaction() | |||
|
124 | repo.dirstate.write(tr) | |||
|
125 | if tr and tr.writepending(): | |||
|
126 | env['HG_PENDING'] = repo.root | |||
|
127 | ||||
121 | for k, v in args.iteritems(): |
|
128 | for k, v in args.iteritems(): | |
122 | if callable(v): |
|
129 | if callable(v): | |
123 | v = v() |
|
130 | v = v() |
@@ -994,8 +994,7 class localrepository(object): | |||||
994 | reporef = weakref.ref(self) |
|
994 | reporef = weakref.ref(self) | |
995 | def validate(tr): |
|
995 | def validate(tr): | |
996 | """will run pre-closing hooks""" |
|
996 | """will run pre-closing hooks""" | |
997 | pending = lambda: tr.writepending() and self.root or "" |
|
997 | reporef().hook('pretxnclose', throw=True, | |
998 | reporef().hook('pretxnclose', throw=True, pending=pending, |
|
|||
999 | txnname=desc, **tr.hookargs) |
|
998 | txnname=desc, **tr.hookargs) | |
1000 | def releasefn(tr, success): |
|
999 | def releasefn(tr, success): | |
1001 | repo = reporef() |
|
1000 | repo = reporef() | |
@@ -1682,10 +1681,9 class localrepository(object): | |||||
1682 | n = self.changelog.add(mn, files, ctx.description(), |
|
1681 | n = self.changelog.add(mn, files, ctx.description(), | |
1683 | trp, p1.node(), p2.node(), |
|
1682 | trp, p1.node(), p2.node(), | |
1684 | user, ctx.date(), ctx.extra().copy()) |
|
1683 | user, ctx.date(), ctx.extra().copy()) | |
1685 | p = lambda: tr.writepending() and self.root or "" |
|
|||
1686 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
1684 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
1687 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
1685 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, | |
1688 |
parent2=xp2 |
|
1686 | parent2=xp2) | |
1689 | # set the new commit is proper phase |
|
1687 | # set the new commit is proper phase | |
1690 | targetphase = subrepo.newcommitphase(self.ui, ctx) |
|
1688 | targetphase = subrepo.newcommitphase(self.ui, ctx) | |
1691 | if targetphase: |
|
1689 | if targetphase: | |
@@ -1865,8 +1863,6 class localrepository(object): | |||||
1865 | hookargs = {} |
|
1863 | hookargs = {} | |
1866 | if tr is not None: |
|
1864 | if tr is not None: | |
1867 | hookargs.update(tr.hookargs) |
|
1865 | hookargs.update(tr.hookargs) | |
1868 | pending = lambda: tr.writepending() and self.root or "" |
|
|||
1869 | hookargs['pending'] = pending |
|
|||
1870 | hookargs['namespace'] = namespace |
|
1866 | hookargs['namespace'] = namespace | |
1871 | hookargs['key'] = key |
|
1867 | hookargs['key'] = key | |
1872 | hookargs['old'] = old |
|
1868 | hookargs['old'] = old |
@@ -259,6 +259,60 check line 1 is back | |||||
259 | line 2 |
|
259 | line 2 | |
260 | line 3 |
|
260 | line 3 | |
261 |
|
261 | |||
|
262 | Test visibility of in-memory dirstate changes outside transaction to | |||
|
263 | external hook process | |||
|
264 | ||||
|
265 | $ cat > $TESTTMP/checkvisibility.sh <<EOF | |||
|
266 | > echo "==== \$1:" | |||
|
267 | > hg parents --template "{rev}:{node|short}\n" | |||
|
268 | > echo "====" | |||
|
269 | > EOF | |||
|
270 | ||||
|
271 | "hg backout --merge REV1" at REV2 below implies steps below: | |||
|
272 | ||||
|
273 | (1) update to REV1 (REV2 => REV1) | |||
|
274 | (2) revert by REV1^1 | |||
|
275 | (3) commit backnig out revision (REV3) | |||
|
276 | (4) update to REV2 (REV3 => REV2) | |||
|
277 | (5) merge with REV3 (REV2 => REV2, REV3) | |||
|
278 | ||||
|
279 | == test visibility to external preupdate hook | |||
|
280 | ||||
|
281 | $ hg update -q -C 2 | |||
|
282 | $ hg --config extensions.strip= strip 3 | |||
|
283 | saved backup bundle to * (glob) | |||
|
284 | ||||
|
285 | $ cat >> .hg/hgrc <<EOF | |||
|
286 | > [hooks] | |||
|
287 | > preupdate.visibility = sh $TESTTMP/checkvisibility.sh preupdate | |||
|
288 | > EOF | |||
|
289 | ||||
|
290 | ("-m" is needed to avoid writing dirstte changes out at other than | |||
|
291 | invocation of the hook to be examined) | |||
|
292 | ||||
|
293 | $ hg backout --merge -d '3 0' 1 --tool=true -m 'fixed comment' | |||
|
294 | ==== preupdate: | |||
|
295 | 2:6ea3f2a197a2 | |||
|
296 | ==== | |||
|
297 | reverting a | |||
|
298 | created new head | |||
|
299 | changeset 3:d92a3f57f067 backs out changeset 1:5a50a024c182 | |||
|
300 | ==== preupdate: | |||
|
301 | 3:d92a3f57f067 | |||
|
302 | ==== | |||
|
303 | merging with changeset 3:d92a3f57f067 | |||
|
304 | ==== preupdate: | |||
|
305 | 2:6ea3f2a197a2 | |||
|
306 | ==== | |||
|
307 | merging a | |||
|
308 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | |||
|
309 | (branch merge, don't forget to commit) | |||
|
310 | ||||
|
311 | $ cat >> .hg/hgrc <<EOF | |||
|
312 | > [hooks] | |||
|
313 | > preupdate.visibility = | |||
|
314 | > EOF | |||
|
315 | ||||
262 | $ cd .. |
|
316 | $ cd .. | |
263 |
|
317 | |||
264 | backout should not back out subsequent changesets |
|
318 | backout should not back out subsequent changesets |
@@ -533,6 +533,110 external process | |||||
533 | $ hg --cwd b revert --no-backup a |
|
533 | $ hg --cwd b revert --no-backup a | |
534 | $ rm -f b/foo |
|
534 | $ rm -f b/foo | |
535 |
|
535 | |||
|
536 | == test visibility to precommit external hook | |||
|
537 | ||||
|
538 | $ cat >> b/.hg/hgrc <<EOF | |||
|
539 | > [hooks] | |||
|
540 | > precommit.visibility = sh $TESTTMP/checkvisibility.sh | |||
|
541 | > EOF | |||
|
542 | ||||
|
543 | $ (cd b && sh "$TESTTMP/checkvisibility.sh") | |||
|
544 | ==== | |||
|
545 | VISIBLE 0:80971e65b431 | |||
|
546 | ACTUAL 0:80971e65b431 | |||
|
547 | ==== | |||
|
548 | ||||
|
549 | $ hg --cwd b import ../patch1 ../patch2 ../patch3 | |||
|
550 | applying ../patch1 | |||
|
551 | ==== | |||
|
552 | VISIBLE 0:80971e65b431 | |||
|
553 | M a | |||
|
554 | ACTUAL 0:80971e65b431 | |||
|
555 | M a | |||
|
556 | ==== | |||
|
557 | applying ../patch2 | |||
|
558 | ==== | |||
|
559 | VISIBLE 1:1d4bd90af0e4 | |||
|
560 | M a | |||
|
561 | ACTUAL 0:80971e65b431 | |||
|
562 | M a | |||
|
563 | ==== | |||
|
564 | applying ../patch3 | |||
|
565 | ==== | |||
|
566 | VISIBLE 2:6d019af21222 | |||
|
567 | A foo | |||
|
568 | ACTUAL 0:80971e65b431 | |||
|
569 | M a | |||
|
570 | ==== | |||
|
571 | ||||
|
572 | $ hg --cwd b rollback -q | |||
|
573 | $ (cd b && sh "$TESTTMP/checkvisibility.sh") | |||
|
574 | ==== | |||
|
575 | VISIBLE 0:80971e65b431 | |||
|
576 | M a | |||
|
577 | ACTUAL 0:80971e65b431 | |||
|
578 | M a | |||
|
579 | ==== | |||
|
580 | $ hg --cwd b revert --no-backup a | |||
|
581 | $ rm -f b/foo | |||
|
582 | ||||
|
583 | $ cat >> b/.hg/hgrc <<EOF | |||
|
584 | > [hooks] | |||
|
585 | > precommit.visibility = | |||
|
586 | > EOF | |||
|
587 | ||||
|
588 | == test visibility to pretxncommit external hook | |||
|
589 | ||||
|
590 | $ cat >> b/.hg/hgrc <<EOF | |||
|
591 | > [hooks] | |||
|
592 | > pretxncommit.visibility = sh $TESTTMP/checkvisibility.sh | |||
|
593 | > EOF | |||
|
594 | ||||
|
595 | $ (cd b && sh "$TESTTMP/checkvisibility.sh") | |||
|
596 | ==== | |||
|
597 | VISIBLE 0:80971e65b431 | |||
|
598 | ACTUAL 0:80971e65b431 | |||
|
599 | ==== | |||
|
600 | ||||
|
601 | $ hg --cwd b import ../patch1 ../patch2 ../patch3 | |||
|
602 | applying ../patch1 | |||
|
603 | ==== | |||
|
604 | VISIBLE 0:80971e65b431 | |||
|
605 | M a | |||
|
606 | ACTUAL 0:80971e65b431 | |||
|
607 | M a | |||
|
608 | ==== | |||
|
609 | applying ../patch2 | |||
|
610 | ==== | |||
|
611 | VISIBLE 1:1d4bd90af0e4 | |||
|
612 | M a | |||
|
613 | ACTUAL 0:80971e65b431 | |||
|
614 | M a | |||
|
615 | ==== | |||
|
616 | applying ../patch3 | |||
|
617 | ==== | |||
|
618 | VISIBLE 2:6d019af21222 | |||
|
619 | A foo | |||
|
620 | ACTUAL 0:80971e65b431 | |||
|
621 | M a | |||
|
622 | ==== | |||
|
623 | ||||
|
624 | $ hg --cwd b rollback -q | |||
|
625 | $ (cd b && sh "$TESTTMP/checkvisibility.sh") | |||
|
626 | ==== | |||
|
627 | VISIBLE 0:80971e65b431 | |||
|
628 | M a | |||
|
629 | ACTUAL 0:80971e65b431 | |||
|
630 | M a | |||
|
631 | ==== | |||
|
632 | $ hg --cwd b revert --no-backup a | |||
|
633 | $ rm -f b/foo | |||
|
634 | ||||
|
635 | $ cat >> b/.hg/hgrc <<EOF | |||
|
636 | > [hooks] | |||
|
637 | > pretxncommit.visibility = | |||
|
638 | > EOF | |||
|
639 | ||||
536 | $ rm -r b |
|
640 | $ rm -r b | |
537 |
|
641 | |||
538 |
|
642 |
@@ -242,3 +242,85 dropping status of "file2") | |||||
242 | ==== |
|
242 | ==== | |
243 | 0:25e397dabed2 |
|
243 | 0:25e397dabed2 | |
244 | ==== |
|
244 | ==== | |
|
245 | ||||
|
246 | == test visibility to precommit external hook | |||
|
247 | ||||
|
248 | $ hg update -C -q | |||
|
249 | $ rm -f file2 | |||
|
250 | $ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= | |||
|
251 | now at: second-patch | |||
|
252 | $ echo bbbb >> file2 | |||
|
253 | ||||
|
254 | $ cat >> .hg/hgrc <<EOF | |||
|
255 | > [hooks] | |||
|
256 | > precommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh" | |||
|
257 | > EOF | |||
|
258 | ||||
|
259 | $ sh "$TESTTMP/checkvisibility.sh" | |||
|
260 | ==== | |||
|
261 | 1:e30108269082 | |||
|
262 | M file2 | |||
|
263 | ==== | |||
|
264 | ||||
|
265 | $ hg qrefresh | |||
|
266 | ==== | |||
|
267 | 0:25e397dabed2 | |||
|
268 | A file2 | |||
|
269 | ==== | |||
|
270 | transaction abort! | |||
|
271 | rollback completed | |||
|
272 | refresh interrupted while patch was popped! (revert --all, qpush to recover) | |||
|
273 | abort: pretxncommit.unexpectedabort hook exited with status 1 | |||
|
274 | [255] | |||
|
275 | ||||
|
276 | $ sh "$TESTTMP/checkvisibility.sh" | |||
|
277 | ==== | |||
|
278 | 0:25e397dabed2 | |||
|
279 | ==== | |||
|
280 | ||||
|
281 | $ cat >> .hg/hgrc <<EOF | |||
|
282 | > [hooks] | |||
|
283 | > precommit.checkvisibility = | |||
|
284 | > EOF | |||
|
285 | ||||
|
286 | == test visibility to pretxncommit external hook | |||
|
287 | ||||
|
288 | $ hg update -C -q | |||
|
289 | $ rm -f file2 | |||
|
290 | $ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= | |||
|
291 | now at: second-patch | |||
|
292 | $ echo bbbb >> file2 | |||
|
293 | ||||
|
294 | $ cat >> .hg/hgrc <<EOF | |||
|
295 | > [hooks] | |||
|
296 | > pretxncommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh" | |||
|
297 | > # make checkvisibility run before unexpectedabort | |||
|
298 | > priority.pretxncommit.checkvisibility = 10 | |||
|
299 | > EOF | |||
|
300 | ||||
|
301 | $ sh "$TESTTMP/checkvisibility.sh" | |||
|
302 | ==== | |||
|
303 | 1:e30108269082 | |||
|
304 | M file2 | |||
|
305 | ==== | |||
|
306 | ||||
|
307 | $ hg qrefresh | |||
|
308 | ==== | |||
|
309 | 0:25e397dabed2 | |||
|
310 | A file2 | |||
|
311 | ==== | |||
|
312 | transaction abort! | |||
|
313 | rollback completed | |||
|
314 | refresh interrupted while patch was popped! (revert --all, qpush to recover) | |||
|
315 | abort: pretxncommit.unexpectedabort hook exited with status 1 | |||
|
316 | [255] | |||
|
317 | ||||
|
318 | $ sh "$TESTTMP/checkvisibility.sh" | |||
|
319 | ==== | |||
|
320 | 0:25e397dabed2 | |||
|
321 | ==== | |||
|
322 | ||||
|
323 | $ cat >> .hg/hgrc <<EOF | |||
|
324 | > [hooks] | |||
|
325 | > pretxncommit.checkvisibility = | |||
|
326 | > EOF |
@@ -1011,6 +1011,84 with general delta | |||||
1011 | 7e30d8ac6f23cfc84330fd7e698730374615d21a |
|
1011 | 7e30d8ac6f23cfc84330fd7e698730374615d21a | |
1012 | $ cd .. |
|
1012 | $ cd .. | |
1013 |
|
1013 | |||
|
1014 | Test visibility of in-memory changes inside transaction to external hook | |||
|
1015 | ------------------------------------------------------------------------ | |||
|
1016 | ||||
|
1017 | $ cd repo | |||
|
1018 | ||||
|
1019 | $ echo xxxx >> x | |||
|
1020 | $ hg commit -m "#5: changes to invoke rebase" | |||
|
1021 | ||||
|
1022 | $ cat > $TESTTMP/checkvisibility.sh <<EOF | |||
|
1023 | > echo "==== \$1:" | |||
|
1024 | > hg parents --template "VISIBLE {rev}:{node|short}\n" | |||
|
1025 | > # test that pending changes are hidden | |||
|
1026 | > unset HG_PENDING | |||
|
1027 | > hg parents --template "ACTUAL {rev}:{node|short}\n" | |||
|
1028 | > echo "====" | |||
|
1029 | > EOF | |||
|
1030 | ||||
|
1031 | $ cat >> .hg/hgrc <<EOF | |||
|
1032 | > [defaults] | |||
|
1033 | > # to fix hash id of temporary revisions | |||
|
1034 | > unshelve = --date '0 0' | |||
|
1035 | > EOF | |||
|
1036 | ||||
|
1037 | "hg unshelve" at REV5 implies steps below: | |||
|
1038 | ||||
|
1039 | (1) commit changes in the working directory (REV6) | |||
|
1040 | (2) unbundle shelved revision (REV7) | |||
|
1041 | (3) rebase: merge REV7 into REV6 (REV6 => REV6, REV7) | |||
|
1042 | (4) rebase: commit merged revision (REV8) | |||
|
1043 | (5) rebase: update to REV6 (REV8 => REV6) | |||
|
1044 | (6) update to REV5 (REV6 => REV5) | |||
|
1045 | (7) abort transaction | |||
|
1046 | ||||
|
1047 | == test visibility to external preupdate hook | |||
|
1048 | ||||
|
1049 | $ cat >> .hg/hgrc <<EOF | |||
|
1050 | > [hooks] | |||
|
1051 | > preupdate.visibility = sh $TESTTMP/checkvisibility.sh preupdate | |||
|
1052 | > EOF | |||
|
1053 | ||||
|
1054 | $ echo nnnn >> n | |||
|
1055 | ||||
|
1056 | $ sh $TESTTMP/checkvisibility.sh before-unshelving | |||
|
1057 | ==== before-unshelving: | |||
|
1058 | VISIBLE 5:703117a2acfb | |||
|
1059 | ACTUAL 5:703117a2acfb | |||
|
1060 | ==== | |||
|
1061 | ||||
|
1062 | $ hg unshelve --keep default | |||
|
1063 | temporarily committing pending changes (restore with 'hg unshelve --abort') | |||
|
1064 | rebasing shelved changes | |||
|
1065 | rebasing 7:fcbb97608399 "changes to 'create conflict'" (tip) | |||
|
1066 | ==== preupdate: | |||
|
1067 | VISIBLE 6:66b86db80ee4 | |||
|
1068 | ACTUAL 5:703117a2acfb | |||
|
1069 | ==== | |||
|
1070 | ==== preupdate: | |||
|
1071 | VISIBLE 8:cb2a4e59c2d5 | |||
|
1072 | ACTUAL 5:703117a2acfb | |||
|
1073 | ==== | |||
|
1074 | ==== preupdate: | |||
|
1075 | VISIBLE 6:66b86db80ee4 | |||
|
1076 | ACTUAL 5:703117a2acfb | |||
|
1077 | ==== | |||
|
1078 | ||||
|
1079 | $ cat >> .hg/hgrc <<EOF | |||
|
1080 | > [hooks] | |||
|
1081 | > preupdate.visibility = | |||
|
1082 | > EOF | |||
|
1083 | ||||
|
1084 | $ sh $TESTTMP/checkvisibility.sh after-unshelving | |||
|
1085 | ==== after-unshelving: | |||
|
1086 | VISIBLE 5:703117a2acfb | |||
|
1087 | ACTUAL 5:703117a2acfb | |||
|
1088 | ==== | |||
|
1089 | ||||
|
1090 | $ cd .. | |||
|
1091 | ||||
1014 | test Abort unshelve always gets user out of the unshelved state |
|
1092 | test Abort unshelve always gets user out of the unshelved state | |
1015 | --------------------------------------------------------------- |
|
1093 | --------------------------------------------------------------- | |
1016 | $ hg init salvage |
|
1094 | $ hg init salvage |
General Comments 0
You need to be logged in to leave comments.
Login now