##// END OF EJS Templates
remove: rewrite to be ~400x faster, bit more friendly...
Vadim Gelfer -
r2309:b2f37c70 default
parent child Browse files
Show More
@@ -2189,34 +2189,42 b' def remove(ui, repo, *pats, **opts):'
2189 entire project history. If the files still exist in the working
2189 entire project history. If the files still exist in the working
2190 directory, they will be deleted from it. If invoked with --after,
2190 directory, they will be deleted from it. If invoked with --after,
2191 files that have been manually deleted are marked as removed.
2191 files that have been manually deleted are marked as removed.
2192
2193 Modified files and added files are not removed by default. To
2194 remove them, use the -f/--force option.
2192 """
2195 """
2193 names = []
2196 names = []
2194 if not opts['after'] and not pats:
2197 if not opts['after'] and not pats:
2195 raise util.Abort(_('no files specified'))
2198 raise util.Abort(_('no files specified'))
2196 def okaytoremove(abs, rel, exact):
2199 files, matchfn, anypats = matchpats(repo, pats, opts)
2197 modified, added, removed, deleted, unknown = repo.changes(files=[abs])
2200 exact = dict.fromkeys(files)
2201 mardu = map(dict.fromkeys, repo.changes(files=files, match=matchfn))
2202 modified, added, removed, deleted, unknown = mardu
2203 remove, forget = [], []
2204 for src, abs, rel, exact in walk(repo, pats, opts):
2198 reason = None
2205 reason = None
2199 if not deleted and opts['after']:
2206 if abs not in deleted and opts['after']:
2200 reason = _('is still present')
2207 reason = _('is still present')
2201 elif modified and not opts['force']:
2208 elif abs in modified and not opts['force']:
2202 reason = _('is modified')
2209 reason = _('is modified (use -f to force removal)')
2203 elif added:
2210 elif abs in added:
2204 reason = _('has been marked for add')
2211 if opts['force']:
2205 elif unknown:
2212 forget.append(abs)
2213 continue
2214 reason = _('has been marked for add (use -f to force removal)')
2215 elif abs in unknown:
2206 reason = _('is not managed')
2216 reason = _('is not managed')
2207 elif removed:
2217 elif abs in removed:
2208 return False
2218 continue
2209 if reason:
2219 if reason:
2210 if exact:
2220 if exact:
2211 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
2221 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
2212 else:
2222 else:
2213 return True
2214 for src, abs, rel, exact in walk(repo, pats, opts):
2215 if okaytoremove(abs, rel, exact):
2216 if ui.verbose or not exact:
2223 if ui.verbose or not exact:
2217 ui.status(_('removing %s\n') % rel)
2224 ui.status(_('removing %s\n') % rel)
2218 names.append(abs)
2225 remove.append(abs)
2219 repo.remove(names, unlink=not opts['after'])
2226 repo.forget(forget)
2227 repo.remove(remove, unlink=not opts['after'])
2220
2228
2221 def rename(ui, repo, *pats, **opts):
2229 def rename(ui, repo, *pats, **opts):
2222 """rename files; equivalent of copy + remove
2230 """rename files; equivalent of copy + remove
@@ -3,6 +3,7 b''
3 hg init a
3 hg init a
4 cd a
4 cd a
5 echo a > foo
5 echo a > foo
6 hg rm foo
6 hg add foo
7 hg add foo
7 hg commit -m 1 -d "1000000 0"
8 hg commit -m 1 -d "1000000 0"
8 hg remove
9 hg remove
@@ -17,5 +18,15 b' hg export 1'
17 hg log -p -r 0
18 hg log -p -r 0
18 hg log -p -r 1
19 hg log -p -r 1
19
20
21 echo a > a
22 hg add a
23 hg rm a
24 hg rm -f a
25 echo b > b
26 hg ci -A -m 3 -d "1000001 0"
27 echo c >> b
28 hg rm b
29 hg rm -f b
30
20 cd ..
31 cd ..
21 hg clone a b
32 hg clone a b
@@ -1,3 +1,4 b''
1 not removing foo: file is not managed
1 abort: no files specified
2 abort: no files specified
2 undeleting foo
3 undeleting foo
3 removing foo
4 removing foo
@@ -50,4 +51,8 b' diff -r 8ba83d44753d -r a1fce69c50d9 foo'
50 -a
51 -a
51
52
52
53
53 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
54 not removing a: file has been marked for add (use -f to force removal)
55 adding a
56 adding b
57 not removing b: file is modified (use -f to force removal)
58 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