Show More
@@ -1,70 +1,125 b'' | |||
|
1 | 1 | |
|
2 | 2 | $ cat > adddrop.py <<EOF |
|
3 | 3 | > from mercurial import cmdutil |
|
4 | 4 | > cmdtable = {} |
|
5 | 5 | > command = cmdutil.command(cmdtable) |
|
6 | 6 | > @command('debugadddrop', |
|
7 | 7 | > [('', 'drop', False, 'drop file from dirstate', 'FILE'), |
|
8 | 8 | > ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')], |
|
9 | 9 | > '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 644 -1 set bar |
|
52 | 52 | n 644 -1 set 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 644 -1 set 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 | $ cd .. | |
|
70 | Test debugdirstate --minimal where a file is not in parent manifest | |
|
71 | but in the dirstate | |
|
72 | $ touch foo bar qux | |
|
73 | $ hg add qux | |
|
74 | $ hg remove bar | |
|
75 | $ hg status -A | |
|
76 | A qux | |
|
77 | R bar | |
|
78 | ? baz | |
|
79 | C foo | |
|
80 | $ hg debugadddrop --normal-lookup baz | |
|
81 | $ hg debugdirstate --nodates | |
|
82 | r 0 0 * bar (glob) | |
|
83 | n 0 -1 * baz (glob) | |
|
84 | n 644 0 * foo (glob) | |
|
85 | a 0 -1 * qux (glob) | |
|
86 | $ hg debugrebuilddirstate --minimal | |
|
87 | $ hg debugdirstate --nodates | |
|
88 | r 0 0 * bar (glob) | |
|
89 | n 644 0 * foo (glob) | |
|
90 | a 0 -1 * qux (glob) | |
|
91 | $ hg status -A | |
|
92 | A qux | |
|
93 | R bar | |
|
94 | ? baz | |
|
95 | C foo | |
|
96 | ||
|
97 | Test debugdirstate --minimal where file is in the parent manifest but not the | |
|
98 | dirstate | |
|
99 | $ hg manifest | |
|
100 | bar | |
|
101 | foo | |
|
102 | $ hg status -A | |
|
103 | A qux | |
|
104 | R bar | |
|
105 | ? baz | |
|
106 | C foo | |
|
107 | $ hg debugdirstate --nodates | |
|
108 | r 0 0 * bar (glob) | |
|
109 | n 644 0 * foo (glob) | |
|
110 | a 0 -1 * qux (glob) | |
|
111 | $ hg debugadddrop --drop foo | |
|
112 | $ hg debugdirstate --nodates | |
|
113 | r 0 0 * bar (glob) | |
|
114 | a 0 -1 * qux (glob) | |
|
115 | $ hg debugrebuilddirstate --minimal | |
|
116 | $ hg debugdirstate --nodates | |
|
117 | r 0 0 * bar (glob) | |
|
118 | n 0 -1 * foo (glob) | |
|
119 | a 0 -1 * qux (glob) | |
|
120 | $ hg status -A | |
|
121 | A qux | |
|
122 | R bar | |
|
123 | ? baz | |
|
124 | C foo | |
|
125 |
General Comments 0
You need to be logged in to leave comments.
Login now