Mercurial > hg-stable
changeset 4691:ca4971347e0a
purge: don't delete ignored files if --all is not specified
author | Emanuele Aina <em@nerd.ocracy.org> |
---|---|
date | Wed, 06 Jun 2007 22:17:35 +0200 |
parents | ecea4de3104e |
children | c135c6cddbec |
files | hgext/purge.py tests/test-purge tests/test-purge.out |
diffstat | 3 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/purge.py Wed Jun 13 18:18:06 2007 +0900 +++ b/hgext/purge.py Wed Jun 06 22:17:35 2007 +0200 @@ -31,7 +31,8 @@ from mercurial.i18n import _ import os -def dopurge(ui, repo, dirs=None, act=True, abort_on_err=False, eol='\n', +def dopurge(ui, repo, dirs=None, act=True, ignored=False, + abort_on_err=False, eol='\n', force=False, include=None, exclude=None): def error(msg): if abort_on_err: @@ -54,7 +55,7 @@ roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs, include, exclude) for src, f, st in repo.dirstate.statwalk(files=roots, match=match, - ignored=True, directories=True): + ignored=ignored, directories=True): if src == 'd': directories.append(f) elif src == 'm': @@ -139,6 +140,7 @@ files that this program would delete use the --print option. ''' act = not opts['print'] + ignored = bool(opts['all']) abort_on_err = bool(opts['abort_on_err']) eol = opts['print0'] and '\0' or '\n' if eol == '\0': @@ -147,13 +149,15 @@ force = bool(opts['force']) include = opts['include'] exclude = opts['exclude'] - dopurge(ui, repo, dirs, act, abort_on_err, eol, force, include, exclude) + dopurge(ui, repo, dirs, act, ignored, abort_on_err, + eol, force, include, exclude) cmdtable = { 'purge': (purge, [('a', 'abort-on-err', None, _('abort if an error occurs')), + ('', 'all', None, _('purge ignored files too')), ('f', 'force', None, _('purge even when missing files are detected')), ('p', 'print', None, _('print the file names instead of deleting them')), ('0', 'print0', None, _('end filenames with NUL, for use with xargs'
--- a/tests/test-purge Wed Jun 13 18:18:06 2007 +0900 +++ b/tests/test-purge Wed Jun 06 22:17:35 2007 +0200 @@ -69,11 +69,14 @@ ls directory/untracked_file rm directory/untracked_file -echo % delete ignored files +echo % skip ignored files if --all not specified touch ignored hg purge -p hg purge -v ls +hg purge -p --all +hg purge -v --all +ls echo % abort with missing files until we support name mangling filesystems touch untracked_file
--- a/tests/test-purge.out Wed Jun 13 18:18:06 2007 +0900 +++ b/tests/test-purge.out Wed Jun 06 22:17:35 2007 +0200 @@ -42,7 +42,10 @@ directory r1 directory/untracked_file -% delete ignored files +% skip ignored files if --all not specified +directory +ignored +r1 ignored Removing file ignored directory