Mercurial > hg
changeset 4470:b593dcd96367
merge with crew
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 01 Jun 2007 13:00:27 +0200 |
parents | a73cf208b2a0 (diff) 8af65bc092b0 (current diff) |
children | 1196998c62e3 |
files | |
diffstat | 3 files changed, 55 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/purge.py Thu May 31 20:12:40 2007 -0400 +++ b/hgext/purge.py Fri Jun 01 13:00:27 2007 +0200 @@ -32,7 +32,7 @@ import os def dopurge(ui, repo, dirs=None, act=True, abort_on_err=False, eol='\n', - force=False): + force=False, include=None, exclude=None): def error(msg): if abort_on_err: raise util.Abort(msg) @@ -51,7 +51,8 @@ directories = [] files = [] missing = [] - roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs) + 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): if src == 'd': @@ -71,7 +72,7 @@ remove(os.remove, f) for f in directories[::-1]: - if not os.listdir(repo.wjoin(f)): + if match(f) and not os.listdir(repo.wjoin(f)): ui.note(_('Removing directory %s\n') % f) remove(os.rmdir, f) @@ -144,7 +145,9 @@ # --print0 implies --print act = False force = bool(opts['force']) - dopurge(ui, repo, dirs, act, abort_on_err, eol, force) + include = opts['include'] + exclude = opts['exclude'] + dopurge(ui, repo, dirs, act, abort_on_err, eol, force, include, exclude) cmdtable = { @@ -154,6 +157,8 @@ ('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' - ' (implies -p)'))], + ' (implies -p)')), + ('I', 'include', [], _('include names matching the given patterns')), + ('X', 'exclude', [], _('exclude names matching the given patterns'))], _('hg purge [OPTION]... [DIR]...')) }
--- a/tests/test-purge Thu May 31 20:12:40 2007 -0400 +++ b/tests/test-purge Fri Jun 01 13:00:27 2007 +0200 @@ -97,3 +97,34 @@ hg purge -v --force hg revert --all --quiet ls + +echo % skip excluded files +touch excluded_file +hg purge -p -X excluded_file +hg purge -v -X excluded_file +ls +rm excluded_file + +echo % skip files in excluded dirs +mkdir excluded_dir +touch excluded_dir/file +hg purge -p -X excluded_dir +hg purge -v -X excluded_dir +ls +ls excluded_dir +rm -R excluded_dir + +echo % skip excluded empty dirs +mkdir excluded_dir +hg purge -p -X excluded_dir +hg purge -v -X excluded_dir +ls +rmdir excluded_dir + +echo % skip patterns +mkdir .svn +touch .svn/foo +mkdir directory/.svn +touch directory/.svn/foo +hg purge -p -X .svn -X '*/.svn' +hg purge -p -X re:.*.svn
--- a/tests/test-purge.out Thu May 31 20:12:40 2007 -0400 +++ b/tests/test-purge.out Fri Jun 01 13:00:27 2007 +0200 @@ -56,3 +56,17 @@ Removing file untracked_file directory r1 +% skip excluded files +directory +excluded_file +r1 +% skip files in excluded dirs +directory +excluded_dir +r1 +file +% skip excluded empty dirs +directory +excluded_dir +r1 +% skip patterns