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