Show More
@@ -1,65 +1,65 b'' | |||
|
1 | 1 | # dirstatenonnormalcheck.py - extension to check the consistency of the |
|
2 | 2 | # dirstate's non-normal map |
|
3 | 3 | # |
|
4 | 4 | # For most operations on dirstate, this extensions checks that the nonnormalset |
|
5 | 5 | # contains the right entries. |
|
6 | 6 | # It compares the nonnormal file to a nonnormalset built from the map of all |
|
7 | 7 | # the files in the dirstate to check that they contain the same files. |
|
8 | 8 | |
|
9 | 9 | from __future__ import absolute_import |
|
10 | 10 | |
|
11 | 11 | from mercurial import ( |
|
12 | 12 | dirstate, |
|
13 | 13 | extensions, |
|
14 | 14 | ) |
|
15 | 15 | |
|
16 | 16 | |
|
17 | 17 | def nonnormalentries(dmap): |
|
18 | 18 | """Compute nonnormal entries from dirstate's dmap""" |
|
19 | 19 | res = set() |
|
20 | 20 | for f, e in dmap.iteritems(): |
|
21 |
if e |
|
|
21 | if e.state != b'n' or e.mtime == -1: | |
|
22 | 22 | res.add(f) |
|
23 | 23 | return res |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | def checkconsistency(ui, orig, dmap, _nonnormalset, label): |
|
27 | 27 | """Compute nonnormalset from dmap, check that it matches _nonnormalset""" |
|
28 | 28 | nonnormalcomputedmap = nonnormalentries(dmap) |
|
29 | 29 | if _nonnormalset != nonnormalcomputedmap: |
|
30 | 30 | ui.develwarn(b"%s call to %s\n" % (label, orig), config=b'dirstate') |
|
31 | 31 | ui.develwarn(b"inconsistency in nonnormalset\n", config=b'dirstate') |
|
32 | 32 | ui.develwarn(b"[nonnormalset] %s\n" % _nonnormalset, config=b'dirstate') |
|
33 | 33 | ui.develwarn(b"[map] %s\n" % nonnormalcomputedmap, config=b'dirstate') |
|
34 | 34 | |
|
35 | 35 | |
|
36 | 36 | def _checkdirstate(orig, self, arg): |
|
37 | 37 | """Check nonnormal set consistency before and after the call to orig""" |
|
38 | 38 | checkconsistency( |
|
39 | 39 | self._ui, orig, self._map, self._map.nonnormalset, b"before" |
|
40 | 40 | ) |
|
41 | 41 | r = orig(self, arg) |
|
42 | 42 | checkconsistency( |
|
43 | 43 | self._ui, orig, self._map, self._map.nonnormalset, b"after" |
|
44 | 44 | ) |
|
45 | 45 | return r |
|
46 | 46 | |
|
47 | 47 | |
|
48 | 48 | def extsetup(ui): |
|
49 | 49 | """Wrap functions modifying dirstate to check nonnormalset consistency""" |
|
50 | 50 | dirstatecl = dirstate.dirstate |
|
51 | 51 | devel = ui.configbool(b'devel', b'all-warnings') |
|
52 | 52 | paranoid = ui.configbool(b'experimental', b'nonnormalparanoidcheck') |
|
53 | 53 | if devel: |
|
54 | 54 | extensions.wrapfunction(dirstatecl, '_writedirstate', _checkdirstate) |
|
55 | 55 | if paranoid: |
|
56 | 56 | # We don't do all these checks when paranoid is disable as it would |
|
57 | 57 | # make the extension run very slowly on large repos |
|
58 | 58 | extensions.wrapfunction(dirstatecl, 'normallookup', _checkdirstate) |
|
59 | 59 | extensions.wrapfunction(dirstatecl, 'otherparent', _checkdirstate) |
|
60 | 60 | extensions.wrapfunction(dirstatecl, 'normal', _checkdirstate) |
|
61 | 61 | extensions.wrapfunction(dirstatecl, 'write', _checkdirstate) |
|
62 | 62 | extensions.wrapfunction(dirstatecl, 'add', _checkdirstate) |
|
63 | 63 | extensions.wrapfunction(dirstatecl, 'remove', _checkdirstate) |
|
64 | 64 | extensions.wrapfunction(dirstatecl, 'merge', _checkdirstate) |
|
65 | 65 | extensions.wrapfunction(dirstatecl, 'drop', _checkdirstate) |
General Comments 0
You need to be logged in to leave comments.
Login now