##// END OF EJS Templates
tests: remove potential mtime ambiguity in a dirstate test...
marmoute -
r49223:eea70e35 default
parent child Browse files
Show More
@@ -1,132 +1,134 b''
1 1
2 2 $ cat > adddrop.py <<EOF
3 3 > from mercurial import registrar
4 4 > cmdtable = {}
5 5 > command = registrar.command(cmdtable)
6 6 > @command(b'debugadddrop',
7 7 > [(b'', b'drop', False, b'drop file from dirstate', b'FILE'),
8 8 > (b'', b'normal-lookup', False, b'add file to dirstate', b'FILE')],
9 9 > b'hg debugadddrop')
10 10 > def debugadddrop(ui, repo, *pats, **opts):
11 11 > '''Add or drop unnamed arguments to or from the dirstate'''
12 12 > drop = opts.get('drop')
13 13 > nl = opts.get('normal_lookup')
14 14 > if nl and drop:
15 15 > raise error.Abort('drop and normal-lookup are mutually exclusive')
16 16 > wlock = repo.wlock()
17 17 > try:
18 18 > for file in pats:
19 19 > if opts.get('normal_lookup'):
20 20 > with repo.dirstate.parentchange():
21 21 > repo.dirstate.update_file(
22 22 > file,
23 23 > p1_tracked=True,
24 24 > wc_tracked=True,
25 25 > possibly_dirty=True,
26 26 > )
27 27 > else:
28 28 > repo.dirstate._map.reset_state(file)
29 29 > repo.dirstate._dirty = True
30 30 >
31 31 > repo.dirstate.write(repo.currenttransaction())
32 32 > finally:
33 33 > wlock.release()
34 34 > EOF
35 35
36 36 $ echo "[extensions]" >> $HGRCPATH
37 37 $ echo "debugadddrop=`pwd`/adddrop.py" >> $HGRCPATH
38 38
39 39 basic test for hg debugrebuildstate
40 40
41 41 $ hg init repo
42 42 $ cd repo
43 43
44 44 $ touch foo bar
45 45 $ hg ci -Am 'add foo bar'
46 46 adding bar
47 47 adding foo
48 48
49 49 $ touch baz
50 50 $ hg add baz
51 51 $ hg rm bar
52 52
53 53 $ hg debugrebuildstate
54 54
55 55 state dump after
56 56
57 57 $ hg debugstate --no-dates | sort
58 58 n 0 -1 unset bar
59 59 n 0 -1 unset foo
60 60
61 61 $ hg debugadddrop --normal-lookup file1 file2
62 62 $ hg debugadddrop --drop bar
63 63 $ hg debugadddrop --drop
64 64 $ hg debugstate --no-dates
65 65 n 0 -1 unset file1
66 66 n 0 -1 unset file2
67 67 n 0 -1 unset foo
68 68 $ hg debugrebuildstate
69 69
70 70 status
71 71
72 72 $ hg st -A
73 73 ! bar
74 74 ? baz
75 75 C foo
76 76
77 77 Test debugdirstate --minimal where a file is not in parent manifest
78 78 but in the dirstate
79 79 $ touch foo bar qux
80 80 $ hg add qux
81 81 $ hg remove bar
82 $ sleep 1 # remove potential ambiguity in mtime
82 83 $ hg status -A
83 84 A qux
84 85 R bar
85 86 ? baz
86 87 C foo
87 88 $ hg debugadddrop --normal-lookup baz
88 89 $ hg debugdirstate --no-dates
89 90 r 0 0 * bar (glob)
90 91 n 0 -1 * baz (glob)
91 92 n 644 0 * foo (glob)
92 93 a 0 -1 * qux (glob)
93 94 $ hg debugrebuilddirstate --minimal
94 95 $ hg debugdirstate --no-dates
95 96 r 0 0 * bar (glob)
96 97 n 644 0 * foo (glob)
97 98 a 0 -1 * qux (glob)
98 99 $ hg status -A
99 100 A qux
100 101 R bar
101 102 ? baz
102 103 C foo
103 104
104 105 Test debugdirstate --minimal where file is in the parent manifest but not the
105 106 dirstate
106 107 $ hg manifest
107 108 bar
108 109 foo
110 $ sleep 1 # remove potential ambiguity in mtime
109 111 $ hg status -A
110 112 A qux
111 113 R bar
112 114 ? baz
113 115 C foo
114 116 $ hg debugdirstate --no-dates
115 117 r 0 0 * bar (glob)
116 118 n 644 0 * foo (glob)
117 119 a 0 -1 * qux (glob)
118 120 $ hg debugadddrop --drop foo
119 121 $ hg debugdirstate --no-dates
120 122 r 0 0 * bar (glob)
121 123 a 0 -1 * qux (glob)
122 124 $ hg debugrebuilddirstate --minimal
123 125 $ hg debugdirstate --no-dates
124 126 r 0 0 * bar (glob)
125 127 n 0 -1 * foo (glob)
126 128 a 0 -1 * qux (glob)
127 129 $ hg status -A
128 130 A qux
129 131 R bar
130 132 ? baz
131 133 C foo
132 134
General Comments 0
You need to be logged in to leave comments. Login now