Show More
@@ -1,125 +1,125 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 | > [('', 'drop', False, 'drop file from dirstate', 'FILE'), | |
|
8 | > ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')], | |
|
9 | > 'hg debugadddrop') | |
|
7 | > [(b'', b'drop', False, b'drop file from dirstate', b'FILE'), | |
|
8 | > (b'', b'normal-lookup', False, b'add file to dirstate', b'FILE')], | |
|
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 | > repo.dirstate.normallookup(file) |
|
21 | 21 | > else: |
|
22 | 22 | > repo.dirstate.drop(file) |
|
23 | 23 | > |
|
24 | 24 | > repo.dirstate.write(repo.currenttransaction()) |
|
25 | 25 | > finally: |
|
26 | 26 | > wlock.release() |
|
27 | 27 | > EOF |
|
28 | 28 | |
|
29 | 29 | $ echo "[extensions]" >> $HGRCPATH |
|
30 | 30 | $ echo "debugadddrop=`pwd`/adddrop.py" >> $HGRCPATH |
|
31 | 31 | |
|
32 | 32 | basic test for hg debugrebuildstate |
|
33 | 33 | |
|
34 | 34 | $ hg init repo |
|
35 | 35 | $ cd repo |
|
36 | 36 | |
|
37 | 37 | $ touch foo bar |
|
38 | 38 | $ hg ci -Am 'add foo bar' |
|
39 | 39 | adding bar |
|
40 | 40 | adding foo |
|
41 | 41 | |
|
42 | 42 | $ touch baz |
|
43 | 43 | $ hg add baz |
|
44 | 44 | $ hg rm bar |
|
45 | 45 | |
|
46 | 46 | $ hg debugrebuildstate |
|
47 | 47 | |
|
48 | 48 | state dump after |
|
49 | 49 | |
|
50 | 50 | $ hg debugstate --nodates | sort |
|
51 | 51 | n 0 -1 unset bar |
|
52 | 52 | n 0 -1 unset foo |
|
53 | 53 | |
|
54 | 54 | $ hg debugadddrop --normal-lookup file1 file2 |
|
55 | 55 | $ hg debugadddrop --drop bar |
|
56 | 56 | $ hg debugadddrop --drop |
|
57 | 57 | $ hg debugstate --nodates |
|
58 | 58 | n 0 -1 unset file1 |
|
59 | 59 | n 0 -1 unset file2 |
|
60 | 60 | n 0 -1 unset foo |
|
61 | 61 | $ hg debugrebuildstate |
|
62 | 62 | |
|
63 | 63 | status |
|
64 | 64 | |
|
65 | 65 | $ hg st -A |
|
66 | 66 | ! bar |
|
67 | 67 | ? baz |
|
68 | 68 | C foo |
|
69 | 69 | |
|
70 | 70 | Test debugdirstate --minimal where a file is not in parent manifest |
|
71 | 71 | but in the dirstate |
|
72 | 72 | $ touch foo bar qux |
|
73 | 73 | $ hg add qux |
|
74 | 74 | $ hg remove bar |
|
75 | 75 | $ hg status -A |
|
76 | 76 | A qux |
|
77 | 77 | R bar |
|
78 | 78 | ? baz |
|
79 | 79 | C foo |
|
80 | 80 | $ hg debugadddrop --normal-lookup baz |
|
81 | 81 | $ hg debugdirstate --nodates |
|
82 | 82 | r 0 0 * bar (glob) |
|
83 | 83 | n 0 -1 * baz (glob) |
|
84 | 84 | n 644 0 * foo (glob) |
|
85 | 85 | a 0 -1 * qux (glob) |
|
86 | 86 | $ hg debugrebuilddirstate --minimal |
|
87 | 87 | $ hg debugdirstate --nodates |
|
88 | 88 | r 0 0 * bar (glob) |
|
89 | 89 | n 644 0 * foo (glob) |
|
90 | 90 | a 0 -1 * qux (glob) |
|
91 | 91 | $ hg status -A |
|
92 | 92 | A qux |
|
93 | 93 | R bar |
|
94 | 94 | ? baz |
|
95 | 95 | C foo |
|
96 | 96 | |
|
97 | 97 | Test debugdirstate --minimal where file is in the parent manifest but not the |
|
98 | 98 | dirstate |
|
99 | 99 | $ hg manifest |
|
100 | 100 | bar |
|
101 | 101 | foo |
|
102 | 102 | $ hg status -A |
|
103 | 103 | A qux |
|
104 | 104 | R bar |
|
105 | 105 | ? baz |
|
106 | 106 | C foo |
|
107 | 107 | $ hg debugdirstate --nodates |
|
108 | 108 | r 0 0 * bar (glob) |
|
109 | 109 | n 644 0 * foo (glob) |
|
110 | 110 | a 0 -1 * qux (glob) |
|
111 | 111 | $ hg debugadddrop --drop foo |
|
112 | 112 | $ hg debugdirstate --nodates |
|
113 | 113 | r 0 0 * bar (glob) |
|
114 | 114 | a 0 -1 * qux (glob) |
|
115 | 115 | $ hg debugrebuilddirstate --minimal |
|
116 | 116 | $ hg debugdirstate --nodates |
|
117 | 117 | r 0 0 * bar (glob) |
|
118 | 118 | n 0 -1 * foo (glob) |
|
119 | 119 | a 0 -1 * qux (glob) |
|
120 | 120 | $ hg status -A |
|
121 | 121 | A qux |
|
122 | 122 | R bar |
|
123 | 123 | ? baz |
|
124 | 124 | C foo |
|
125 | 125 |
General Comments 0
You need to be logged in to leave comments.
Login now