comparison tests/test-bookmarks.t @ 31052:0332b8fafd05

bookmarks: check HG_PENDING strictly Before this patch, checking HG_PENDING in bookmarks.py might cause unintentional reading unrelated '.hg/bookmarks.pending' in, because it just examines existence of HG_PENDING environment variable. This patch uses txnutil.trypending() to check HG_PENDING strictly. This patch also changes share extension. Enabling share extension (+ bookmark sharing) makes bookmarks._getbkfile() receive repo to be shared (= "srcrepo"). On the other hand, HG_PENDING always refers current working repo (= "currepo"), and bookmarks.pending is written only into currepo. Therefore, we should try to read .hg/bookmarks.pending of currepo in at first. If it doesn't exist, we try to read .hg/bookmarks of srcrepo in. Even after this patch, an external hook spawned in currepo can't see pending changes in currepo via srcrepo, even though such changes become visible after closing transaction, because there is no easy and cheap way to know existence of pending changes in currepo via srcrepo. Please see https://www.mercurial-scm.org/wiki/SharedRepository, too. 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 96eaefd350ae
children 6c800688afe1
comparison
equal deleted inserted replaced
31051:96eaefd350ae 31052:0332b8fafd05
894 $ hg bookmarks 894 $ hg bookmarks
895 * mybook 0:867bc5792c8c 895 * mybook 0:867bc5792c8c
896 $ touch $TESTTMP/unpause 896 $ touch $TESTTMP/unpause
897 897
898 $ cd .. 898 $ cd ..
899
900 check whether HG_PENDING makes pending changes only in related
901 repositories visible to an external hook.
902
903 (emulate a transaction running concurrently by copied
904 .hg/bookmarks.pending in subsequent test)
905
906 $ cat > $TESTTMP/savepending.sh <<EOF
907 > cp .hg/bookmarks.pending .hg/bookmarks.pending.saved
908 > exit 1 # to avoid adding new bookmark for subsequent tests
909 > EOF
910
911 $ hg init unrelated
912 $ cd unrelated
913 $ echo a > a
914 $ hg add a
915 $ hg commit -m '#0'
916 $ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" bookmarks INVISIBLE
917 transaction abort!
918 rollback completed
919 abort: pretxnclose hook exited with status 1
920 [255]
921 $ cp .hg/bookmarks.pending.saved .hg/bookmarks.pending
922
923 (check visible bookmarks while transaction running in repo)
924
925 $ cat > $TESTTMP/checkpending.sh <<EOF
926 > echo "@repo"
927 > hg -R $TESTTMP/repo bookmarks
928 > echo "@unrelated"
929 > hg -R $TESTTMP/unrelated bookmarks
930 > exit 1 # to avoid adding new bookmark for subsequent tests
931 > EOF
932
933 $ cd ../repo
934 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" bookmarks NEW
935 @repo
936 * NEW 6:81dcce76aa0b
937 X2 1:925d80f479bb
938 Y 4:125c9a1d6df6
939 Z 5:5fb12f0f2d51
940 Z@1 1:925d80f479bb
941 Z@2 4:125c9a1d6df6
942 foo 3:9ba5f110a0b3
943 foo@1 0:f7b1eb17ad24
944 foo@2 2:db815d6d32e6
945 four 3:9ba5f110a0b3
946 should-end-on-two 2:db815d6d32e6
947 x y 2:db815d6d32e6
948 @unrelated
949 no bookmarks set
950 transaction abort!
951 rollback completed
952 abort: pretxnclose hook exited with status 1
953 [255]