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