Show More
@@ -1,30 +1,70 b'' | |||||
|
1 | ||||
|
2 | $ cat > adddrop.py <<EOF | |||
|
3 | > from mercurial import cmdutil | |||
|
4 | > cmdtable = {} | |||
|
5 | > command = cmdutil.command(cmdtable) | |||
|
6 | > @command('debugadddrop', | |||
|
7 | > [('', 'drop', False, 'drop file from dirstate', 'FILE'), | |||
|
8 | > ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')], | |||
|
9 | > 'hg debugadddrop') | |||
|
10 | > def debugadddrop(ui, repo, *pats, **opts): | |||
|
11 | > '''Add or drop unnamed arguments to or from the dirstate''' | |||
|
12 | > drop = opts.get('drop') | |||
|
13 | > nl = opts.get('normal_lookup') | |||
|
14 | > if nl and drop: | |||
|
15 | > raise error.Abort('drop and normal-lookup are mutually exclusive') | |||
|
16 | > wlock = repo.wlock() | |||
|
17 | > try: | |||
|
18 | > for file in pats: | |||
|
19 | > if opts.get('normal_lookup'): | |||
|
20 | > repo.dirstate.normallookup(file) | |||
|
21 | > else: | |||
|
22 | > repo.dirstate.drop(file) | |||
|
23 | > | |||
|
24 | > repo.dirstate.write(repo.currenttransaction()) | |||
|
25 | > finally: | |||
|
26 | > wlock.release() | |||
|
27 | > EOF | |||
|
28 | ||||
|
29 | $ echo "[extensions]" >> $HGRCPATH | |||
|
30 | $ echo "debugadddrop=`pwd`/adddrop.py" >> $HGRCPATH | |||
|
31 | ||||
1 | basic test for hg debugrebuildstate |
|
32 | basic test for hg debugrebuildstate | |
2 |
|
33 | |||
3 | $ hg init repo |
|
34 | $ hg init repo | |
4 | $ cd repo |
|
35 | $ cd repo | |
5 |
|
36 | |||
6 | $ touch foo bar |
|
37 | $ touch foo bar | |
7 | $ hg ci -Am 'add foo bar' |
|
38 | $ hg ci -Am 'add foo bar' | |
8 | adding bar |
|
39 | adding bar | |
9 | adding foo |
|
40 | adding foo | |
10 |
|
41 | |||
11 | $ touch baz |
|
42 | $ touch baz | |
12 | $ hg add baz |
|
43 | $ hg add baz | |
13 | $ hg rm bar |
|
44 | $ hg rm bar | |
14 |
|
45 | |||
15 | $ hg debugrebuildstate |
|
46 | $ hg debugrebuildstate | |
16 |
|
47 | |||
17 | state dump after |
|
48 | state dump after | |
18 |
|
49 | |||
19 | $ hg debugstate --nodates | sort |
|
50 | $ hg debugstate --nodates | sort | |
20 | n 644 -1 set bar |
|
51 | n 644 -1 set bar | |
21 | n 644 -1 set foo |
|
52 | n 644 -1 set foo | |
22 |
|
53 | |||
|
54 | $ hg debugadddrop --normal-lookup file1 file2 | |||
|
55 | $ hg debugadddrop --drop bar | |||
|
56 | $ hg debugadddrop --drop | |||
|
57 | $ hg debugstate --nodates | |||
|
58 | n 0 -1 unset file1 | |||
|
59 | n 0 -1 unset file2 | |||
|
60 | n 644 -1 set foo | |||
|
61 | $ hg debugrebuildstate | |||
|
62 | ||||
23 | status |
|
63 | status | |
24 |
|
64 | |||
25 | $ hg st -A |
|
65 | $ hg st -A | |
26 | ! bar |
|
66 | ! bar | |
27 | ? baz |
|
67 | ? baz | |
28 | C foo |
|
68 | C foo | |
29 |
|
69 | |||
30 | $ cd .. |
|
70 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now