comparison mercurial/commands.py @ 1189:4cbcc54695b2

Make removal check more complete and informative.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 01 Sep 2005 08:01:10 -0700
parents b3ceb2d470fc
children 737f9b90c571
comparison
equal deleted inserted replaced
1188:b3ceb2d470fc 1189:4cbcc54695b2
1263 repo.recover() 1263 repo.recover()
1264 1264
1265 def remove(ui, repo, pat, *pats, **opts): 1265 def remove(ui, repo, pat, *pats, **opts):
1266 """remove the specified files on the next commit""" 1266 """remove the specified files on the next commit"""
1267 names = [] 1267 names = []
1268 def okaytoremove(abs, rel, exact):
1269 c, a, d, u = repo.changes(files = [abs])
1270 reason = None
1271 if c: reason = 'is modified'
1272 elif a: reason = 'has been marked for add'
1273 elif u: reason = 'not managed'
1274 if reason and exact:
1275 ui.warn('not removing %s: file %s\n' % (rel, reason))
1276 else:
1277 return True
1268 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): 1278 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts):
1269 if exact: 1279 if okaytoremove(abs, rel, exact):
1270 skip = {'m': 'file has pending merge', 1280 if not exact: ui.status('removing %s\n' % rel)
1271 'a': 'file has been marked for add (use forget)',
1272 '?': 'file not managed'}
1273 reason = skip.get(repo.dirstate.state(abs))
1274 if reason:
1275 ui.warn('not removing %s: %s\n' % (rel, reason))
1276 else:
1277 names.append(abs)
1278 elif repo.dirstate.state(abs) == 'n':
1279 ui.status('removing %s\n' % rel)
1280 names.append(abs) 1281 names.append(abs)
1281 repo.remove(names) 1282 repo.remove(names)
1282 1283
1283 def revert(ui, repo, *names, **opts): 1284 def revert(ui, repo, *names, **opts):
1284 """revert modified files or dirs back to their unmodified states""" 1285 """revert modified files or dirs back to their unmodified states"""