comparison tests/test-hook.t @ 31054:59e69ed81776

localrepo: check HG_PENDING strictly Before this patch, checking HG_PENDING for changelog in localrepo.py might cause unintentional reading unrelated '00changelog.i.a' in, because HG_PENDING is checked by str.startswith(). An external hook spawned by inner repository in nested ones satisfies this condition. This patch uses txnutil.mayhavepending() to check HG_PENDING strictly. BTW, this patch may cause failure of bisect in the repository of Mercurial itself, if examination at bisecting assumes that an external hook can see all pending changes while nested transactions across repositories. This invisibility issue will be fixed by subsequent patch, which allows HG_PENDING to refer multiple repositories.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 21 Feb 2017 01:21:00 +0900
parents 34a5f6c66bc5
children 728d37353e1e
comparison
equal deleted inserted replaced
31053:6afd8a87a657 31054:59e69ed81776
830 $ hg recover 830 $ hg recover
831 no interrupted transaction available 831 no interrupted transaction available
832 [1] 832 [1]
833 $ cd .. 833 $ cd ..
834 834
835 check whether HG_PENDING makes pending changes only in related
836 repositories visible to an external hook.
837
838 (emulate a transaction running concurrently by copied
839 .hg/store/00changelog.i.a in subsequent test)
840
841 $ cat > $TESTTMP/savepending.sh <<EOF
842 > cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
843 > exit 1 # to avoid adding new revision for subsequent tests
844 > EOF
845 $ cd a
846 $ hg tip -q
847 4:539e4b31b6dc
848 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
849 transaction abort!
850 rollback completed
851 abort: pretxnclose hook exited with status 1
852 [255]
853 $ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
854
855 (check (in)visibility of new changeset while transaction running in
856 repo)
857
858 $ cat > $TESTTMP/checkpending.sh <<EOF
859 > echo '@a'
860 > hg -R $TESTTMP/a tip -q
861 > echo '@a/nested'
862 > hg -R $TESTTMP/a/nested tip -q
863 > exit 1 # to avoid adding new revision for subsequent tests
864 > EOF
865 $ hg init nested
866 $ cd nested
867 $ echo a > a
868 $ hg add a
869 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
870 @a
871 4:539e4b31b6dc
872 @a/nested
873 0:bf5e395ced2c
874 transaction abort!
875 rollback completed
876 abort: pretxnclose hook exited with status 1
877 [255]
878
835 Hook from untrusted hgrc are reported as failure 879 Hook from untrusted hgrc are reported as failure
836 ================================================ 880 ================================================
837 881
838 $ cat << EOF > $TESTTMP/untrusted.py 882 $ cat << EOF > $TESTTMP/untrusted.py
839 > from mercurial import scmutil, util 883 > from mercurial import scmutil, util