Mercurial > hg
changeset 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 | 00205fe76993 |
children | 82385773df6c |
files | mercurial/commands.py |
diffstat | 1 files changed, 14 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue May 02 14:38:32 2006 -0700 +++ b/mercurial/commands.py Tue May 02 21:44:24 2006 -0700 @@ -2347,7 +2347,7 @@ return repo.verify() return 1 -def remove(ui, repo, pat, *pats, **opts): +def remove(ui, repo, *pats, **opts): """remove the specified files on the next commit Schedule the indicated files for removal from the repository. @@ -2355,29 +2355,36 @@ This command schedules the files to be removed at the next commit. This only removes files from the current branch, not from the entire project history. If the files still exist in the working - directory, they will be deleted from it. + directory, they will be deleted from it. If invoked with --after, + files that have been manually deleted are marked as removed. """ names = [] + if not opts['after'] and not pats: + raise util.Abort(_('no files specified')) def okaytoremove(abs, rel, exact): modified, added, removed, deleted, unknown = repo.changes(files=[abs]) reason = None - if modified and not opts['force']: + if not deleted and opts['after']: + reason = _('is still present') + elif modified and not opts['force']: reason = _('is modified') elif added: reason = _('has been marked for add') elif unknown: reason = _('is not managed') + elif removed: + return False if reason: if exact: ui.warn(_('not removing %s: file %s\n') % (rel, reason)) else: return True - for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): + for src, abs, rel, exact in walk(repo, pats, opts): if okaytoremove(abs, rel, exact): if ui.verbose or not exact: ui.status(_('removing %s\n') % rel) names.append(abs) - repo.remove(names, unlink=True) + repo.remove(names, unlink=not opts['after']) def rename(ui, repo, *pats, **opts): """rename files; equivalent of copy + remove @@ -3161,7 +3168,8 @@ "recover": (recover, [], _('hg recover')), "^remove|rm": (remove, - [('f', 'force', None, _('remove file even if modified')), + [('', 'after', None, _('record remove that has already occurred')), + ('f', 'force', None, _('remove file even if modified')), ('I', 'include', [], _('include names matching the given patterns')), ('X', 'exclude', [], _('exclude names matching the given patterns'))], _('hg remove [OPTION]... FILE...')),