Show More
@@ -315,7 +315,10 b' class repoview(object):' | |||
|
315 | 315 | revs = filterrevs(unfi, self.filtername) |
|
316 | 316 | cl = self._clcache |
|
317 | 317 | newkey = (unfilen, unfinode, hash(revs), unfichangelog._delayed) |
|
318 | if cl is not None and newkey != self._clcachekey: | |
|
318 | # if cl.index is not unfiindex, unfi.changelog would be | |
|
319 | # recreated, and our clcache refers to garbage object | |
|
320 | if (cl is not None and | |
|
321 | (cl.index is not unfiindex or newkey != self._clcachekey)): | |
|
319 | 322 | cl = None |
|
320 | 323 | # could have been made None by the previous if |
|
321 | 324 | if cl is None: |
@@ -725,3 +725,133 b' unix domain socket:' | |||
|
725 | 725 | [255] |
|
726 | 726 | |
|
727 | 727 | #endif |
|
728 | ||
|
729 | $ cd .. | |
|
730 | ||
|
731 | Test that accessing to invalid changelog cache is avoided at | |
|
732 | subsequent operations even if repo object is reused even after failure | |
|
733 | of transaction (see 0a7610758c42 also) | |
|
734 | ||
|
735 | "hg log" after failure of transaction is needed to detect invalid | |
|
736 | cache in repoview: this can't detect by "hg verify" only. | |
|
737 | ||
|
738 | Combination of "finalization" and "empty-ness of changelog" (2 x 2 = | |
|
739 | 4) are tested, because '00changelog.i' are differently changed in each | |
|
740 | cases. | |
|
741 | ||
|
742 | $ cat > $TESTTMP/failafterfinalize.py <<EOF | |
|
743 | > # extension to abort transaction after finalization forcibly | |
|
744 | > from mercurial import commands, error, extensions, lock as lockmod | |
|
745 | > def fail(tr): | |
|
746 | > raise error.Abort('fail after finalization') | |
|
747 | > def reposetup(ui, repo): | |
|
748 | > class failrepo(repo.__class__): | |
|
749 | > def commitctx(self, ctx, error=False): | |
|
750 | > if self.ui.configbool('failafterfinalize', 'fail'): | |
|
751 | > # 'sorted()' by ASCII code on category names causes | |
|
752 | > # invoking 'fail' after finalization of changelog | |
|
753 | > # using "'cl-%i' % id(self)" as category name | |
|
754 | > self.currenttransaction().addfinalize('zzzzzzzz', fail) | |
|
755 | > return super(failrepo, self).commitctx(ctx, error) | |
|
756 | > repo.__class__ = failrepo | |
|
757 | > EOF | |
|
758 | ||
|
759 | $ hg init repo3 | |
|
760 | $ cd repo3 | |
|
761 | ||
|
762 | $ cat <<EOF >> $HGRCPATH | |
|
763 | > [ui] | |
|
764 | > logtemplate = {rev} {desc|firstline} ({files})\n | |
|
765 | > | |
|
766 | > [extensions] | |
|
767 | > failafterfinalize = $TESTTMP/failafterfinalize.py | |
|
768 | > EOF | |
|
769 | ||
|
770 | - test failure with "empty changelog" | |
|
771 | ||
|
772 | $ echo foo > foo | |
|
773 | $ hg add foo | |
|
774 | ||
|
775 | (failuer before finalization) | |
|
776 | ||
|
777 | >>> from hgclient import readchannel, runcommand, check | |
|
778 | >>> @check | |
|
779 | ... def abort(server): | |
|
780 | ... readchannel(server) | |
|
781 | ... runcommand(server, ['commit', | |
|
782 | ... '--config', 'hooks.pretxncommit=false', | |
|
783 | ... '-mfoo']) | |
|
784 | ... runcommand(server, ['log']) | |
|
785 | ... runcommand(server, ['verify', '-q']) | |
|
786 | *** runcommand commit --config hooks.pretxncommit=false -mfoo | |
|
787 | transaction abort! | |
|
788 | rollback completed | |
|
789 | abort: pretxncommit hook exited with status 1 | |
|
790 | [255] | |
|
791 | *** runcommand log | |
|
792 | *** runcommand verify -q | |
|
793 | ||
|
794 | (failuer after finalization) | |
|
795 | ||
|
796 | >>> from hgclient import readchannel, runcommand, check | |
|
797 | >>> @check | |
|
798 | ... def abort(server): | |
|
799 | ... readchannel(server) | |
|
800 | ... runcommand(server, ['commit', | |
|
801 | ... '--config', 'failafterfinalize.fail=true', | |
|
802 | ... '-mfoo']) | |
|
803 | ... runcommand(server, ['log']) | |
|
804 | ... runcommand(server, ['verify', '-q']) | |
|
805 | *** runcommand commit --config failafterfinalize.fail=true -mfoo | |
|
806 | transaction abort! | |
|
807 | rollback completed | |
|
808 | abort: fail after finalization | |
|
809 | [255] | |
|
810 | *** runcommand log | |
|
811 | *** runcommand verify -q | |
|
812 | ||
|
813 | - test failure with "not-empty changelog" | |
|
814 | ||
|
815 | $ echo bar > bar | |
|
816 | $ hg add bar | |
|
817 | $ hg commit -mbar bar | |
|
818 | ||
|
819 | (failure before finalization) | |
|
820 | ||
|
821 | >>> from hgclient import readchannel, runcommand, check | |
|
822 | >>> @check | |
|
823 | ... def abort(server): | |
|
824 | ... readchannel(server) | |
|
825 | ... runcommand(server, ['commit', | |
|
826 | ... '--config', 'hooks.pretxncommit=false', | |
|
827 | ... '-mfoo', 'foo']) | |
|
828 | ... runcommand(server, ['log']) | |
|
829 | ... runcommand(server, ['verify', '-q']) | |
|
830 | *** runcommand commit --config hooks.pretxncommit=false -mfoo foo | |
|
831 | transaction abort! | |
|
832 | rollback completed | |
|
833 | abort: pretxncommit hook exited with status 1 | |
|
834 | [255] | |
|
835 | *** runcommand log | |
|
836 | 0 bar (bar) | |
|
837 | *** runcommand verify -q | |
|
838 | ||
|
839 | (failure after finalization) | |
|
840 | ||
|
841 | >>> from hgclient import readchannel, runcommand, check | |
|
842 | >>> @check | |
|
843 | ... def abort(server): | |
|
844 | ... readchannel(server) | |
|
845 | ... runcommand(server, ['commit', | |
|
846 | ... '--config', 'failafterfinalize.fail=true', | |
|
847 | ... '-mfoo', 'foo']) | |
|
848 | ... runcommand(server, ['log']) | |
|
849 | ... runcommand(server, ['verify', '-q']) | |
|
850 | *** runcommand commit --config failafterfinalize.fail=true -mfoo foo | |
|
851 | transaction abort! | |
|
852 | rollback completed | |
|
853 | abort: fail after finalization | |
|
854 | [255] | |
|
855 | *** runcommand log | |
|
856 | 0 bar (bar) | |
|
857 | *** runcommand verify -q |
General Comments 0
You need to be logged in to leave comments.
Login now