##// END OF EJS Templates
test: use a more direct form of interruption in fncache "recover" testing...
marmoute -
r50887:420fad6b default
parent child Browse files
Show More
@@ -1,537 +1,537 b''
1 #require repofncache
1 #require repofncache
2
2
3 An extension which will set fncache chunksize to 1 byte to make sure that logic
3 An extension which will set fncache chunksize to 1 byte to make sure that logic
4 does not break
4 does not break
5
5
6 $ cat > chunksize.py <<EOF
6 $ cat > chunksize.py <<EOF
7 > from mercurial import store
7 > from mercurial import store
8 > store.fncache_chunksize = 1
8 > store.fncache_chunksize = 1
9 > EOF
9 > EOF
10
10
11 $ cat >> $HGRCPATH <<EOF
11 $ cat >> $HGRCPATH <<EOF
12 > [extensions]
12 > [extensions]
13 > chunksize = $TESTTMP/chunksize.py
13 > chunksize = $TESTTMP/chunksize.py
14 > EOF
14 > EOF
15
15
16 Init repo1:
16 Init repo1:
17
17
18 $ hg init repo1
18 $ hg init repo1
19 $ cd repo1
19 $ cd repo1
20 $ echo "some text" > a
20 $ echo "some text" > a
21 $ hg add
21 $ hg add
22 adding a
22 adding a
23 $ hg ci -m first
23 $ hg ci -m first
24 $ cat .hg/store/fncache | sort
24 $ cat .hg/store/fncache | sort
25 data/a.i
25 data/a.i
26
26
27 Testing a.i/b:
27 Testing a.i/b:
28
28
29 $ mkdir a.i
29 $ mkdir a.i
30 $ echo "some other text" > a.i/b
30 $ echo "some other text" > a.i/b
31 $ hg add
31 $ hg add
32 adding a.i/b
32 adding a.i/b
33 $ hg ci -m second
33 $ hg ci -m second
34 $ cat .hg/store/fncache | sort
34 $ cat .hg/store/fncache | sort
35 data/a.i
35 data/a.i
36 data/a.i.hg/b.i
36 data/a.i.hg/b.i
37
37
38 Testing a.i.hg/c:
38 Testing a.i.hg/c:
39
39
40 $ mkdir a.i.hg
40 $ mkdir a.i.hg
41 $ echo "yet another text" > a.i.hg/c
41 $ echo "yet another text" > a.i.hg/c
42 $ hg add
42 $ hg add
43 adding a.i.hg/c
43 adding a.i.hg/c
44 $ hg ci -m third
44 $ hg ci -m third
45 $ cat .hg/store/fncache | sort
45 $ cat .hg/store/fncache | sort
46 data/a.i
46 data/a.i
47 data/a.i.hg.hg/c.i
47 data/a.i.hg.hg/c.i
48 data/a.i.hg/b.i
48 data/a.i.hg/b.i
49
49
50 Testing verify:
50 Testing verify:
51
51
52 $ hg verify -q
52 $ hg verify -q
53
53
54 $ rm .hg/store/fncache
54 $ rm .hg/store/fncache
55
55
56 $ hg verify
56 $ hg verify
57 checking changesets
57 checking changesets
58 checking manifests
58 checking manifests
59 crosschecking files in changesets and manifests
59 crosschecking files in changesets and manifests
60 checking files
60 checking files
61 warning: revlog 'data/a.i' not in fncache!
61 warning: revlog 'data/a.i' not in fncache!
62 warning: revlog 'data/a.i.hg/c.i' not in fncache!
62 warning: revlog 'data/a.i.hg/c.i' not in fncache!
63 warning: revlog 'data/a.i/b.i' not in fncache!
63 warning: revlog 'data/a.i/b.i' not in fncache!
64 checking dirstate
64 checking dirstate
65 checked 3 changesets with 3 changes to 3 files
65 checked 3 changesets with 3 changes to 3 files
66 3 warnings encountered!
66 3 warnings encountered!
67 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
67 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
68
68
69 Follow the hint to make sure it works
69 Follow the hint to make sure it works
70
70
71 $ hg debugrebuildfncache
71 $ hg debugrebuildfncache
72 adding data/a.i
72 adding data/a.i
73 adding data/a.i.hg/c.i
73 adding data/a.i.hg/c.i
74 adding data/a.i/b.i
74 adding data/a.i/b.i
75 3 items added, 0 removed from fncache
75 3 items added, 0 removed from fncache
76
76
77 $ hg verify -q
77 $ hg verify -q
78
78
79 $ cd ..
79 $ cd ..
80
80
81 Non store repo:
81 Non store repo:
82
82
83 $ hg --config format.usestore=False init foo
83 $ hg --config format.usestore=False init foo
84 $ cd foo
84 $ cd foo
85 $ mkdir tst.d
85 $ mkdir tst.d
86 $ echo foo > tst.d/foo
86 $ echo foo > tst.d/foo
87 $ hg ci -Amfoo
87 $ hg ci -Amfoo
88 adding tst.d/foo
88 adding tst.d/foo
89 $ find .hg | sort
89 $ find .hg | sort
90 .hg
90 .hg
91 .hg/00changelog.i
91 .hg/00changelog.i
92 .hg/00manifest.i
92 .hg/00manifest.i
93 .hg/cache
93 .hg/cache
94 .hg/cache/branch2-served
94 .hg/cache/branch2-served
95 .hg/cache/rbc-names-v1
95 .hg/cache/rbc-names-v1
96 .hg/cache/rbc-revs-v1
96 .hg/cache/rbc-revs-v1
97 .hg/data
97 .hg/data
98 .hg/data/tst.d.hg
98 .hg/data/tst.d.hg
99 .hg/data/tst.d.hg/foo.i
99 .hg/data/tst.d.hg/foo.i
100 .hg/dirstate
100 .hg/dirstate
101 .hg/fsmonitor.state (fsmonitor !)
101 .hg/fsmonitor.state (fsmonitor !)
102 .hg/last-message.txt
102 .hg/last-message.txt
103 .hg/phaseroots
103 .hg/phaseroots
104 .hg/requires
104 .hg/requires
105 .hg/undo
105 .hg/undo
106 .hg/undo.backup.dirstate
106 .hg/undo.backup.dirstate
107 .hg/undo.backupfiles
107 .hg/undo.backupfiles
108 .hg/undo.bookmarks
108 .hg/undo.bookmarks
109 .hg/undo.branch
109 .hg/undo.branch
110 .hg/undo.desc
110 .hg/undo.desc
111 .hg/undo.dirstate
111 .hg/undo.dirstate
112 .hg/undo.phaseroots
112 .hg/undo.phaseroots
113 .hg/wcache
113 .hg/wcache
114 .hg/wcache/checkisexec (execbit !)
114 .hg/wcache/checkisexec (execbit !)
115 .hg/wcache/checklink (symlink !)
115 .hg/wcache/checklink (symlink !)
116 .hg/wcache/checklink-target (symlink !)
116 .hg/wcache/checklink-target (symlink !)
117 .hg/wcache/manifestfulltextcache (reporevlogstore !)
117 .hg/wcache/manifestfulltextcache (reporevlogstore !)
118 $ cd ..
118 $ cd ..
119
119
120 Non fncache repo:
120 Non fncache repo:
121
121
122 $ hg --config format.usefncache=False init bar
122 $ hg --config format.usefncache=False init bar
123 $ cd bar
123 $ cd bar
124 $ mkdir tst.d
124 $ mkdir tst.d
125 $ echo foo > tst.d/Foo
125 $ echo foo > tst.d/Foo
126 $ hg ci -Amfoo
126 $ hg ci -Amfoo
127 adding tst.d/Foo
127 adding tst.d/Foo
128 $ find .hg | sort
128 $ find .hg | sort
129 .hg
129 .hg
130 .hg/00changelog.i
130 .hg/00changelog.i
131 .hg/cache
131 .hg/cache
132 .hg/cache/branch2-served
132 .hg/cache/branch2-served
133 .hg/cache/rbc-names-v1
133 .hg/cache/rbc-names-v1
134 .hg/cache/rbc-revs-v1
134 .hg/cache/rbc-revs-v1
135 .hg/dirstate
135 .hg/dirstate
136 .hg/fsmonitor.state (fsmonitor !)
136 .hg/fsmonitor.state (fsmonitor !)
137 .hg/last-message.txt
137 .hg/last-message.txt
138 .hg/requires
138 .hg/requires
139 .hg/store
139 .hg/store
140 .hg/store/00changelog.i
140 .hg/store/00changelog.i
141 .hg/store/00manifest.i
141 .hg/store/00manifest.i
142 .hg/store/data
142 .hg/store/data
143 .hg/store/data/tst.d.hg
143 .hg/store/data/tst.d.hg
144 .hg/store/data/tst.d.hg/_foo.i
144 .hg/store/data/tst.d.hg/_foo.i
145 .hg/store/phaseroots
145 .hg/store/phaseroots
146 .hg/store/requires
146 .hg/store/requires
147 .hg/store/undo
147 .hg/store/undo
148 .hg/store/undo.backupfiles
148 .hg/store/undo.backupfiles
149 .hg/store/undo.phaseroots
149 .hg/store/undo.phaseroots
150 .hg/undo.backup.dirstate
150 .hg/undo.backup.dirstate
151 .hg/undo.bookmarks
151 .hg/undo.bookmarks
152 .hg/undo.branch
152 .hg/undo.branch
153 .hg/undo.desc
153 .hg/undo.desc
154 .hg/undo.dirstate
154 .hg/undo.dirstate
155 .hg/wcache
155 .hg/wcache
156 .hg/wcache/checkisexec (execbit !)
156 .hg/wcache/checkisexec (execbit !)
157 .hg/wcache/checklink (symlink !)
157 .hg/wcache/checklink (symlink !)
158 .hg/wcache/checklink-target (symlink !)
158 .hg/wcache/checklink-target (symlink !)
159 .hg/wcache/manifestfulltextcache (reporevlogstore !)
159 .hg/wcache/manifestfulltextcache (reporevlogstore !)
160 $ cd ..
160 $ cd ..
161
161
162 Encoding of reserved / long paths in the store
162 Encoding of reserved / long paths in the store
163
163
164 $ hg init r2
164 $ hg init r2
165 $ cd r2
165 $ cd r2
166 $ cat <<EOF > .hg/hgrc
166 $ cat <<EOF > .hg/hgrc
167 > [ui]
167 > [ui]
168 > portablefilenames = ignore
168 > portablefilenames = ignore
169 > EOF
169 > EOF
170
170
171 $ hg import -q --bypass - <<EOF
171 $ hg import -q --bypass - <<EOF
172 > # HG changeset patch
172 > # HG changeset patch
173 > # User test
173 > # User test
174 > # Date 0 0
174 > # Date 0 0
175 > # Node ID 1c7a2f7cb77be1a0def34e4c7cabc562ad98fbd7
175 > # Node ID 1c7a2f7cb77be1a0def34e4c7cabc562ad98fbd7
176 > # Parent 0000000000000000000000000000000000000000
176 > # Parent 0000000000000000000000000000000000000000
177 > 1
177 > 1
178 >
178 >
179 > diff --git a/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
179 > diff --git a/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
180 > new file mode 100644
180 > new file mode 100644
181 > --- /dev/null
181 > --- /dev/null
182 > +++ b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
182 > +++ b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
183 > @@ -0,0 +1,1 @@
183 > @@ -0,0 +1,1 @@
184 > +foo
184 > +foo
185 > diff --git a/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
185 > diff --git a/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
186 > new file mode 100644
186 > new file mode 100644
187 > --- /dev/null
187 > --- /dev/null
188 > +++ b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
188 > +++ b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
189 > @@ -0,0 +1,1 @@
189 > @@ -0,0 +1,1 @@
190 > +foo
190 > +foo
191 > diff --git a/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
191 > diff --git a/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
192 > new file mode 100644
192 > new file mode 100644
193 > --- /dev/null
193 > --- /dev/null
194 > +++ b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
194 > +++ b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
195 > @@ -0,0 +1,1 @@
195 > @@ -0,0 +1,1 @@
196 > +foo
196 > +foo
197 > diff --git a/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
197 > diff --git a/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
198 > new file mode 100644
198 > new file mode 100644
199 > --- /dev/null
199 > --- /dev/null
200 > +++ b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
200 > +++ b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
201 > @@ -0,0 +1,1 @@
201 > @@ -0,0 +1,1 @@
202 > +foo
202 > +foo
203 > diff --git a/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
203 > diff --git a/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
204 > new file mode 100644
204 > new file mode 100644
205 > --- /dev/null
205 > --- /dev/null
206 > +++ b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
206 > +++ b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
207 > @@ -0,0 +1,1 @@
207 > @@ -0,0 +1,1 @@
208 > +foo
208 > +foo
209 > EOF
209 > EOF
210
210
211 $ find .hg/store -name *.i | sort
211 $ find .hg/store -name *.i | sort
212 .hg/store/00changelog.i
212 .hg/store/00changelog.i
213 .hg/store/00manifest.i
213 .hg/store/00manifest.i
214 .hg/store/data/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i
214 .hg/store/data/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i
215 .hg/store/dh/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxx168e07b38e65eff86ab579afaaa8e30bfbe0f35f.i
215 .hg/store/dh/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxx168e07b38e65eff86ab579afaaa8e30bfbe0f35f.i
216 .hg/store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i
216 .hg/store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i
217 .hg/store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i
217 .hg/store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i
218 .hg/store/dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilename0d8e1f4187c650e2f1fdca9fd90f786bc0976b6b.i
218 .hg/store/dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilename0d8e1f4187c650e2f1fdca9fd90f786bc0976b6b.i
219
219
220 $ cd ..
220 $ cd ..
221
221
222 Aborting lock does not prevent fncache writes
222 Aborting lock does not prevent fncache writes
223
223
224 $ cat > exceptionext.py <<EOF
224 $ cat > exceptionext.py <<EOF
225 > import os
225 > import os
226 > from mercurial import commands, error, extensions
226 > from mercurial import commands, error, extensions
227 >
227 >
228 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
228 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
229 > def releasewrap():
229 > def releasewrap():
230 > l.held = False # ensure __del__ is a noop
230 > l.held = False # ensure __del__ is a noop
231 > raise error.Abort(b"forced lock failure")
231 > raise error.Abort(b"forced lock failure")
232 > l = orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
232 > l = orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
233 > return l
233 > return l
234 >
234 >
235 > def reposetup(ui, repo):
235 > def reposetup(ui, repo):
236 > extensions.wrapfunction(repo, '_lock', lockexception)
236 > extensions.wrapfunction(repo, '_lock', lockexception)
237 >
237 >
238 > cmdtable = {}
238 > cmdtable = {}
239 >
239 >
240 > # wrap "commit" command to prevent wlock from being '__del__()'-ed
240 > # wrap "commit" command to prevent wlock from being '__del__()'-ed
241 > # at the end of dispatching (for intentional "forced lcok failure")
241 > # at the end of dispatching (for intentional "forced lcok failure")
242 > def commitwrap(orig, ui, repo, *pats, **opts):
242 > def commitwrap(orig, ui, repo, *pats, **opts):
243 > repo = repo.unfiltered() # to use replaced repo._lock certainly
243 > repo = repo.unfiltered() # to use replaced repo._lock certainly
244 > wlock = repo.wlock()
244 > wlock = repo.wlock()
245 > try:
245 > try:
246 > return orig(ui, repo, *pats, **opts)
246 > return orig(ui, repo, *pats, **opts)
247 > finally:
247 > finally:
248 > # multiple 'relase()' is needed for complete releasing wlock,
248 > # multiple 'relase()' is needed for complete releasing wlock,
249 > # because "forced" abort at last releasing store lock
249 > # because "forced" abort at last releasing store lock
250 > # prevents wlock from being released at same 'lockmod.release()'
250 > # prevents wlock from being released at same 'lockmod.release()'
251 > for i in range(wlock.held):
251 > for i in range(wlock.held):
252 > wlock.release()
252 > wlock.release()
253 >
253 >
254 > def extsetup(ui):
254 > def extsetup(ui):
255 > extensions.wrapcommand(commands.table, b"commit", commitwrap)
255 > extensions.wrapcommand(commands.table, b"commit", commitwrap)
256 > EOF
256 > EOF
257 $ extpath=`pwd`/exceptionext.py
257 $ extpath=`pwd`/exceptionext.py
258 $ hg init fncachetxn
258 $ hg init fncachetxn
259 $ cd fncachetxn
259 $ cd fncachetxn
260 $ printf "[extensions]\nexceptionext=$extpath\n" >> .hg/hgrc
260 $ printf "[extensions]\nexceptionext=$extpath\n" >> .hg/hgrc
261 $ touch y
261 $ touch y
262 $ hg ci -qAm y
262 $ hg ci -qAm y
263 abort: forced lock failure
263 abort: forced lock failure
264 [255]
264 [255]
265 $ cat .hg/store/fncache
265 $ cat .hg/store/fncache
266 data/y.i
266 data/y.i
267
267
268 Aborting transaction prevents fncache change
268 Aborting transaction prevents fncache change
269
269
270 $ cat > ../exceptionext.py <<EOF
270 $ cat > ../exceptionext.py <<EOF
271 > import os
271 > import os
272 > from mercurial import commands, error, extensions, localrepo
272 > from mercurial import commands, error, extensions, localrepo
273 >
273 >
274 > def wrapper(orig, self, *args, **kwargs):
274 > def wrapper(orig, self, *args, **kwargs):
275 > tr = orig(self, *args, **kwargs)
275 > tr = orig(self, *args, **kwargs)
276 > def fail(tr):
276 > def fail(tr):
277 > raise error.Abort(b"forced transaction failure")
277 > raise error.Abort(b"forced transaction failure")
278 > # zzz prefix to ensure it sorted after store.write
278 > # zzz prefix to ensure it sorted after store.write
279 > tr.addfinalize(b'zzz-forcefails', fail)
279 > tr.addfinalize(b'zzz-forcefails', fail)
280 > return tr
280 > return tr
281 >
281 >
282 > def uisetup(ui):
282 > def uisetup(ui):
283 > extensions.wrapfunction(
283 > extensions.wrapfunction(
284 > localrepo.localrepository, b'transaction', wrapper)
284 > localrepo.localrepository, b'transaction', wrapper)
285 >
285 >
286 > cmdtable = {}
286 > cmdtable = {}
287 >
287 >
288 > EOF
288 > EOF
289
289
290 Clean cached version
290 Clean cached version
291 $ rm -f "${extpath}c"
291 $ rm -f "${extpath}c"
292 $ rm -Rf "`dirname $extpath`/__pycache__"
292 $ rm -Rf "`dirname $extpath`/__pycache__"
293
293
294 $ touch z
294 $ touch z
295 $ hg ci -qAm z
295 $ hg ci -qAm z
296 transaction abort!
296 transaction abort!
297 rollback completed
297 rollback completed
298 abort: forced transaction failure
298 abort: forced transaction failure
299 [255]
299 [255]
300 $ cat .hg/store/fncache
300 $ cat .hg/store/fncache
301 data/y.i
301 data/y.i
302
302
303 Aborted transactions can be recovered later
303 Aborted transactions can be recovered later
304
304
305 $ cat > ../exceptionext.py <<EOF
305 $ cat > ../exceptionext.py <<EOF
306 > import os
306 > import os
307 > import signal
307 > from mercurial import (
308 > from mercurial import (
308 > commands,
309 > commands,
309 > error,
310 > error,
310 > extensions,
311 > extensions,
311 > localrepo,
312 > localrepo,
312 > transaction,
313 > transaction,
313 > )
314 > )
314 >
315 >
315 > def trwrapper(orig, self, *args, **kwargs):
316 > def trwrapper(orig, self, *args, **kwargs):
316 > tr = orig(self, *args, **kwargs)
317 > tr = orig(self, *args, **kwargs)
317 > def fail(tr):
318 > def fail(tr):
318 > raise error.Abort(b"forced transaction failure")
319 > os.kill(os.getpid(), signal.SIGKILL)
319 > # zzz prefix to ensure it sorted after store.write
320 > # zzz prefix to ensure it sorted after store.write
320 > tr.addfinalize(b'zzz-forcefails', fail)
321 > tr.addfinalize(b'zzz-forcefails', fail)
321 > return tr
322 > return tr
322 >
323 >
323 > def abortwrapper(orig, self, *args, **kwargs):
324 > raise error.Abort(b"forced transaction failure")
325 >
326 > def uisetup(ui):
324 > def uisetup(ui):
327 > extensions.wrapfunction(localrepo.localrepository, 'transaction',
325 > extensions.wrapfunction(localrepo.localrepository, 'transaction',
328 > trwrapper)
326 > trwrapper)
329 > extensions.wrapfunction(transaction.transaction, '_abort',
330 > abortwrapper)
331 >
327 >
332 > cmdtable = {}
328 > cmdtable = {}
333 >
329 >
334 > EOF
330 > EOF
335
331
336 Clean cached versions
332 Clean cached versions
337 $ rm -f "${extpath}c"
333 $ rm -f "${extpath}c"
338 $ rm -Rf "`dirname $extpath`/__pycache__"
334 $ rm -Rf "`dirname $extpath`/__pycache__"
339
335
340 $ hg up -q 1
336 $ hg up -q 1
341 $ touch z
337 $ touch z
342 $ hg ci -qAm z 2>/dev/null
338 # Cannot rely on the return code value as chg use a different one.
343 [255]
339 # So we use a `|| echo` trick
340 # XXX-CHG fixing chg behavior would be nice here.
341 $ hg ci -qAm z || echo "He's Dead, Jim." 2>/dev/null
342 Killed (?)
343 He's Dead, Jim.
344 $ cat .hg/store/fncache | sort
344 $ cat .hg/store/fncache | sort
345 data/y.i
345 data/y.i
346 data/z.i
346 data/z.i
347 $ hg recover --verify
347 $ hg recover --verify
348 rolling back interrupted transaction
348 rolling back interrupted transaction
349 checking changesets
349 checking changesets
350 checking manifests
350 checking manifests
351 crosschecking files in changesets and manifests
351 crosschecking files in changesets and manifests
352 checking files
352 checking files
353 checking dirstate
353 checking dirstate
354 checked 1 changesets with 1 changes to 1 files
354 checked 1 changesets with 1 changes to 1 files
355 $ cat .hg/store/fncache
355 $ cat .hg/store/fncache
356 data/y.i
356 data/y.i
357
357
358 $ cd ..
358 $ cd ..
359
359
360 debugrebuildfncache does nothing unless repo has fncache requirement
360 debugrebuildfncache does nothing unless repo has fncache requirement
361
361
362 $ hg --config format.usefncache=false init nofncache
362 $ hg --config format.usefncache=false init nofncache
363 $ cd nofncache
363 $ cd nofncache
364 $ hg debugrebuildfncache
364 $ hg debugrebuildfncache
365 (not rebuilding fncache because repository does not support fncache)
365 (not rebuilding fncache because repository does not support fncache)
366
366
367 $ cd ..
367 $ cd ..
368
368
369 debugrebuildfncache works on empty repository
369 debugrebuildfncache works on empty repository
370
370
371 $ hg init empty
371 $ hg init empty
372 $ cd empty
372 $ cd empty
373 $ hg debugrebuildfncache
373 $ hg debugrebuildfncache
374 fncache already up to date
374 fncache already up to date
375 $ cd ..
375 $ cd ..
376
376
377 debugrebuildfncache on an up to date repository no-ops
377 debugrebuildfncache on an up to date repository no-ops
378
378
379 $ hg init repo
379 $ hg init repo
380 $ cd repo
380 $ cd repo
381 $ echo initial > foo
381 $ echo initial > foo
382 $ echo initial > .bar
382 $ echo initial > .bar
383 $ hg commit -A -m initial
383 $ hg commit -A -m initial
384 adding .bar
384 adding .bar
385 adding foo
385 adding foo
386
386
387 $ cat .hg/store/fncache | sort
387 $ cat .hg/store/fncache | sort
388 data/.bar.i
388 data/.bar.i
389 data/foo.i
389 data/foo.i
390
390
391 $ hg debugrebuildfncache
391 $ hg debugrebuildfncache
392 fncache already up to date
392 fncache already up to date
393
393
394 debugrebuildfncache restores deleted fncache file
394 debugrebuildfncache restores deleted fncache file
395
395
396 $ rm -f .hg/store/fncache
396 $ rm -f .hg/store/fncache
397 $ hg debugrebuildfncache
397 $ hg debugrebuildfncache
398 adding data/.bar.i
398 adding data/.bar.i
399 adding data/foo.i
399 adding data/foo.i
400 2 items added, 0 removed from fncache
400 2 items added, 0 removed from fncache
401
401
402 $ cat .hg/store/fncache | sort
402 $ cat .hg/store/fncache | sort
403 data/.bar.i
403 data/.bar.i
404 data/foo.i
404 data/foo.i
405
405
406 Rebuild after rebuild should no-op
406 Rebuild after rebuild should no-op
407
407
408 $ hg debugrebuildfncache
408 $ hg debugrebuildfncache
409 fncache already up to date
409 fncache already up to date
410
410
411 A single missing file should get restored, an extra file should be removed
411 A single missing file should get restored, an extra file should be removed
412
412
413 $ cat > .hg/store/fncache << EOF
413 $ cat > .hg/store/fncache << EOF
414 > data/foo.i
414 > data/foo.i
415 > data/bad-entry.i
415 > data/bad-entry.i
416 > EOF
416 > EOF
417
417
418 $ hg debugrebuildfncache
418 $ hg debugrebuildfncache
419 removing data/bad-entry.i
419 removing data/bad-entry.i
420 adding data/.bar.i
420 adding data/.bar.i
421 1 items added, 1 removed from fncache
421 1 items added, 1 removed from fncache
422
422
423 $ cat .hg/store/fncache | sort
423 $ cat .hg/store/fncache | sort
424 data/.bar.i
424 data/.bar.i
425 data/foo.i
425 data/foo.i
426
426
427 debugrebuildfncache recovers from truncated line in fncache
427 debugrebuildfncache recovers from truncated line in fncache
428
428
429 $ printf a > .hg/store/fncache
429 $ printf a > .hg/store/fncache
430 $ hg debugrebuildfncache
430 $ hg debugrebuildfncache
431 fncache does not ends with a newline
431 fncache does not ends with a newline
432 adding data/.bar.i
432 adding data/.bar.i
433 adding data/foo.i
433 adding data/foo.i
434 2 items added, 0 removed from fncache
434 2 items added, 0 removed from fncache
435
435
436 $ cat .hg/store/fncache | sort
436 $ cat .hg/store/fncache | sort
437 data/.bar.i
437 data/.bar.i
438 data/foo.i
438 data/foo.i
439
439
440 $ cd ..
440 $ cd ..
441
441
442 Try a simple variation without dotencode to ensure fncache is ignorant of encoding
442 Try a simple variation without dotencode to ensure fncache is ignorant of encoding
443
443
444 $ hg --config format.dotencode=false init nodotencode
444 $ hg --config format.dotencode=false init nodotencode
445 $ cd nodotencode
445 $ cd nodotencode
446 $ echo initial > foo
446 $ echo initial > foo
447 $ echo initial > .bar
447 $ echo initial > .bar
448 $ hg commit -A -m initial
448 $ hg commit -A -m initial
449 adding .bar
449 adding .bar
450 adding foo
450 adding foo
451
451
452 $ cat .hg/store/fncache | sort
452 $ cat .hg/store/fncache | sort
453 data/.bar.i
453 data/.bar.i
454 data/foo.i
454 data/foo.i
455
455
456 $ rm .hg/store/fncache
456 $ rm .hg/store/fncache
457 $ hg debugrebuildfncache
457 $ hg debugrebuildfncache
458 adding data/.bar.i
458 adding data/.bar.i
459 adding data/foo.i
459 adding data/foo.i
460 2 items added, 0 removed from fncache
460 2 items added, 0 removed from fncache
461
461
462 $ cat .hg/store/fncache | sort
462 $ cat .hg/store/fncache | sort
463 data/.bar.i
463 data/.bar.i
464 data/foo.i
464 data/foo.i
465
465
466 $ cd ..
466 $ cd ..
467
467
468 In repositories that have accumulated a large number of files over time, the
468 In repositories that have accumulated a large number of files over time, the
469 fncache file is going to be large. If we possibly can avoid loading it, so much the better.
469 fncache file is going to be large. If we possibly can avoid loading it, so much the better.
470 The cache should not loaded when committing changes to existing files, or when unbundling
470 The cache should not loaded when committing changes to existing files, or when unbundling
471 changesets that only contain changes to existing files:
471 changesets that only contain changes to existing files:
472
472
473 $ cat > fncacheloadwarn.py << EOF
473 $ cat > fncacheloadwarn.py << EOF
474 > from mercurial import extensions, localrepo
474 > from mercurial import extensions, localrepo
475 >
475 >
476 > def extsetup(ui):
476 > def extsetup(ui):
477 > def wrapstore(orig, requirements, *args):
477 > def wrapstore(orig, requirements, *args):
478 > store = orig(requirements, *args)
478 > store = orig(requirements, *args)
479 > if b'store' in requirements and b'fncache' in requirements:
479 > if b'store' in requirements and b'fncache' in requirements:
480 > instrumentfncachestore(store, ui)
480 > instrumentfncachestore(store, ui)
481 > return store
481 > return store
482 > extensions.wrapfunction(localrepo, 'makestore', wrapstore)
482 > extensions.wrapfunction(localrepo, 'makestore', wrapstore)
483 >
483 >
484 > def instrumentfncachestore(fncachestore, ui):
484 > def instrumentfncachestore(fncachestore, ui):
485 > class instrumentedfncache(type(fncachestore.fncache)):
485 > class instrumentedfncache(type(fncachestore.fncache)):
486 > def _load(self):
486 > def _load(self):
487 > ui.warn(b'fncache load triggered!\n')
487 > ui.warn(b'fncache load triggered!\n')
488 > super(instrumentedfncache, self)._load()
488 > super(instrumentedfncache, self)._load()
489 > fncachestore.fncache.__class__ = instrumentedfncache
489 > fncachestore.fncache.__class__ = instrumentedfncache
490 > EOF
490 > EOF
491
491
492 $ fncachextpath=`pwd`/fncacheloadwarn.py
492 $ fncachextpath=`pwd`/fncacheloadwarn.py
493 $ hg init nofncacheload
493 $ hg init nofncacheload
494 $ cd nofncacheload
494 $ cd nofncacheload
495 $ printf "[extensions]\nfncacheloadwarn=$fncachextpath\n" >> .hg/hgrc
495 $ printf "[extensions]\nfncacheloadwarn=$fncachextpath\n" >> .hg/hgrc
496
496
497 A new file should trigger a load, as we'd want to update the fncache set in that case:
497 A new file should trigger a load, as we'd want to update the fncache set in that case:
498
498
499 $ touch foo
499 $ touch foo
500 $ hg ci -qAm foo
500 $ hg ci -qAm foo
501 fncache load triggered!
501 fncache load triggered!
502
502
503 But modifying that file should not:
503 But modifying that file should not:
504
504
505 $ echo bar >> foo
505 $ echo bar >> foo
506 $ hg ci -qm foo
506 $ hg ci -qm foo
507
507
508 If a transaction has been aborted, the zero-size truncated index file will
508 If a transaction has been aborted, the zero-size truncated index file will
509 not prevent the fncache from being loaded; rather than actually abort
509 not prevent the fncache from being loaded; rather than actually abort
510 a transaction, we simulate the situation by creating a zero-size index file:
510 a transaction, we simulate the situation by creating a zero-size index file:
511
511
512 $ touch .hg/store/data/bar.i
512 $ touch .hg/store/data/bar.i
513 $ touch bar
513 $ touch bar
514 $ hg ci -qAm bar
514 $ hg ci -qAm bar
515 fncache load triggered!
515 fncache load triggered!
516
516
517 Unbundling should follow the same rules; existing files should not cause a load:
517 Unbundling should follow the same rules; existing files should not cause a load:
518
518
519 (loading during the clone is expected)
519 (loading during the clone is expected)
520 $ hg clone -q . tobundle
520 $ hg clone -q . tobundle
521 fncache load triggered!
521 fncache load triggered!
522 fncache load triggered!
522 fncache load triggered!
523
523
524 $ echo 'new line' > tobundle/bar
524 $ echo 'new line' > tobundle/bar
525 $ hg -R tobundle ci -qm bar
525 $ hg -R tobundle ci -qm bar
526 $ hg -R tobundle bundle -q barupdated.hg
526 $ hg -R tobundle bundle -q barupdated.hg
527 $ hg unbundle -q barupdated.hg
527 $ hg unbundle -q barupdated.hg
528
528
529 but adding new files should:
529 but adding new files should:
530
530
531 $ touch tobundle/newfile
531 $ touch tobundle/newfile
532 $ hg -R tobundle ci -qAm newfile
532 $ hg -R tobundle ci -qAm newfile
533 $ hg -R tobundle bundle -q newfile.hg
533 $ hg -R tobundle bundle -q newfile.hg
534 $ hg unbundle -q newfile.hg
534 $ hg unbundle -q newfile.hg
535 fncache load triggered!
535 fncache load triggered!
536
536
537 $ cd ..
537 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now