Mercurial > hg
comparison tests/test-share.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 | 8c14f87bd0ae |
children | 23080c03a604 |
comparison
equal
deleted
inserted
replaced
31051:96eaefd350ae | 31052:0332b8fafd05 |
---|---|
151 * bm3 2:c2e0ac586386 | 151 * bm3 2:c2e0ac586386 |
152 $ cd ../repo1 | 152 $ cd ../repo1 |
153 $ hg bookmarks | 153 $ hg bookmarks |
154 * bm1 2:c2e0ac586386 | 154 * bm1 2:c2e0ac586386 |
155 bm3 2:c2e0ac586386 | 155 bm3 2:c2e0ac586386 |
156 | |
157 check whether HG_PENDING makes pending changes only in relatd | |
158 repositories visible to an external hook. | |
159 | |
160 In "hg share" case, another transaction can't run in other | |
161 repositories sharing same source repository, because starting | |
162 transaction requires locking store of source repository. | |
163 | |
164 Therefore, this test scenario ignores checking visibility of | |
165 .hg/bookmakrs.pending in repo2, which shares repo1 without bookmarks. | |
166 | |
167 $ cat > $TESTTMP/checkbookmarks.sh <<EOF | |
168 > echo "@repo1" | |
169 > hg -R $TESTTMP/repo1 bookmarks | |
170 > echo "@repo2" | |
171 > hg -R $TESTTMP/repo2 bookmarks | |
172 > echo "@repo3" | |
173 > hg -R $TESTTMP/repo3 bookmarks | |
174 > exit 1 # to avoid adding new bookmark for subsequent tests | |
175 > EOF | |
176 | |
177 $ cd ../repo1 | |
178 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX | |
179 @repo1 | |
180 bm1 2:c2e0ac586386 | |
181 bm3 2:c2e0ac586386 | |
182 * bmX 2:c2e0ac586386 | |
183 @repo2 | |
184 * bm2 3:0e6e70d1d5f1 | |
185 @repo3 | |
186 bm1 2:c2e0ac586386 | |
187 * bm3 2:c2e0ac586386 | |
188 bmX 2:c2e0ac586386 | |
189 transaction abort! | |
190 rollback completed | |
191 abort: pretxnclose hook exited with status 1 | |
192 [255] | |
193 $ hg book bm1 | |
194 | |
195 FYI, in contrast to above test, bmX is invisible in repo1 (= shared | |
196 src), because (1) HG_PENDING refers only repo3 and (2) | |
197 "bookmarks.pending" is written only into repo3. | |
198 | |
199 $ cd ../repo3 | |
200 $ hg --config hooks.pretxnclose="sh $TESTTMP/checkbookmarks.sh" -q book bmX | |
201 @repo1 | |
202 * bm1 2:c2e0ac586386 | |
203 bm3 2:c2e0ac586386 | |
204 @repo2 | |
205 * bm2 3:0e6e70d1d5f1 | |
206 @repo3 | |
207 bm1 2:c2e0ac586386 | |
208 bm3 2:c2e0ac586386 | |
209 * bmX 2:c2e0ac586386 | |
210 transaction abort! | |
211 rollback completed | |
212 abort: pretxnclose hook exited with status 1 | |
213 [255] | |
214 $ hg book bm3 | |
215 | |
216 $ cd ../repo1 | |
156 | 217 |
157 test that commits work | 218 test that commits work |
158 | 219 |
159 $ echo 'shared bookmarks' > a | 220 $ echo 'shared bookmarks' > a |
160 $ hg commit -m 'testing shared bookmarks' | 221 $ hg commit -m 'testing shared bookmarks' |