Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 2179:520dd3d28e9b
add --after option to remove command.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 02 May 2006 21:44:24 -0700 |
parents | b2ae81a7df29 |
children | 690da72b0b16 |
comparison
equal
deleted
inserted
replaced
2178:00205fe76993 | 2179:520dd3d28e9b |
---|---|
2345 """ | 2345 """ |
2346 if repo.recover(): | 2346 if repo.recover(): |
2347 return repo.verify() | 2347 return repo.verify() |
2348 return 1 | 2348 return 1 |
2349 | 2349 |
2350 def remove(ui, repo, pat, *pats, **opts): | 2350 def remove(ui, repo, *pats, **opts): |
2351 """remove the specified files on the next commit | 2351 """remove the specified files on the next commit |
2352 | 2352 |
2353 Schedule the indicated files for removal from the repository. | 2353 Schedule the indicated files for removal from the repository. |
2354 | 2354 |
2355 This command schedules the files to be removed at the next commit. | 2355 This command schedules the files to be removed at the next commit. |
2356 This only removes files from the current branch, not from the | 2356 This only removes files from the current branch, not from the |
2357 entire project history. If the files still exist in the working | 2357 entire project history. If the files still exist in the working |
2358 directory, they will be deleted from it. | 2358 directory, they will be deleted from it. If invoked with --after, |
2359 files that have been manually deleted are marked as removed. | |
2359 """ | 2360 """ |
2360 names = [] | 2361 names = [] |
2362 if not opts['after'] and not pats: | |
2363 raise util.Abort(_('no files specified')) | |
2361 def okaytoremove(abs, rel, exact): | 2364 def okaytoremove(abs, rel, exact): |
2362 modified, added, removed, deleted, unknown = repo.changes(files=[abs]) | 2365 modified, added, removed, deleted, unknown = repo.changes(files=[abs]) |
2363 reason = None | 2366 reason = None |
2364 if modified and not opts['force']: | 2367 if not deleted and opts['after']: |
2368 reason = _('is still present') | |
2369 elif modified and not opts['force']: | |
2365 reason = _('is modified') | 2370 reason = _('is modified') |
2366 elif added: | 2371 elif added: |
2367 reason = _('has been marked for add') | 2372 reason = _('has been marked for add') |
2368 elif unknown: | 2373 elif unknown: |
2369 reason = _('is not managed') | 2374 reason = _('is not managed') |
2375 elif removed: | |
2376 return False | |
2370 if reason: | 2377 if reason: |
2371 if exact: | 2378 if exact: |
2372 ui.warn(_('not removing %s: file %s\n') % (rel, reason)) | 2379 ui.warn(_('not removing %s: file %s\n') % (rel, reason)) |
2373 else: | 2380 else: |
2374 return True | 2381 return True |
2375 for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): | 2382 for src, abs, rel, exact in walk(repo, pats, opts): |
2376 if okaytoremove(abs, rel, exact): | 2383 if okaytoremove(abs, rel, exact): |
2377 if ui.verbose or not exact: | 2384 if ui.verbose or not exact: |
2378 ui.status(_('removing %s\n') % rel) | 2385 ui.status(_('removing %s\n') % rel) |
2379 names.append(abs) | 2386 names.append(abs) |
2380 repo.remove(names, unlink=True) | 2387 repo.remove(names, unlink=not opts['after']) |
2381 | 2388 |
2382 def rename(ui, repo, *pats, **opts): | 2389 def rename(ui, repo, *pats, **opts): |
2383 """rename files; equivalent of copy + remove | 2390 """rename files; equivalent of copy + remove |
2384 | 2391 |
2385 Mark dest as copies of sources; mark sources for deletion. If | 2392 Mark dest as copies of sources; mark sources for deletion. If |
3159 ('l', 'logfile', '', _('commit message file'))], | 3166 ('l', 'logfile', '', _('commit message file'))], |
3160 _('hg debugrawcommit [OPTION]... [FILE]...')), | 3167 _('hg debugrawcommit [OPTION]... [FILE]...')), |
3161 "recover": (recover, [], _('hg recover')), | 3168 "recover": (recover, [], _('hg recover')), |
3162 "^remove|rm": | 3169 "^remove|rm": |
3163 (remove, | 3170 (remove, |
3164 [('f', 'force', None, _('remove file even if modified')), | 3171 [('', 'after', None, _('record remove that has already occurred')), |
3172 ('f', 'force', None, _('remove file even if modified')), | |
3165 ('I', 'include', [], _('include names matching the given patterns')), | 3173 ('I', 'include', [], _('include names matching the given patterns')), |
3166 ('X', 'exclude', [], _('exclude names matching the given patterns'))], | 3174 ('X', 'exclude', [], _('exclude names matching the given patterns'))], |
3167 _('hg remove [OPTION]... FILE...')), | 3175 _('hg remove [OPTION]... FILE...')), |
3168 "rename|mv": | 3176 "rename|mv": |
3169 (rename, | 3177 (rename, |