Show More
@@ -1,298 +1,298 b'' | |||||
1 | # repair.py - functions for repository repair for mercurial |
|
1 | # repair.py - functions for repository repair for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005, 2006 Chris Mason <mason@suse.com> |
|
3 | # Copyright 2005, 2006 Chris Mason <mason@suse.com> | |
4 | # Copyright 2007 Matt Mackall |
|
4 | # Copyright 2007 Matt Mackall | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | from mercurial import changegroup, exchange, util, bundle2 |
|
9 | from mercurial import changegroup, exchange, util, bundle2 | |
10 | from mercurial.node import short |
|
10 | from mercurial.node import short | |
11 | from mercurial.i18n import _ |
|
11 | from mercurial.i18n import _ | |
12 | import errno |
|
12 | import errno | |
13 |
|
13 | |||
14 | def _bundle(repo, bases, heads, node, suffix, compress=True): |
|
14 | def _bundle(repo, bases, heads, node, suffix, compress=True): | |
15 | """create a bundle with the specified revisions as a backup""" |
|
15 | """create a bundle with the specified revisions as a backup""" | |
16 | usebundle2 = (repo.ui.configbool('experimental', 'bundle2-exp', True) and |
|
16 | usebundle2 = (repo.ui.configbool('experimental', 'bundle2-exp', True) and | |
17 | repo.ui.config('experimental', 'strip-bundle2-version')) |
|
17 | repo.ui.config('experimental', 'strip-bundle2-version')) | |
18 | if usebundle2: |
|
18 | if usebundle2: | |
19 | cgversion = repo.ui.config('experimental', 'strip-bundle2-version') |
|
19 | cgversion = repo.ui.config('experimental', 'strip-bundle2-version') | |
20 | if cgversion not in changegroup.packermap: |
|
20 | if cgversion not in changegroup.packermap: | |
21 | repo.ui.warn(_('unknown strip-bundle2-version value %r; ' |
|
21 | repo.ui.warn(_('unknown strip-bundle2-version value %r; ' | |
22 | 'should be one of %r\n') % |
|
22 | 'should be one of %r\n') % | |
23 | (cgversion, sorted(changegroup.packermap.keys()),)) |
|
23 | (cgversion, sorted(changegroup.packermap.keys()),)) | |
24 | cgversion = '01' |
|
24 | cgversion = '01' | |
25 | usebundle2 = False |
|
25 | usebundle2 = False | |
26 | else: |
|
26 | else: | |
27 | cgversion = '01' |
|
27 | cgversion = '01' | |
28 |
|
28 | |||
29 | cg = changegroup.changegroupsubset(repo, bases, heads, 'strip', |
|
29 | cg = changegroup.changegroupsubset(repo, bases, heads, 'strip', | |
30 | version=cgversion) |
|
30 | version=cgversion) | |
31 | backupdir = "strip-backup" |
|
31 | backupdir = "strip-backup" | |
32 | vfs = repo.vfs |
|
32 | vfs = repo.vfs | |
33 | if not vfs.isdir(backupdir): |
|
33 | if not vfs.isdir(backupdir): | |
34 | vfs.mkdir(backupdir) |
|
34 | vfs.mkdir(backupdir) | |
35 |
|
35 | |||
36 | # Include a hash of all the nodes in the filename for uniqueness |
|
36 | # Include a hash of all the nodes in the filename for uniqueness | |
37 | allcommits = repo.set('%ln::%ln', bases, heads) |
|
37 | allcommits = repo.set('%ln::%ln', bases, heads) | |
38 | allhashes = sorted(c.hex() for c in allcommits) |
|
38 | allhashes = sorted(c.hex() for c in allcommits) | |
39 | totalhash = util.sha1(''.join(allhashes)).hexdigest() |
|
39 | totalhash = util.sha1(''.join(allhashes)).hexdigest() | |
40 | name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) |
|
40 | name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) | |
41 |
|
41 | |||
42 | if usebundle2: |
|
42 | if usebundle2: | |
43 | bundletype = "HG20" |
|
43 | bundletype = "HG20" | |
44 | elif compress: |
|
44 | elif compress: | |
45 | bundletype = "HG10BZ" |
|
45 | bundletype = "HG10BZ" | |
46 | else: |
|
46 | else: | |
47 | bundletype = "HG10UN" |
|
47 | bundletype = "HG10UN" | |
48 | return changegroup.writebundle(repo.ui, cg, name, bundletype, vfs) |
|
48 | return changegroup.writebundle(repo.ui, cg, name, bundletype, vfs) | |
49 |
|
49 | |||
50 | def _collectfiles(repo, striprev): |
|
50 | def _collectfiles(repo, striprev): | |
51 | """find out the filelogs affected by the strip""" |
|
51 | """find out the filelogs affected by the strip""" | |
52 | files = set() |
|
52 | files = set() | |
53 |
|
53 | |||
54 | for x in xrange(striprev, len(repo)): |
|
54 | for x in xrange(striprev, len(repo)): | |
55 | files.update(repo[x].files()) |
|
55 | files.update(repo[x].files()) | |
56 |
|
56 | |||
57 | return sorted(files) |
|
57 | return sorted(files) | |
58 |
|
58 | |||
59 | def _collectbrokencsets(repo, files, striprev): |
|
59 | def _collectbrokencsets(repo, files, striprev): | |
60 | """return the changesets which will be broken by the truncation""" |
|
60 | """return the changesets which will be broken by the truncation""" | |
61 | s = set() |
|
61 | s = set() | |
62 | def collectone(revlog): |
|
62 | def collectone(revlog): | |
63 | _, brokenset = revlog.getstrippoint(striprev) |
|
63 | _, brokenset = revlog.getstrippoint(striprev) | |
64 | s.update([revlog.linkrev(r) for r in brokenset]) |
|
64 | s.update([revlog.linkrev(r) for r in brokenset]) | |
65 |
|
65 | |||
66 | collectone(repo.manifest) |
|
66 | collectone(repo.manifest) | |
67 | for fname in files: |
|
67 | for fname in files: | |
68 | collectone(repo.file(fname)) |
|
68 | collectone(repo.file(fname)) | |
69 |
|
69 | |||
70 | return s |
|
70 | return s | |
71 |
|
71 | |||
72 | def strip(ui, repo, nodelist, backup=True, topic='backup'): |
|
72 | def strip(ui, repo, nodelist, backup=True, topic='backup'): | |
73 |
|
73 | |||
74 | # Simple way to maintain backwards compatibility for this |
|
74 | # Simple way to maintain backwards compatibility for this | |
75 | # argument. |
|
75 | # argument. | |
76 | if backup in ['none', 'strip']: |
|
76 | if backup in ['none', 'strip']: | |
77 | backup = False |
|
77 | backup = False | |
78 |
|
78 | |||
79 | repo = repo.unfiltered() |
|
79 | repo = repo.unfiltered() | |
80 | repo.destroying() |
|
80 | repo.destroying() | |
81 |
|
81 | |||
82 | cl = repo.changelog |
|
82 | cl = repo.changelog | |
83 | # TODO handle undo of merge sets |
|
83 | # TODO handle undo of merge sets | |
84 | if isinstance(nodelist, str): |
|
84 | if isinstance(nodelist, str): | |
85 | nodelist = [nodelist] |
|
85 | nodelist = [nodelist] | |
86 | striplist = [cl.rev(node) for node in nodelist] |
|
86 | striplist = [cl.rev(node) for node in nodelist] | |
87 | striprev = min(striplist) |
|
87 | striprev = min(striplist) | |
88 |
|
88 | |||
89 | # Some revisions with rev > striprev may not be descendants of striprev. |
|
89 | # Some revisions with rev > striprev may not be descendants of striprev. | |
90 | # We have to find these revisions and put them in a bundle, so that |
|
90 | # We have to find these revisions and put them in a bundle, so that | |
91 | # we can restore them after the truncations. |
|
91 | # we can restore them after the truncations. | |
92 | # To create the bundle we use repo.changegroupsubset which requires |
|
92 | # To create the bundle we use repo.changegroupsubset which requires | |
93 | # the list of heads and bases of the set of interesting revisions. |
|
93 | # the list of heads and bases of the set of interesting revisions. | |
94 | # (head = revision in the set that has no descendant in the set; |
|
94 | # (head = revision in the set that has no descendant in the set; | |
95 | # base = revision in the set that has no ancestor in the set) |
|
95 | # base = revision in the set that has no ancestor in the set) | |
96 | tostrip = set(striplist) |
|
96 | tostrip = set(striplist) | |
97 | for rev in striplist: |
|
97 | for rev in striplist: | |
98 | for desc in cl.descendants([rev]): |
|
98 | for desc in cl.descendants([rev]): | |
99 | tostrip.add(desc) |
|
99 | tostrip.add(desc) | |
100 |
|
100 | |||
101 | files = _collectfiles(repo, striprev) |
|
101 | files = _collectfiles(repo, striprev) | |
102 | saverevs = _collectbrokencsets(repo, files, striprev) |
|
102 | saverevs = _collectbrokencsets(repo, files, striprev) | |
103 |
|
103 | |||
104 | # compute heads |
|
104 | # compute heads | |
105 | saveheads = set(saverevs) |
|
105 | saveheads = set(saverevs) | |
106 | for r in xrange(striprev + 1, len(cl)): |
|
106 | for r in xrange(striprev + 1, len(cl)): | |
107 | if r not in tostrip: |
|
107 | if r not in tostrip: | |
108 | saverevs.add(r) |
|
108 | saverevs.add(r) | |
109 | saveheads.difference_update(cl.parentrevs(r)) |
|
109 | saveheads.difference_update(cl.parentrevs(r)) | |
110 | saveheads.add(r) |
|
110 | saveheads.add(r) | |
111 | saveheads = [cl.node(r) for r in saveheads] |
|
111 | saveheads = [cl.node(r) for r in saveheads] | |
112 |
|
112 | |||
113 | # compute base nodes |
|
113 | # compute base nodes | |
114 | if saverevs: |
|
114 | if saverevs: | |
115 | descendants = set(cl.descendants(saverevs)) |
|
115 | descendants = set(cl.descendants(saverevs)) | |
116 | saverevs.difference_update(descendants) |
|
116 | saverevs.difference_update(descendants) | |
117 | savebases = [cl.node(r) for r in saverevs] |
|
117 | savebases = [cl.node(r) for r in saverevs] | |
118 | stripbases = [cl.node(r) for r in tostrip] |
|
118 | stripbases = [cl.node(r) for r in tostrip] | |
119 |
|
119 | |||
120 | # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but |
|
120 | # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but | |
121 | # is much faster |
|
121 | # is much faster | |
122 | newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) |
|
122 | newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip) | |
123 | if newbmtarget: |
|
123 | if newbmtarget: | |
124 | newbmtarget = repo[newbmtarget.first()].node() |
|
124 | newbmtarget = repo[newbmtarget.first()].node() | |
125 | else: |
|
125 | else: | |
126 | newbmtarget = '.' |
|
126 | newbmtarget = '.' | |
127 |
|
127 | |||
128 | bm = repo._bookmarks |
|
128 | bm = repo._bookmarks | |
129 | updatebm = [] |
|
129 | updatebm = [] | |
130 | for m in bm: |
|
130 | for m in bm: | |
131 | rev = repo[bm[m]].rev() |
|
131 | rev = repo[bm[m]].rev() | |
132 | if rev in tostrip: |
|
132 | if rev in tostrip: | |
133 | updatebm.append(m) |
|
133 | updatebm.append(m) | |
134 |
|
134 | |||
135 | # create a changegroup for all the branches we need to keep |
|
135 | # create a changegroup for all the branches we need to keep | |
136 | backupfile = None |
|
136 | backupfile = None | |
137 | vfs = repo.vfs |
|
137 | vfs = repo.vfs | |
138 | node = nodelist[-1] |
|
138 | node = nodelist[-1] | |
139 | if backup: |
|
139 | if backup: | |
140 | backupfile = _bundle(repo, stripbases, cl.heads(), node, topic) |
|
140 | backupfile = _bundle(repo, stripbases, cl.heads(), node, topic) | |
141 | repo.ui.status(_("saved backup bundle to %s\n") % |
|
141 | repo.ui.status(_("saved backup bundle to %s\n") % | |
142 | vfs.join(backupfile)) |
|
142 | vfs.join(backupfile)) | |
143 | repo.ui.log("backupbundle", "saved backup bundle to %s\n", |
|
143 | repo.ui.log("backupbundle", "saved backup bundle to %s\n", | |
144 | vfs.join(backupfile)) |
|
144 | vfs.join(backupfile)) | |
145 | if saveheads or savebases: |
|
145 | if saveheads or savebases: | |
146 | # do not compress partial bundle if we remove it from disk later |
|
146 | # do not compress partial bundle if we remove it from disk later | |
147 | chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp', |
|
147 | chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp', | |
148 | compress=False) |
|
148 | compress=False) | |
149 |
|
149 | |||
150 | mfst = repo.manifest |
|
150 | mfst = repo.manifest | |
151 |
|
151 | |||
152 | curtr = repo.currenttransaction() |
|
152 | curtr = repo.currenttransaction() | |
153 | if curtr is not None: |
|
153 | if curtr is not None: | |
154 | del curtr # avoid carrying reference to transaction for nothing |
|
154 | del curtr # avoid carrying reference to transaction for nothing | |
155 | msg = _('programming error: cannot strip from inside a transaction') |
|
155 | msg = _('programming error: cannot strip from inside a transaction') | |
156 | raise util.Abort(msg, hint=_('contact your extension maintainer')) |
|
156 | raise util.Abort(msg, hint=_('contact your extension maintainer')) | |
157 |
|
157 | |||
158 | tr = repo.transaction("strip") |
|
158 | tr = repo.transaction("strip") | |
159 | offset = len(tr.entries) |
|
159 | offset = len(tr.entries) | |
160 |
|
160 | |||
161 | try: |
|
161 | try: | |
162 | tr.startgroup() |
|
162 | tr.startgroup() | |
163 | cl.strip(striprev, tr) |
|
163 | cl.strip(striprev, tr) | |
164 | mfst.strip(striprev, tr) |
|
164 | mfst.strip(striprev, tr) | |
165 | for fn in files: |
|
165 | for fn in files: | |
166 | repo.file(fn).strip(striprev, tr) |
|
166 | repo.file(fn).strip(striprev, tr) | |
167 | tr.endgroup() |
|
167 | tr.endgroup() | |
168 |
|
168 | |||
169 | try: |
|
169 | try: | |
170 | for i in xrange(offset, len(tr.entries)): |
|
170 | for i in xrange(offset, len(tr.entries)): | |
171 | file, troffset, ignore = tr.entries[i] |
|
171 | file, troffset, ignore = tr.entries[i] | |
172 | repo.svfs(file, 'a').truncate(troffset) |
|
172 | repo.svfs(file, 'a').truncate(troffset) | |
173 | if troffset == 0: |
|
173 | if troffset == 0: | |
174 | repo.store.markremoved(file) |
|
174 | repo.store.markremoved(file) | |
175 | tr.close() |
|
175 | tr.close() | |
176 | except: # re-raises |
|
176 | except: # re-raises | |
177 | tr.abort() |
|
177 | tr.abort() | |
178 | raise |
|
178 | raise | |
179 |
|
179 | |||
180 | if saveheads or savebases: |
|
180 | if saveheads or savebases: | |
181 | ui.note(_("adding branch\n")) |
|
181 | ui.note(_("adding branch\n")) | |
182 | f = vfs.open(chgrpfile, "rb") |
|
182 | f = vfs.open(chgrpfile, "rb") | |
183 | gen = exchange.readbundle(ui, f, chgrpfile, vfs) |
|
183 | gen = exchange.readbundle(ui, f, chgrpfile, vfs) | |
184 | if not repo.ui.verbose: |
|
184 | if not repo.ui.verbose: | |
185 | # silence internal shuffling chatter |
|
185 | # silence internal shuffling chatter | |
186 | repo.ui.pushbuffer() |
|
186 | repo.ui.pushbuffer() | |
187 | if isinstance(gen, bundle2.unbundle20): |
|
187 | if isinstance(gen, bundle2.unbundle20): | |
188 | tr = repo.transaction('strip') |
|
188 | tr = repo.transaction('strip') | |
189 | tr.hookargs = {'source': 'strip', |
|
189 | tr.hookargs = {'source': 'strip', | |
190 | 'url': 'bundle:' + vfs.join(chgrpfile)} |
|
190 | 'url': 'bundle:' + vfs.join(chgrpfile)} | |
191 | try: |
|
191 | try: | |
192 | bundle2.processbundle(repo, gen, lambda: tr) |
|
192 | bundle2.processbundle(repo, gen, lambda: tr) | |
193 | tr.close() |
|
193 | tr.close() | |
194 | finally: |
|
194 | finally: | |
195 | tr.release() |
|
195 | tr.release() | |
196 | else: |
|
196 | else: | |
197 | changegroup.addchangegroup(repo, gen, 'strip', |
|
197 | changegroup.addchangegroup(repo, gen, 'strip', | |
198 | 'bundle:' + vfs.join(chgrpfile), |
|
198 | 'bundle:' + vfs.join(chgrpfile), | |
199 | True) |
|
199 | True) | |
200 | if not repo.ui.verbose: |
|
200 | if not repo.ui.verbose: | |
201 | repo.ui.popbuffer() |
|
201 | repo.ui.popbuffer() | |
202 | f.close() |
|
202 | f.close() | |
203 |
|
203 | |||
204 | # remove undo files |
|
204 | # remove undo files | |
205 | for undovfs, undofile in repo.undofiles(): |
|
205 | for undovfs, undofile in repo.undofiles(): | |
206 | try: |
|
206 | try: | |
207 | undovfs.unlink(undofile) |
|
207 | undovfs.unlink(undofile) | |
208 | except OSError as e: |
|
208 | except OSError as e: | |
209 | if e.errno != errno.ENOENT: |
|
209 | if e.errno != errno.ENOENT: | |
210 | ui.warn(_('error removing %s: %s\n') % |
|
210 | ui.warn(_('error removing %s: %s\n') % | |
211 | (undovfs.join(undofile), str(e))) |
|
211 | (undovfs.join(undofile), str(e))) | |
212 |
|
212 | |||
213 | for m in updatebm: |
|
213 | for m in updatebm: | |
214 | bm[m] = repo[newbmtarget].node() |
|
214 | bm[m] = repo[newbmtarget].node() | |
215 | bm.write() |
|
215 | bm.write() | |
216 | except: # re-raises |
|
216 | except: # re-raises | |
217 | if backupfile: |
|
217 | if backupfile: | |
218 | ui.warn(_("strip failed, full bundle stored in '%s'\n") |
|
218 | ui.warn(_("strip failed, full bundle stored in '%s'\n") | |
219 | % vfs.join(backupfile)) |
|
219 | % vfs.join(backupfile)) | |
220 | elif saveheads: |
|
220 | elif saveheads: | |
221 | ui.warn(_("strip failed, partial bundle stored in '%s'\n") |
|
221 | ui.warn(_("strip failed, partial bundle stored in '%s'\n") | |
222 | % vfs.join(chgrpfile)) |
|
222 | % vfs.join(chgrpfile)) | |
223 | raise |
|
223 | raise | |
224 | else: |
|
224 | else: | |
225 | if saveheads or savebases: |
|
225 | if saveheads or savebases: | |
226 | # Remove partial backup only if there were no exceptions |
|
226 | # Remove partial backup only if there were no exceptions | |
227 | vfs.unlink(chgrpfile) |
|
227 | vfs.unlink(chgrpfile) | |
228 |
|
228 | |||
229 | repo.destroyed() |
|
229 | repo.destroyed() | |
230 |
|
230 | |||
231 | def rebuildfncache(ui, repo): |
|
231 | def rebuildfncache(ui, repo): | |
232 | """Rebuilds the fncache file from repo history. |
|
232 | """Rebuilds the fncache file from repo history. | |
233 |
|
233 | |||
234 | Missing entries will be added. Extra entries will be removed. |
|
234 | Missing entries will be added. Extra entries will be removed. | |
235 | """ |
|
235 | """ | |
236 | repo = repo.unfiltered() |
|
236 | repo = repo.unfiltered() | |
237 |
|
237 | |||
238 | if 'fncache' not in repo.requirements: |
|
238 | if 'fncache' not in repo.requirements: | |
239 | ui.warn(_('(not rebuilding fncache because repository does not ' |
|
239 | ui.warn(_('(not rebuilding fncache because repository does not ' | |
240 | 'support fncache\n')) |
|
240 | 'support fncache)\n')) | |
241 | return |
|
241 | return | |
242 |
|
242 | |||
243 | lock = repo.lock() |
|
243 | lock = repo.lock() | |
244 | try: |
|
244 | try: | |
245 | fnc = repo.store.fncache |
|
245 | fnc = repo.store.fncache | |
246 | # Trigger load of fncache. |
|
246 | # Trigger load of fncache. | |
247 | if 'irrelevant' in fnc: |
|
247 | if 'irrelevant' in fnc: | |
248 | pass |
|
248 | pass | |
249 |
|
249 | |||
250 | oldentries = set(fnc.entries) |
|
250 | oldentries = set(fnc.entries) | |
251 | newentries = set() |
|
251 | newentries = set() | |
252 | seenfiles = set() |
|
252 | seenfiles = set() | |
253 |
|
253 | |||
254 | repolen = len(repo) |
|
254 | repolen = len(repo) | |
255 | for rev in repo: |
|
255 | for rev in repo: | |
256 | ui.progress(_('changeset'), rev, total=repolen) |
|
256 | ui.progress(_('changeset'), rev, total=repolen) | |
257 |
|
257 | |||
258 | ctx = repo[rev] |
|
258 | ctx = repo[rev] | |
259 | for f in ctx.files(): |
|
259 | for f in ctx.files(): | |
260 | # This is to minimize I/O. |
|
260 | # This is to minimize I/O. | |
261 | if f in seenfiles: |
|
261 | if f in seenfiles: | |
262 | continue |
|
262 | continue | |
263 | seenfiles.add(f) |
|
263 | seenfiles.add(f) | |
264 |
|
264 | |||
265 | i = 'data/%s.i' % f |
|
265 | i = 'data/%s.i' % f | |
266 | d = 'data/%s.d' % f |
|
266 | d = 'data/%s.d' % f | |
267 |
|
267 | |||
268 | if repo.store._exists(i): |
|
268 | if repo.store._exists(i): | |
269 | newentries.add(i) |
|
269 | newentries.add(i) | |
270 | if repo.store._exists(d): |
|
270 | if repo.store._exists(d): | |
271 | newentries.add(d) |
|
271 | newentries.add(d) | |
272 |
|
272 | |||
273 | ui.progress(_('changeset'), None) |
|
273 | ui.progress(_('changeset'), None) | |
274 |
|
274 | |||
275 | addcount = len(newentries - oldentries) |
|
275 | addcount = len(newentries - oldentries) | |
276 | removecount = len(oldentries - newentries) |
|
276 | removecount = len(oldentries - newentries) | |
277 | for p in sorted(oldentries - newentries): |
|
277 | for p in sorted(oldentries - newentries): | |
278 | ui.write(_('removing %s\n') % p) |
|
278 | ui.write(_('removing %s\n') % p) | |
279 | for p in sorted(newentries - oldentries): |
|
279 | for p in sorted(newentries - oldentries): | |
280 | ui.write(_('adding %s\n') % p) |
|
280 | ui.write(_('adding %s\n') % p) | |
281 |
|
281 | |||
282 | if addcount or removecount: |
|
282 | if addcount or removecount: | |
283 | ui.write(_('%d items added, %d removed from fncache\n') % |
|
283 | ui.write(_('%d items added, %d removed from fncache\n') % | |
284 | (addcount, removecount)) |
|
284 | (addcount, removecount)) | |
285 | fnc.entries = newentries |
|
285 | fnc.entries = newentries | |
286 | fnc._dirty = True |
|
286 | fnc._dirty = True | |
287 |
|
287 | |||
288 | tr = repo.transaction('fncache') |
|
288 | tr = repo.transaction('fncache') | |
289 | try: |
|
289 | try: | |
290 | fnc.write(tr) |
|
290 | fnc.write(tr) | |
291 | tr.close() |
|
291 | tr.close() | |
292 | finally: |
|
292 | finally: | |
293 | tr.release() |
|
293 | tr.release() | |
294 | else: |
|
294 | else: | |
295 | ui.write(_('fncache already up to date\n')) |
|
295 | ui.write(_('fncache already up to date\n')) | |
296 | finally: |
|
296 | finally: | |
297 | lock.release() |
|
297 | lock.release() | |
298 |
|
298 |
@@ -1,397 +1,397 b'' | |||||
1 | Init repo1: |
|
1 | Init repo1: | |
2 |
|
2 | |||
3 | $ hg init repo1 |
|
3 | $ hg init repo1 | |
4 | $ cd repo1 |
|
4 | $ cd repo1 | |
5 | $ echo "some text" > a |
|
5 | $ echo "some text" > a | |
6 | $ hg add |
|
6 | $ hg add | |
7 | adding a |
|
7 | adding a | |
8 | $ hg ci -m first |
|
8 | $ hg ci -m first | |
9 | $ cat .hg/store/fncache | sort |
|
9 | $ cat .hg/store/fncache | sort | |
10 | data/a.i |
|
10 | data/a.i | |
11 |
|
11 | |||
12 | Testing a.i/b: |
|
12 | Testing a.i/b: | |
13 |
|
13 | |||
14 | $ mkdir a.i |
|
14 | $ mkdir a.i | |
15 | $ echo "some other text" > a.i/b |
|
15 | $ echo "some other text" > a.i/b | |
16 | $ hg add |
|
16 | $ hg add | |
17 | adding a.i/b (glob) |
|
17 | adding a.i/b (glob) | |
18 | $ hg ci -m second |
|
18 | $ hg ci -m second | |
19 | $ cat .hg/store/fncache | sort |
|
19 | $ cat .hg/store/fncache | sort | |
20 | data/a.i |
|
20 | data/a.i | |
21 | data/a.i.hg/b.i |
|
21 | data/a.i.hg/b.i | |
22 |
|
22 | |||
23 | Testing a.i.hg/c: |
|
23 | Testing a.i.hg/c: | |
24 |
|
24 | |||
25 | $ mkdir a.i.hg |
|
25 | $ mkdir a.i.hg | |
26 | $ echo "yet another text" > a.i.hg/c |
|
26 | $ echo "yet another text" > a.i.hg/c | |
27 | $ hg add |
|
27 | $ hg add | |
28 | adding a.i.hg/c (glob) |
|
28 | adding a.i.hg/c (glob) | |
29 | $ hg ci -m third |
|
29 | $ hg ci -m third | |
30 | $ cat .hg/store/fncache | sort |
|
30 | $ cat .hg/store/fncache | sort | |
31 | data/a.i |
|
31 | data/a.i | |
32 | data/a.i.hg.hg/c.i |
|
32 | data/a.i.hg.hg/c.i | |
33 | data/a.i.hg/b.i |
|
33 | data/a.i.hg/b.i | |
34 |
|
34 | |||
35 | Testing verify: |
|
35 | Testing verify: | |
36 |
|
36 | |||
37 | $ hg verify |
|
37 | $ hg verify | |
38 | checking changesets |
|
38 | checking changesets | |
39 | checking manifests |
|
39 | checking manifests | |
40 | crosschecking files in changesets and manifests |
|
40 | crosschecking files in changesets and manifests | |
41 | checking files |
|
41 | checking files | |
42 | 3 files, 3 changesets, 3 total revisions |
|
42 | 3 files, 3 changesets, 3 total revisions | |
43 |
|
43 | |||
44 | $ rm .hg/store/fncache |
|
44 | $ rm .hg/store/fncache | |
45 |
|
45 | |||
46 | $ hg verify |
|
46 | $ hg verify | |
47 | checking changesets |
|
47 | checking changesets | |
48 | checking manifests |
|
48 | checking manifests | |
49 | crosschecking files in changesets and manifests |
|
49 | crosschecking files in changesets and manifests | |
50 | checking files |
|
50 | checking files | |
51 | warning: revlog 'data/a.i' not in fncache! |
|
51 | warning: revlog 'data/a.i' not in fncache! | |
52 | warning: revlog 'data/a.i.hg/c.i' not in fncache! |
|
52 | warning: revlog 'data/a.i.hg/c.i' not in fncache! | |
53 | warning: revlog 'data/a.i/b.i' not in fncache! |
|
53 | warning: revlog 'data/a.i/b.i' not in fncache! | |
54 | 3 files, 3 changesets, 3 total revisions |
|
54 | 3 files, 3 changesets, 3 total revisions | |
55 | 3 warnings encountered! |
|
55 | 3 warnings encountered! | |
56 | hint: run "hg debugrebuildfncache" to recover from corrupt fncache |
|
56 | hint: run "hg debugrebuildfncache" to recover from corrupt fncache | |
57 |
|
57 | |||
58 | Follow the hint to make sure it works |
|
58 | Follow the hint to make sure it works | |
59 |
|
59 | |||
60 | $ hg debugrebuildfncache |
|
60 | $ hg debugrebuildfncache | |
61 | adding data/a.i |
|
61 | adding data/a.i | |
62 | adding data/a.i.hg/c.i |
|
62 | adding data/a.i.hg/c.i | |
63 | adding data/a.i/b.i |
|
63 | adding data/a.i/b.i | |
64 | 3 items added, 0 removed from fncache |
|
64 | 3 items added, 0 removed from fncache | |
65 |
|
65 | |||
66 | $ hg verify |
|
66 | $ hg verify | |
67 | checking changesets |
|
67 | checking changesets | |
68 | checking manifests |
|
68 | checking manifests | |
69 | crosschecking files in changesets and manifests |
|
69 | crosschecking files in changesets and manifests | |
70 | checking files |
|
70 | checking files | |
71 | 3 files, 3 changesets, 3 total revisions |
|
71 | 3 files, 3 changesets, 3 total revisions | |
72 |
|
72 | |||
73 | $ cd .. |
|
73 | $ cd .. | |
74 |
|
74 | |||
75 | Non store repo: |
|
75 | Non store repo: | |
76 |
|
76 | |||
77 | $ hg --config format.usestore=False init foo |
|
77 | $ hg --config format.usestore=False init foo | |
78 | $ cd foo |
|
78 | $ cd foo | |
79 | $ mkdir tst.d |
|
79 | $ mkdir tst.d | |
80 | $ echo foo > tst.d/foo |
|
80 | $ echo foo > tst.d/foo | |
81 | $ hg ci -Amfoo |
|
81 | $ hg ci -Amfoo | |
82 | adding tst.d/foo |
|
82 | adding tst.d/foo | |
83 | $ find .hg | sort |
|
83 | $ find .hg | sort | |
84 | .hg |
|
84 | .hg | |
85 | .hg/00changelog.i |
|
85 | .hg/00changelog.i | |
86 | .hg/00manifest.i |
|
86 | .hg/00manifest.i | |
87 | .hg/cache |
|
87 | .hg/cache | |
88 | .hg/cache/branch2-served |
|
88 | .hg/cache/branch2-served | |
89 | .hg/cache/rbc-names-v1 |
|
89 | .hg/cache/rbc-names-v1 | |
90 | .hg/cache/rbc-revs-v1 |
|
90 | .hg/cache/rbc-revs-v1 | |
91 | .hg/data |
|
91 | .hg/data | |
92 | .hg/data/tst.d.hg |
|
92 | .hg/data/tst.d.hg | |
93 | .hg/data/tst.d.hg/foo.i |
|
93 | .hg/data/tst.d.hg/foo.i | |
94 | .hg/dirstate |
|
94 | .hg/dirstate | |
95 | .hg/last-message.txt |
|
95 | .hg/last-message.txt | |
96 | .hg/phaseroots |
|
96 | .hg/phaseroots | |
97 | .hg/requires |
|
97 | .hg/requires | |
98 | .hg/undo |
|
98 | .hg/undo | |
99 | .hg/undo.backupfiles |
|
99 | .hg/undo.backupfiles | |
100 | .hg/undo.bookmarks |
|
100 | .hg/undo.bookmarks | |
101 | .hg/undo.branch |
|
101 | .hg/undo.branch | |
102 | .hg/undo.desc |
|
102 | .hg/undo.desc | |
103 | .hg/undo.dirstate |
|
103 | .hg/undo.dirstate | |
104 | .hg/undo.phaseroots |
|
104 | .hg/undo.phaseroots | |
105 | $ cd .. |
|
105 | $ cd .. | |
106 |
|
106 | |||
107 | Non fncache repo: |
|
107 | Non fncache repo: | |
108 |
|
108 | |||
109 | $ hg --config format.usefncache=False init bar |
|
109 | $ hg --config format.usefncache=False init bar | |
110 | $ cd bar |
|
110 | $ cd bar | |
111 | $ mkdir tst.d |
|
111 | $ mkdir tst.d | |
112 | $ echo foo > tst.d/Foo |
|
112 | $ echo foo > tst.d/Foo | |
113 | $ hg ci -Amfoo |
|
113 | $ hg ci -Amfoo | |
114 | adding tst.d/Foo |
|
114 | adding tst.d/Foo | |
115 | $ find .hg | sort |
|
115 | $ find .hg | sort | |
116 | .hg |
|
116 | .hg | |
117 | .hg/00changelog.i |
|
117 | .hg/00changelog.i | |
118 | .hg/cache |
|
118 | .hg/cache | |
119 | .hg/cache/branch2-served |
|
119 | .hg/cache/branch2-served | |
120 | .hg/cache/rbc-names-v1 |
|
120 | .hg/cache/rbc-names-v1 | |
121 | .hg/cache/rbc-revs-v1 |
|
121 | .hg/cache/rbc-revs-v1 | |
122 | .hg/dirstate |
|
122 | .hg/dirstate | |
123 | .hg/last-message.txt |
|
123 | .hg/last-message.txt | |
124 | .hg/requires |
|
124 | .hg/requires | |
125 | .hg/store |
|
125 | .hg/store | |
126 | .hg/store/00changelog.i |
|
126 | .hg/store/00changelog.i | |
127 | .hg/store/00manifest.i |
|
127 | .hg/store/00manifest.i | |
128 | .hg/store/data |
|
128 | .hg/store/data | |
129 | .hg/store/data/tst.d.hg |
|
129 | .hg/store/data/tst.d.hg | |
130 | .hg/store/data/tst.d.hg/_foo.i |
|
130 | .hg/store/data/tst.d.hg/_foo.i | |
131 | .hg/store/phaseroots |
|
131 | .hg/store/phaseroots | |
132 | .hg/store/undo |
|
132 | .hg/store/undo | |
133 | .hg/store/undo.backupfiles |
|
133 | .hg/store/undo.backupfiles | |
134 | .hg/store/undo.phaseroots |
|
134 | .hg/store/undo.phaseroots | |
135 | .hg/undo.bookmarks |
|
135 | .hg/undo.bookmarks | |
136 | .hg/undo.branch |
|
136 | .hg/undo.branch | |
137 | .hg/undo.desc |
|
137 | .hg/undo.desc | |
138 | .hg/undo.dirstate |
|
138 | .hg/undo.dirstate | |
139 | $ cd .. |
|
139 | $ cd .. | |
140 |
|
140 | |||
141 | Encoding of reserved / long paths in the store |
|
141 | Encoding of reserved / long paths in the store | |
142 |
|
142 | |||
143 | $ hg init r2 |
|
143 | $ hg init r2 | |
144 | $ cd r2 |
|
144 | $ cd r2 | |
145 | $ cat <<EOF > .hg/hgrc |
|
145 | $ cat <<EOF > .hg/hgrc | |
146 | > [ui] |
|
146 | > [ui] | |
147 | > portablefilenames = ignore |
|
147 | > portablefilenames = ignore | |
148 | > EOF |
|
148 | > EOF | |
149 |
|
149 | |||
150 | $ hg import -q --bypass - <<EOF |
|
150 | $ hg import -q --bypass - <<EOF | |
151 | > # HG changeset patch |
|
151 | > # HG changeset patch | |
152 | > # User test |
|
152 | > # User test | |
153 | > # Date 0 0 |
|
153 | > # Date 0 0 | |
154 | > # Node ID 1c7a2f7cb77be1a0def34e4c7cabc562ad98fbd7 |
|
154 | > # Node ID 1c7a2f7cb77be1a0def34e4c7cabc562ad98fbd7 | |
155 | > # Parent 0000000000000000000000000000000000000000 |
|
155 | > # Parent 0000000000000000000000000000000000000000 | |
156 | > 1 |
|
156 | > 1 | |
157 | > |
|
157 | > | |
158 | > 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 |
|
158 | > 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 | |
159 | > new file mode 100644 |
|
159 | > new file mode 100644 | |
160 | > --- /dev/null |
|
160 | > --- /dev/null | |
161 | > +++ b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz |
|
161 | > +++ b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz | |
162 | > @@ -0,0 +1,1 @@ |
|
162 | > @@ -0,0 +1,1 @@ | |
163 | > +foo |
|
163 | > +foo | |
164 | > 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 |
|
164 | > 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 | |
165 | > new file mode 100644 |
|
165 | > new file mode 100644 | |
166 | > --- /dev/null |
|
166 | > --- /dev/null | |
167 | > +++ b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT |
|
167 | > +++ b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT | |
168 | > @@ -0,0 +1,1 @@ |
|
168 | > @@ -0,0 +1,1 @@ | |
169 | > +foo |
|
169 | > +foo | |
170 | > diff --git a/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt |
|
170 | > diff --git a/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt | |
171 | > new file mode 100644 |
|
171 | > new file mode 100644 | |
172 | > --- /dev/null |
|
172 | > --- /dev/null | |
173 | > +++ b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt |
|
173 | > +++ b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt | |
174 | > @@ -0,0 +1,1 @@ |
|
174 | > @@ -0,0 +1,1 @@ | |
175 | > +foo |
|
175 | > +foo | |
176 | > 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 |
|
176 | > 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 | |
177 | > new file mode 100644 |
|
177 | > new file mode 100644 | |
178 | > --- /dev/null |
|
178 | > --- /dev/null | |
179 | > +++ b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c |
|
179 | > +++ b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c | |
180 | > @@ -0,0 +1,1 @@ |
|
180 | > @@ -0,0 +1,1 @@ | |
181 | > +foo |
|
181 | > +foo | |
182 | > 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 |
|
182 | > 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 | |
183 | > new file mode 100644 |
|
183 | > new file mode 100644 | |
184 | > --- /dev/null |
|
184 | > --- /dev/null | |
185 | > +++ b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider |
|
185 | > +++ b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider | |
186 | > @@ -0,0 +1,1 @@ |
|
186 | > @@ -0,0 +1,1 @@ | |
187 | > +foo |
|
187 | > +foo | |
188 | > EOF |
|
188 | > EOF | |
189 |
|
189 | |||
190 | $ find .hg/store -name *.i | sort |
|
190 | $ find .hg/store -name *.i | sort | |
191 | .hg/store/00changelog.i |
|
191 | .hg/store/00changelog.i | |
192 | .hg/store/00manifest.i |
|
192 | .hg/store/00manifest.i | |
193 | .hg/store/data/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i |
|
193 | .hg/store/data/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i | |
194 | .hg/store/dh/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxx168e07b38e65eff86ab579afaaa8e30bfbe0f35f.i |
|
194 | .hg/store/dh/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxx168e07b38e65eff86ab579afaaa8e30bfbe0f35f.i | |
195 | .hg/store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i |
|
195 | .hg/store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i | |
196 | .hg/store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i |
|
196 | .hg/store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i | |
197 | .hg/store/dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilename0d8e1f4187c650e2f1fdca9fd90f786bc0976b6b.i |
|
197 | .hg/store/dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilename0d8e1f4187c650e2f1fdca9fd90f786bc0976b6b.i | |
198 |
|
198 | |||
199 | $ cd .. |
|
199 | $ cd .. | |
200 |
|
200 | |||
201 | Aborting lock does not prevent fncache writes |
|
201 | Aborting lock does not prevent fncache writes | |
202 |
|
202 | |||
203 | $ cat > exceptionext.py <<EOF |
|
203 | $ cat > exceptionext.py <<EOF | |
204 | > import os |
|
204 | > import os | |
205 | > from mercurial import commands, util |
|
205 | > from mercurial import commands, util | |
206 | > from mercurial.extensions import wrapfunction |
|
206 | > from mercurial.extensions import wrapfunction | |
207 | > |
|
207 | > | |
208 | > def lockexception(orig, vfs, lockname, wait, releasefn, acquirefn, desc): |
|
208 | > def lockexception(orig, vfs, lockname, wait, releasefn, acquirefn, desc): | |
209 | > def releasewrap(): |
|
209 | > def releasewrap(): | |
210 | > raise util.Abort("forced lock failure") |
|
210 | > raise util.Abort("forced lock failure") | |
211 | > return orig(vfs, lockname, wait, releasewrap, acquirefn, desc) |
|
211 | > return orig(vfs, lockname, wait, releasewrap, acquirefn, desc) | |
212 | > |
|
212 | > | |
213 | > def reposetup(ui, repo): |
|
213 | > def reposetup(ui, repo): | |
214 | > wrapfunction(repo, '_lock', lockexception) |
|
214 | > wrapfunction(repo, '_lock', lockexception) | |
215 | > |
|
215 | > | |
216 | > cmdtable = {} |
|
216 | > cmdtable = {} | |
217 | > |
|
217 | > | |
218 | > EOF |
|
218 | > EOF | |
219 | $ extpath=`pwd`/exceptionext.py |
|
219 | $ extpath=`pwd`/exceptionext.py | |
220 | $ hg init fncachetxn |
|
220 | $ hg init fncachetxn | |
221 | $ cd fncachetxn |
|
221 | $ cd fncachetxn | |
222 | $ printf "[extensions]\nexceptionext=$extpath\n" >> .hg/hgrc |
|
222 | $ printf "[extensions]\nexceptionext=$extpath\n" >> .hg/hgrc | |
223 | $ touch y |
|
223 | $ touch y | |
224 | $ hg ci -qAm y |
|
224 | $ hg ci -qAm y | |
225 | abort: forced lock failure |
|
225 | abort: forced lock failure | |
226 | [255] |
|
226 | [255] | |
227 | $ cat .hg/store/fncache |
|
227 | $ cat .hg/store/fncache | |
228 | data/y.i |
|
228 | data/y.i | |
229 |
|
229 | |||
230 | Aborting transaction prevents fncache change |
|
230 | Aborting transaction prevents fncache change | |
231 |
|
231 | |||
232 | $ cat > ../exceptionext.py <<EOF |
|
232 | $ cat > ../exceptionext.py <<EOF | |
233 | > import os |
|
233 | > import os | |
234 | > from mercurial import commands, util, localrepo |
|
234 | > from mercurial import commands, util, localrepo | |
235 | > from mercurial.extensions import wrapfunction |
|
235 | > from mercurial.extensions import wrapfunction | |
236 | > |
|
236 | > | |
237 | > def wrapper(orig, self, *args, **kwargs): |
|
237 | > def wrapper(orig, self, *args, **kwargs): | |
238 | > tr = orig(self, *args, **kwargs) |
|
238 | > tr = orig(self, *args, **kwargs) | |
239 | > def fail(tr): |
|
239 | > def fail(tr): | |
240 | > raise util.Abort("forced transaction failure") |
|
240 | > raise util.Abort("forced transaction failure") | |
241 | > # zzz prefix to ensure it sorted after store.write |
|
241 | > # zzz prefix to ensure it sorted after store.write | |
242 | > tr.addfinalize('zzz-forcefails', fail) |
|
242 | > tr.addfinalize('zzz-forcefails', fail) | |
243 | > return tr |
|
243 | > return tr | |
244 | > |
|
244 | > | |
245 | > def uisetup(ui): |
|
245 | > def uisetup(ui): | |
246 | > wrapfunction(localrepo.localrepository, 'transaction', wrapper) |
|
246 | > wrapfunction(localrepo.localrepository, 'transaction', wrapper) | |
247 | > |
|
247 | > | |
248 | > cmdtable = {} |
|
248 | > cmdtable = {} | |
249 | > |
|
249 | > | |
250 | > EOF |
|
250 | > EOF | |
251 | $ rm -f "${extpath}c" |
|
251 | $ rm -f "${extpath}c" | |
252 | $ touch z |
|
252 | $ touch z | |
253 | $ hg ci -qAm z |
|
253 | $ hg ci -qAm z | |
254 | transaction abort! |
|
254 | transaction abort! | |
255 | rollback completed |
|
255 | rollback completed | |
256 | abort: forced transaction failure |
|
256 | abort: forced transaction failure | |
257 | [255] |
|
257 | [255] | |
258 | $ cat .hg/store/fncache |
|
258 | $ cat .hg/store/fncache | |
259 | data/y.i |
|
259 | data/y.i | |
260 |
|
260 | |||
261 | Aborted transactions can be recovered later |
|
261 | Aborted transactions can be recovered later | |
262 |
|
262 | |||
263 | $ cat > ../exceptionext.py <<EOF |
|
263 | $ cat > ../exceptionext.py <<EOF | |
264 | > import os |
|
264 | > import os | |
265 | > from mercurial import commands, util, transaction, localrepo |
|
265 | > from mercurial import commands, util, transaction, localrepo | |
266 | > from mercurial.extensions import wrapfunction |
|
266 | > from mercurial.extensions import wrapfunction | |
267 | > |
|
267 | > | |
268 | > def trwrapper(orig, self, *args, **kwargs): |
|
268 | > def trwrapper(orig, self, *args, **kwargs): | |
269 | > tr = orig(self, *args, **kwargs) |
|
269 | > tr = orig(self, *args, **kwargs) | |
270 | > def fail(tr): |
|
270 | > def fail(tr): | |
271 | > raise util.Abort("forced transaction failure") |
|
271 | > raise util.Abort("forced transaction failure") | |
272 | > # zzz prefix to ensure it sorted after store.write |
|
272 | > # zzz prefix to ensure it sorted after store.write | |
273 | > tr.addfinalize('zzz-forcefails', fail) |
|
273 | > tr.addfinalize('zzz-forcefails', fail) | |
274 | > return tr |
|
274 | > return tr | |
275 | > |
|
275 | > | |
276 | > def abortwrapper(orig, self, *args, **kwargs): |
|
276 | > def abortwrapper(orig, self, *args, **kwargs): | |
277 | > raise util.Abort("forced transaction failure") |
|
277 | > raise util.Abort("forced transaction failure") | |
278 | > |
|
278 | > | |
279 | > def uisetup(ui): |
|
279 | > def uisetup(ui): | |
280 | > wrapfunction(localrepo.localrepository, 'transaction', trwrapper) |
|
280 | > wrapfunction(localrepo.localrepository, 'transaction', trwrapper) | |
281 | > wrapfunction(transaction.transaction, '_abort', abortwrapper) |
|
281 | > wrapfunction(transaction.transaction, '_abort', abortwrapper) | |
282 | > |
|
282 | > | |
283 | > cmdtable = {} |
|
283 | > cmdtable = {} | |
284 | > |
|
284 | > | |
285 | > EOF |
|
285 | > EOF | |
286 | $ rm -f "${extpath}c" |
|
286 | $ rm -f "${extpath}c" | |
287 | $ hg up -q 1 |
|
287 | $ hg up -q 1 | |
288 | $ touch z |
|
288 | $ touch z | |
289 | $ hg ci -qAm z 2>/dev/null |
|
289 | $ hg ci -qAm z 2>/dev/null | |
290 | [255] |
|
290 | [255] | |
291 | $ cat .hg/store/fncache | sort |
|
291 | $ cat .hg/store/fncache | sort | |
292 | data/y.i |
|
292 | data/y.i | |
293 | data/z.i |
|
293 | data/z.i | |
294 | $ hg recover |
|
294 | $ hg recover | |
295 | rolling back interrupted transaction |
|
295 | rolling back interrupted transaction | |
296 | checking changesets |
|
296 | checking changesets | |
297 | checking manifests |
|
297 | checking manifests | |
298 | crosschecking files in changesets and manifests |
|
298 | crosschecking files in changesets and manifests | |
299 | checking files |
|
299 | checking files | |
300 | 1 files, 1 changesets, 1 total revisions |
|
300 | 1 files, 1 changesets, 1 total revisions | |
301 | $ cat .hg/store/fncache |
|
301 | $ cat .hg/store/fncache | |
302 | data/y.i |
|
302 | data/y.i | |
303 |
|
303 | |||
304 | $ cd .. |
|
304 | $ cd .. | |
305 |
|
305 | |||
306 | debugrebuildfncache does nothing unless repo has fncache requirement |
|
306 | debugrebuildfncache does nothing unless repo has fncache requirement | |
307 |
|
307 | |||
308 | $ hg --config format.usefncache=false init nofncache |
|
308 | $ hg --config format.usefncache=false init nofncache | |
309 | $ cd nofncache |
|
309 | $ cd nofncache | |
310 | $ hg debugrebuildfncache |
|
310 | $ hg debugrebuildfncache | |
311 | (not rebuilding fncache because repository does not support fncache |
|
311 | (not rebuilding fncache because repository does not support fncache) | |
312 |
|
312 | |||
313 | $ cd .. |
|
313 | $ cd .. | |
314 |
|
314 | |||
315 | debugrebuildfncache works on empty repository |
|
315 | debugrebuildfncache works on empty repository | |
316 |
|
316 | |||
317 | $ hg init empty |
|
317 | $ hg init empty | |
318 | $ cd empty |
|
318 | $ cd empty | |
319 | $ hg debugrebuildfncache |
|
319 | $ hg debugrebuildfncache | |
320 | fncache already up to date |
|
320 | fncache already up to date | |
321 | $ cd .. |
|
321 | $ cd .. | |
322 |
|
322 | |||
323 | debugrebuildfncache on an up to date repository no-ops |
|
323 | debugrebuildfncache on an up to date repository no-ops | |
324 |
|
324 | |||
325 | $ hg init repo |
|
325 | $ hg init repo | |
326 | $ cd repo |
|
326 | $ cd repo | |
327 | $ echo initial > foo |
|
327 | $ echo initial > foo | |
328 | $ echo initial > .bar |
|
328 | $ echo initial > .bar | |
329 | $ hg commit -A -m initial |
|
329 | $ hg commit -A -m initial | |
330 | adding .bar |
|
330 | adding .bar | |
331 | adding foo |
|
331 | adding foo | |
332 |
|
332 | |||
333 | $ cat .hg/store/fncache | sort |
|
333 | $ cat .hg/store/fncache | sort | |
334 | data/.bar.i |
|
334 | data/.bar.i | |
335 | data/foo.i |
|
335 | data/foo.i | |
336 |
|
336 | |||
337 | $ hg debugrebuildfncache |
|
337 | $ hg debugrebuildfncache | |
338 | fncache already up to date |
|
338 | fncache already up to date | |
339 |
|
339 | |||
340 | debugrebuildfncache restores deleted fncache file |
|
340 | debugrebuildfncache restores deleted fncache file | |
341 |
|
341 | |||
342 | $ rm -f .hg/store/fncache |
|
342 | $ rm -f .hg/store/fncache | |
343 | $ hg debugrebuildfncache |
|
343 | $ hg debugrebuildfncache | |
344 | adding data/.bar.i |
|
344 | adding data/.bar.i | |
345 | adding data/foo.i |
|
345 | adding data/foo.i | |
346 | 2 items added, 0 removed from fncache |
|
346 | 2 items added, 0 removed from fncache | |
347 |
|
347 | |||
348 | $ cat .hg/store/fncache | sort |
|
348 | $ cat .hg/store/fncache | sort | |
349 | data/.bar.i |
|
349 | data/.bar.i | |
350 | data/foo.i |
|
350 | data/foo.i | |
351 |
|
351 | |||
352 | Rebuild after rebuild should no-op |
|
352 | Rebuild after rebuild should no-op | |
353 |
|
353 | |||
354 | $ hg debugrebuildfncache |
|
354 | $ hg debugrebuildfncache | |
355 | fncache already up to date |
|
355 | fncache already up to date | |
356 |
|
356 | |||
357 | A single missing file should get restored, an extra file should be removed |
|
357 | A single missing file should get restored, an extra file should be removed | |
358 |
|
358 | |||
359 | $ cat > .hg/store/fncache << EOF |
|
359 | $ cat > .hg/store/fncache << EOF | |
360 | > data/foo.i |
|
360 | > data/foo.i | |
361 | > data/bad-entry.i |
|
361 | > data/bad-entry.i | |
362 | > EOF |
|
362 | > EOF | |
363 |
|
363 | |||
364 | $ hg debugrebuildfncache |
|
364 | $ hg debugrebuildfncache | |
365 | removing data/bad-entry.i |
|
365 | removing data/bad-entry.i | |
366 | adding data/.bar.i |
|
366 | adding data/.bar.i | |
367 | 1 items added, 1 removed from fncache |
|
367 | 1 items added, 1 removed from fncache | |
368 |
|
368 | |||
369 | $ cat .hg/store/fncache | sort |
|
369 | $ cat .hg/store/fncache | sort | |
370 | data/.bar.i |
|
370 | data/.bar.i | |
371 | data/foo.i |
|
371 | data/foo.i | |
372 |
|
372 | |||
373 | $ cd .. |
|
373 | $ cd .. | |
374 |
|
374 | |||
375 | Try a simple variation without dotencode to ensure fncache is ignorant of encoding |
|
375 | Try a simple variation without dotencode to ensure fncache is ignorant of encoding | |
376 |
|
376 | |||
377 | $ hg --config format.dotencode=false init nodotencode |
|
377 | $ hg --config format.dotencode=false init nodotencode | |
378 | $ cd nodotencode |
|
378 | $ cd nodotencode | |
379 | $ echo initial > foo |
|
379 | $ echo initial > foo | |
380 | $ echo initial > .bar |
|
380 | $ echo initial > .bar | |
381 | $ hg commit -A -m initial |
|
381 | $ hg commit -A -m initial | |
382 | adding .bar |
|
382 | adding .bar | |
383 | adding foo |
|
383 | adding foo | |
384 |
|
384 | |||
385 | $ cat .hg/store/fncache | sort |
|
385 | $ cat .hg/store/fncache | sort | |
386 | data/.bar.i |
|
386 | data/.bar.i | |
387 | data/foo.i |
|
387 | data/foo.i | |
388 |
|
388 | |||
389 | $ rm .hg/store/fncache |
|
389 | $ rm .hg/store/fncache | |
390 | $ hg debugrebuildfncache |
|
390 | $ hg debugrebuildfncache | |
391 | adding data/.bar.i |
|
391 | adding data/.bar.i | |
392 | adding data/foo.i |
|
392 | adding data/foo.i | |
393 | 2 items added, 0 removed from fncache |
|
393 | 2 items added, 0 removed from fncache | |
394 |
|
394 | |||
395 | $ cat .hg/store/fncache | sort |
|
395 | $ cat .hg/store/fncache | sort | |
396 | data/.bar.i |
|
396 | data/.bar.i | |
397 | data/foo.i |
|
397 | data/foo.i |
General Comments 0
You need to be logged in to leave comments.
Login now