Mercurial > hg-stable
changeset 6573:44cd348e6529
purge: eliminate dopurge
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 12 May 2008 11:37:07 -0500 |
parents | 4927cf61bdc1 |
children | 76af1dff402a |
files | hgext/purge.py |
diffstat | 1 files changed, 36 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/purge.py Mon May 12 11:37:07 2008 -0500 +++ b/hgext/purge.py Mon May 12 11:37:07 2008 -0500 @@ -31,9 +31,41 @@ from mercurial.i18n import _ import os -def dopurge(ui, repo, dirs=None, act=True, ignored=False, - abort_on_err=False, eol='\n', - force=False, include=None, exclude=None): +def purge(ui, repo, *dirs, **opts): + '''removes files not tracked by mercurial + + Delete files not known to mercurial, this is useful to test local and + uncommitted changes in the otherwise clean source tree. + + This means that purge will delete: + - Unknown files: files marked with "?" by "hg status" + - Ignored files: files usually ignored by Mercurial because they match + a pattern in a ".hgignore" file + - Empty directories: in fact Mercurial ignores directories unless they + contain files under source control managment + But it will leave untouched: + - Unmodified tracked files + - Modified tracked files + - New files added to the repository (with "hg add") + + If directories are given on the command line, only files in these + directories are considered. + + Be careful with purge, you could irreversibly delete some files you + forgot to add to the repository. If you only want to print the list of + 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': + # --print0 implies --print + act = False + force = bool(opts['force']) + include = opts['include'] + exclude = opts['exclude'] + def error(msg): if abort_on_err: raise util.Abort(msg) @@ -57,7 +89,7 @@ missing = [] roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs, include, exclude) - for src, f, st in repo.dirstate.statwalk(files=roots, match=match, + for src, f, st in repo.dirstate.statwalk(roots, match, ignored=ignored, directories=True): if src == 'd': directories.append(f) @@ -99,45 +131,6 @@ "fully supported.\n")) raise util.Abort(_("outstanding uncommitted changes")) - -def purge(ui, repo, *dirs, **opts): - '''removes files not tracked by mercurial - - Delete files not known to mercurial, this is useful to test local and - uncommitted changes in the otherwise clean source tree. - - This means that purge will delete: - - Unknown files: files marked with "?" by "hg status" - - Ignored files: files usually ignored by Mercurial because they match - a pattern in a ".hgignore" file - - Empty directories: in fact Mercurial ignores directories unless they - contain files under source control managment - But it will leave untouched: - - Unmodified tracked files - - Modified tracked files - - New files added to the repository (with "hg add") - - If directories are given on the command line, only files in these - directories are considered. - - Be careful with purge, you could irreversibly delete some files you - forgot to add to the repository. If you only want to print the list of - 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': - # --print0 implies --print - act = False - force = bool(opts['force']) - include = opts['include'] - exclude = opts['exclude'] - dopurge(ui, repo, dirs, act, ignored, abort_on_err, - eol, force, include, exclude) - - cmdtable = { 'purge|clean': (purge,