Show More
@@ -2127,51 +2127,74 b' def remove(ui, repo, *pats, **opts):' | |||||
2127 |
|
2127 | |||
2128 | Schedule the indicated files for removal from the repository. |
|
2128 | Schedule the indicated files for removal from the repository. | |
2129 |
|
2129 | |||
2130 | This only removes files from the current branch, not from the |
|
2130 | This only removes files from the current branch, not from the entire | |
2131 | entire project history. If the files still exist in the working |
|
2131 | project history. -A can be used to remove only files that have already | |
2132 | directory, they will be deleted from it. If invoked with --after, |
|
2132 | been deleted, -f can be used to force deletion, and -Af can be used | |
2133 | files are marked as removed, but not actually unlinked unless --force |
|
2133 | to remove files from the next revision without deleting them. | |
2134 | is also given. Without exact file names, --after will only mark |
|
2134 | ||
2135 | files as removed if they are no longer in the working directory. |
|
2135 | The following table details the behavior of remove for different file | |
|
2136 | states (columns) and option combinations (rows). The file states are | |||
|
2137 | Added, Clean, Modified and Missing (as reported by hg status). The | |||
|
2138 | actions are Warn, Remove (from branch) and Delete (from disk). | |||
|
2139 | ||||
|
2140 | A C M ! | |||
|
2141 | none W RD W R | |||
|
2142 | -f R RD RD R | |||
|
2143 | -A W W W R | |||
|
2144 | -Af R R R R | |||
2136 |
|
2145 | |||
2137 | This command schedules the files to be removed at the next commit. |
|
2146 | This command schedules the files to be removed at the next commit. | |
2138 | To undo a remove before that, see hg revert. |
|
2147 | To undo a remove before that, see hg revert. | |
2139 |
|
||||
2140 | Modified files and added files are not removed by default. To |
|
|||
2141 | remove them, use the -f/--force option. |
|
|||
2142 | """ |
|
2148 | """ | |
2143 | if not opts['after'] and not pats: |
|
2149 | ||
|
2150 | after, force = opts.get('after'), opts.get('force') | |||
|
2151 | if not pats and not after: | |||
2144 | raise util.Abort(_('no files specified')) |
|
2152 | raise util.Abort(_('no files specified')) | |
|
2153 | ||||
2145 | files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
|
2154 | files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) | |
2146 | exact = dict.fromkeys(files) |
|
|||
2147 | mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5] |
|
2155 | mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5] | |
2148 | modified, added, removed, deleted, unknown = mardu |
|
2156 | modified, added, removed, deleted, unknown = mardu | |
|
2157 | ||||
2149 | remove, forget = [], [] |
|
2158 | remove, forget = [], [] | |
2150 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): |
|
2159 | for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): | |
|
2160 | ||||
2151 | reason = None |
|
2161 | reason = None | |
2152 |
if abs in |
|
2162 | if abs in removed or abs in unknown: | |
2153 | reason = _('is modified (use -f to force removal)') |
|
2163 | continue | |
|
2164 | ||||
|
2165 | # last column | |||
|
2166 | elif abs in deleted: | |||
|
2167 | remove.append(abs) | |||
|
2168 | ||||
|
2169 | # rest of the third row | |||
|
2170 | elif after and not force: | |||
|
2171 | reason = _('still exists (use -f to force removal)') | |||
|
2172 | ||||
|
2173 | # rest of the first column | |||
2154 | elif abs in added: |
|
2174 | elif abs in added: | |
2155 |
if |
|
2175 | if not force: | |
2156 | forget.append(abs) |
|
|||
2157 | continue |
|
|||
2158 | reason = _('has been marked for add (use -f to force removal)') |
|
2176 | reason = _('has been marked for add (use -f to force removal)') | |
2159 | exact = 1 # force the message |
|
2177 | else: | |
2160 | elif abs not in repo.dirstate: |
|
2178 | forget.append(abs) | |
2161 | reason = _('is not managed') |
|
2179 | ||
2162 | elif opts['after'] and not exact and abs not in deleted: |
|
2180 | # rest of the third column | |
2163 | continue |
|
2181 | elif abs in modified: | |
2164 | elif abs in removed: |
|
2182 | if not force: | |
2165 | continue |
|
2183 | reason = _('is modified (use -f to force removal)') | |
|
2184 | else: | |||
|
2185 | remove.append(abs) | |||
|
2186 | ||||
|
2187 | # rest of the second column | |||
|
2188 | elif not reason: | |||
|
2189 | remove.append(abs) | |||
|
2190 | ||||
2166 | if reason: |
|
2191 | if reason: | |
2167 | if exact: |
|
|||
2168 |
|
|
2192 | ui.warn(_('not removing %s: file %s\n') % (rel, reason)) | |
2169 | else: |
|
2193 | elif ui.verbose or not exact: | |
2170 | if ui.verbose or not exact: |
|
|||
2171 |
|
|
2194 | ui.status(_('removing %s\n') % rel) | |
2172 | remove.append(abs) |
|
2195 | ||
2173 | repo.forget(forget) |
|
2196 | repo.forget(forget) | |
2174 |
repo.remove(remove, unlink= |
|
2197 | repo.remove(remove, unlink=not after) | |
2175 |
|
2198 | |||
2176 | def rename(ui, repo, *pats, **opts): |
|
2199 | def rename(ui, repo, *pats, **opts): | |
2177 | """rename files; equivalent of copy + remove |
|
2200 | """rename files; equivalent of copy + remove | |
@@ -3125,8 +3148,9 b' table = {' | |||||
3125 | "recover": (recover, [], _('hg recover')), |
|
3148 | "recover": (recover, [], _('hg recover')), | |
3126 | "^remove|rm": |
|
3149 | "^remove|rm": | |
3127 | (remove, |
|
3150 | (remove, | |
3128 |
[('A', 'after', None, _('record |
|
3151 | [('A', 'after', None, _('record delete for missing files')), | |
3129 |
('f', 'force', None, |
|
3152 | ('f', 'force', None, | |
|
3153 | _('remove (and delete) file even if added or modified')), | |||
3130 | ] + walkopts, |
|
3154 | ] + walkopts, | |
3131 | _('hg remove [OPTION]... FILE...')), |
|
3155 | _('hg remove [OPTION]... FILE...')), | |
3132 | "rename|mv": |
|
3156 | "rename|mv": |
@@ -1,45 +1,109 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 |
|
2 | |||
|
3 | remove() { | |||
|
4 | hg rm $@ | |||
|
5 | hg st | |||
|
6 | ls -R | |||
|
7 | hg up -C | |||
|
8 | } | |||
|
9 | ||||
3 | hg init a |
|
10 | hg init a | |
4 | cd a |
|
11 | cd a | |
5 | echo a > foo |
|
12 | echo a > foo | |
6 | hg rm foo |
|
13 | ||
|
14 | echo % file not managed | |||
|
15 | remove foo | |||
|
16 | ||||
7 | hg add foo |
|
17 | hg add foo | |
8 |
hg commit -m |
|
18 | hg commit -m1 | |
9 | hg remove |
|
19 | ||
|
20 | # the table cases | |||
|
21 | ||||
|
22 | echo % 00 state added, options none | |||
|
23 | echo b > bar | |||
|
24 | hg add bar | |||
|
25 | remove bar | |||
|
26 | ||||
|
27 | echo % 01 state clean, options none | |||
|
28 | remove foo | |||
|
29 | ||||
|
30 | echo % 02 state modified, options none | |||
|
31 | echo b >> foo | |||
|
32 | remove foo | |||
|
33 | ||||
|
34 | echo % 03 state missing, options none | |||
10 | rm foo |
|
35 | rm foo | |
11 |
|
|
36 | remove foo | |
12 | hg revert --all |
|
37 | ||
|
38 | echo % 10 state added, options -f | |||
|
39 | echo b > bar | |||
|
40 | hg add bar | |||
|
41 | remove -f bar | |||
|
42 | rm bar | |||
|
43 | ||||
|
44 | echo % 11 state clean, options -f | |||
|
45 | remove -f foo | |||
|
46 | ||||
|
47 | echo % 12 state modified, options -f | |||
|
48 | echo b >> foo | |||
|
49 | remove -f foo | |||
|
50 | ||||
|
51 | echo % 13 state missing, options -f | |||
13 | rm foo |
|
52 | rm foo | |
14 |
|
|
53 | remove -f foo | |
15 | hg commit -m 2 -d "1000000 0" |
|
54 | ||
16 | hg export --nodates 0 |
|
55 | echo % 20 state added, options -A | |
17 | hg export --nodates 1 |
|
56 | echo b > bar | |
18 | hg log -p -r 0 |
|
57 | hg add bar | |
19 | hg log -p -r 1 |
|
58 | remove -A bar | |
20 |
|
59 | |||
21 | echo a > a |
|
60 | echo % 21 state clean, options -A | |
22 | hg add a |
|
61 | remove -A foo | |
23 | hg rm a |
|
62 | ||
24 | hg rm -f a |
|
63 | echo % 22 state modified, options -A | |
25 |
echo b > |
|
64 | echo b >> foo | |
26 | mkdir c |
|
65 | remove -A foo | |
27 | echo d > c/d |
|
66 | ||
28 | hg ci -A -m 3 -d "1000001 0" |
|
67 | echo % 23 state missing, options -A | |
29 | echo c >> b |
|
68 | rm foo | |
30 | hg rm b |
|
69 | remove -A foo | |
31 | hg rm -f b |
|
70 | ||
32 | hg rm -A c/d |
|
71 | echo % 30 state added, options -Af | |
33 | hg st |
|
72 | echo b > bar | |
34 | cat c/d |
|
73 | hg add bar | |
35 | hg revert c |
|
74 | remove -Af bar | |
36 | hg rm -A |
|
75 | rm bar | |
37 | hg st |
|
76 | ||
38 | hg rm -A c |
|
77 | echo % 31 state clean, options -Af | |
39 | hg st |
|
78 | remove -Af foo | |
40 | rm c/d |
|
79 | ||
41 | hg rm -A |
|
80 | echo % 32 state modified, options -Af | |
42 | hg st |
|
81 | echo b >> foo | |
|
82 | remove -Af foo | |||
43 |
|
83 | |||
44 | cd .. |
|
84 | echo % 33 state missing, options -Af | |
45 | hg clone a b |
|
85 | rm foo | |
|
86 | remove -Af foo | |||
|
87 | ||||
|
88 | # test some directory stuff | |||
|
89 | ||||
|
90 | mkdir test | |||
|
91 | echo a > test/foo | |||
|
92 | echo b > test/bar | |||
|
93 | hg ci -Am2 | |||
|
94 | ||||
|
95 | echo % dir, options none | |||
|
96 | rm test/bar | |||
|
97 | remove test | |||
|
98 | ||||
|
99 | echo % dir, options -f | |||
|
100 | rm test/bar | |||
|
101 | remove -f test | |||
|
102 | ||||
|
103 | echo % dir, options -A | |||
|
104 | rm test/bar | |||
|
105 | remove -A test | |||
|
106 | ||||
|
107 | echo % dir, options -Af | |||
|
108 | rm test/bar | |||
|
109 | remove -Af test |
@@ -1,67 +1,127 b'' | |||||
1 |
|
|
1 | % file not managed | |
2 | abort: no files specified |
|
2 | ? foo | |
3 | undeleting foo |
|
3 | .: | |
4 | removing foo |
|
4 | foo | |
5 | # HG changeset patch |
|
5 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
6 | # User test |
|
6 | % 00 state added, options none | |
7 | # Date 1000000 0 |
|
7 | not removing bar: file has been marked for add (use -f to force removal) | |
8 | # Node ID 8ba83d44753d6259db5ce6524974dd1174e90f47 |
|
8 | A bar | |
9 | # Parent 0000000000000000000000000000000000000000 |
|
9 | .: | |
10 | 1 |
|
10 | bar | |
11 |
|
11 | foo | ||
12 | diff -r 000000000000 -r 8ba83d44753d foo |
|
12 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
13 | --- /dev/null |
|
13 | % 01 state clean, options none | |
14 | +++ b/foo |
|
14 | R foo | |
15 | @@ -0,0 +1,1 @@ |
|
15 | .: | |
16 | +a |
|
16 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
17 | # HG changeset patch |
|
17 | % 02 state modified, options none | |
18 | # User test |
|
18 | not removing foo: file is modified (use -f to force removal) | |
19 | # Date 1000000 0 |
|
19 | M foo | |
20 | # Node ID a1fce69c50d97881c5c014ab23f580f720c78678 |
|
20 | .: | |
21 | # Parent 8ba83d44753d6259db5ce6524974dd1174e90f47 |
|
21 | foo | |
22 | 2 |
|
22 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
23 |
|
23 | % 03 state missing, options none | ||
24 | diff -r 8ba83d44753d -r a1fce69c50d9 foo |
|
24 | R foo | |
25 | --- a/foo |
|
25 | .: | |
26 | +++ /dev/null |
|
26 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
27 | @@ -1,1 +0,0 @@ |
|
27 | % 10 state added, options -f | |
28 | -a |
|
28 | ? bar | |
29 | changeset: 0:8ba83d44753d |
|
29 | .: | |
30 | user: test |
|
30 | bar | |
31 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
31 | foo | |
32 | summary: 1 |
|
32 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
33 | % 11 state clean, options -f | |||
|
34 | R foo | |||
|
35 | .: | |||
|
36 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
37 | % 12 state modified, options -f | |||
|
38 | R foo | |||
|
39 | .: | |||
|
40 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
41 | % 13 state missing, options -f | |||
|
42 | R foo | |||
|
43 | .: | |||
|
44 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
45 | % 20 state added, options -A | |||
|
46 | not removing bar: file still exists (use -f to force removal) | |||
|
47 | A bar | |||
|
48 | .: | |||
|
49 | bar | |||
|
50 | foo | |||
|
51 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
52 | % 21 state clean, options -A | |||
|
53 | not removing foo: file still exists (use -f to force removal) | |||
|
54 | .: | |||
|
55 | foo | |||
|
56 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
57 | % 22 state modified, options -A | |||
|
58 | not removing foo: file still exists (use -f to force removal) | |||
|
59 | M foo | |||
|
60 | .: | |||
|
61 | foo | |||
|
62 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
63 | % 23 state missing, options -A | |||
|
64 | R foo | |||
|
65 | .: | |||
|
66 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
67 | % 30 state added, options -Af | |||
|
68 | ? bar | |||
|
69 | .: | |||
|
70 | bar | |||
|
71 | foo | |||
|
72 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
73 | % 31 state clean, options -Af | |||
|
74 | R foo | |||
|
75 | .: | |||
|
76 | foo | |||
|
77 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
78 | % 32 state modified, options -Af | |||
|
79 | R foo | |||
|
80 | .: | |||
|
81 | foo | |||
|
82 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
83 | % 33 state missing, options -Af | |||
|
84 | R foo | |||
|
85 | .: | |||
|
86 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
87 | adding test/bar | |||
|
88 | adding test/foo | |||
|
89 | % dir, options none | |||
|
90 | removing test/foo | |||
|
91 | removing test/bar | |||
|
92 | R test/bar | |||
|
93 | R test/foo | |||
|
94 | .: | |||
|
95 | foo | |||
|
96 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
97 | % dir, options -f | |||
|
98 | removing test/foo | |||
|
99 | removing test/bar | |||
|
100 | R test/bar | |||
|
101 | R test/foo | |||
|
102 | .: | |||
|
103 | foo | |||
|
104 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
105 | % dir, options -A | |||
|
106 | not removing test/foo: file still exists (use -f to force removal) | |||
|
107 | removing test/bar | |||
|
108 | R test/bar | |||
|
109 | .: | |||
|
110 | foo | |||
|
111 | test | |||
33 |
|
112 | |||
34 | diff -r 000000000000 -r 8ba83d44753d foo |
|
113 | ./test: | |
35 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
114 | foo | |
36 | +++ b/foo Mon Jan 12 13:46:40 1970 +0000 |
|
115 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
37 | @@ -0,0 +1,1 @@ |
|
116 | % dir, options -Af | |
38 | +a |
|
117 | removing test/foo | |
39 |
|
118 | removing test/bar | ||
40 | changeset: 1:a1fce69c50d9 |
|
119 | R test/bar | |
41 | tag: tip |
|
120 | R test/foo | |
42 | user: test |
|
121 | .: | |
43 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
122 | foo | |
44 | summary: 2 |
|
123 | test | |
45 |
|
124 | |||
46 | diff -r 8ba83d44753d -r a1fce69c50d9 foo |
|
125 | ./test: | |
47 | --- a/foo Mon Jan 12 13:46:40 1970 +0000 |
|
126 | foo | |
48 | +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
127 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
49 | @@ -1,1 +0,0 @@ |
|
|||
50 | -a |
|
|||
51 |
|
||||
52 | not removing a: file has been marked for add (use -f to force removal) |
|
|||
53 | adding a |
|
|||
54 | adding b |
|
|||
55 | adding c/d |
|
|||
56 | not removing b: file is modified (use -f to force removal) |
|
|||
57 | R b |
|
|||
58 | R c/d |
|
|||
59 | d |
|
|||
60 | undeleting c/d |
|
|||
61 | R b |
|
|||
62 | R b |
|
|||
63 | removing c/d |
|
|||
64 | R b |
|
|||
65 | R c/d |
|
|||
66 | updating working directory |
|
|||
67 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
General Comments 0
You need to be logged in to leave comments.
Login now