diff --git a/hgext/purge.py b/hgext/purge.py --- a/hgext/purge.py +++ b/hgext/purge.py @@ -31,7 +31,8 @@ from mercurial import hg, util 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 @@ def dopurge(ui, repo, dirs=None, act=Tru 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 @@ def purge(ui, repo, *dirs, **opts): 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 @@ def purge(ui, repo, *dirs, **opts): 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' diff --git a/tests/test-purge b/tests/test-purge --- a/tests/test-purge +++ b/tests/test-purge @@ -69,11 +69,14 @@ ls 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 diff --git a/tests/test-purge.out b/tests/test-purge.out --- a/tests/test-purge.out +++ b/tests/test-purge.out @@ -42,7 +42,10 @@ Removing directory untracked_directory directory r1 directory/untracked_file -% delete ignored files +% skip ignored files if --all not specified +directory +ignored +r1 ignored Removing file ignored directory