# HG changeset patch # User Emanuele Aina # Date 1181161055 -7200 # Node ID ca4971347e0a6510df6a0ca0fd05d0e0fe33061f # Parent ecea4de3104ee944520492922c0051124fe69128 purge: don't delete ignored files if --all is not specified diff -r ecea4de3104e -r ca4971347e0a hgext/purge.py --- 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' diff -r ecea4de3104e -r ca4971347e0a tests/test-purge --- 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 diff -r ecea4de3104e -r ca4971347e0a tests/test-purge.out --- 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