comparison tests/test-shelve.t @ 26751:520defbc0335

hook: centralize passing HG_PENDING to external hook process This patch centralizes passing HG_PENDING to external hook process into '_exthook()'. To make in-memory changes visible to external hook process, this patch does: - write (or schedule to write) in-memory dirstate changes, and - set HG_PENDING environment variable, if: - a transaction is running, and - there are in-memory changes to be visible This patch tests some commands with some hooks, because transaction activity of a same hook differs from each other ("---": "not tested"). ======== ========= ========= ============ command preupdate precommit pretxncommit ======== ========= ========= ============ unshelve o --- --- backout x --- --- import --- o o qrefresh --- x o ======== ========= ========= ============ Each hooks are examined separately to prevent in-memory changes from being visible to external process accidentally by side effect of hooks previously invoked.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 17 Oct 2015 01:15:34 +0900
parents ca8170b5d370
children 949e8c626d19
comparison
equal deleted inserted replaced
26750:9f9ec4abe700 26751:520defbc0335
1009 Stream params: {'Compression': 'BZ'} 1009 Stream params: {'Compression': 'BZ'}
1010 changegroup -- "{'version': '02'}" 1010 changegroup -- "{'version': '02'}"
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
1017 $ cd salvage 1095 $ cd salvage
1018 $ echo 'content' > root 1096 $ echo 'content' > root