Show More
@@ -31,7 +31,8 b' from mercurial import hg, util' | |||||
31 | from mercurial.i18n import _ |
|
31 | from mercurial.i18n import _ | |
32 | import os |
|
32 | import os | |
33 |
|
33 | |||
34 |
def dopurge(ui, repo, dirs=None, act=True, |
|
34 | def dopurge(ui, repo, dirs=None, act=True, ignored=False, | |
|
35 | abort_on_err=False, eol='\n', | |||
35 | force=False, include=None, exclude=None): |
|
36 | force=False, include=None, exclude=None): | |
36 | def error(msg): |
|
37 | def error(msg): | |
37 | if abort_on_err: |
|
38 | if abort_on_err: | |
@@ -54,7 +55,7 b' def dopurge(ui, repo, dirs=None, act=Tru' | |||||
54 | roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs, |
|
55 | roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs, | |
55 | include, exclude) |
|
56 | include, exclude) | |
56 | for src, f, st in repo.dirstate.statwalk(files=roots, match=match, |
|
57 | for src, f, st in repo.dirstate.statwalk(files=roots, match=match, | |
57 |
ignored= |
|
58 | ignored=ignored, directories=True): | |
58 | if src == 'd': |
|
59 | if src == 'd': | |
59 | directories.append(f) |
|
60 | directories.append(f) | |
60 | elif src == 'm': |
|
61 | elif src == 'm': | |
@@ -139,6 +140,7 b' def purge(ui, repo, *dirs, **opts):' | |||||
139 | files that this program would delete use the --print option. |
|
140 | files that this program would delete use the --print option. | |
140 | ''' |
|
141 | ''' | |
141 | act = not opts['print'] |
|
142 | act = not opts['print'] | |
|
143 | ignored = bool(opts['all']) | |||
142 | abort_on_err = bool(opts['abort_on_err']) |
|
144 | abort_on_err = bool(opts['abort_on_err']) | |
143 | eol = opts['print0'] and '\0' or '\n' |
|
145 | eol = opts['print0'] and '\0' or '\n' | |
144 | if eol == '\0': |
|
146 | if eol == '\0': | |
@@ -147,13 +149,15 b' def purge(ui, repo, *dirs, **opts):' | |||||
147 | force = bool(opts['force']) |
|
149 | force = bool(opts['force']) | |
148 | include = opts['include'] |
|
150 | include = opts['include'] | |
149 | exclude = opts['exclude'] |
|
151 | exclude = opts['exclude'] | |
150 |
dopurge(ui, repo, dirs, act, abort_on_err, |
|
152 | dopurge(ui, repo, dirs, act, ignored, abort_on_err, | |
|
153 | eol, force, include, exclude) | |||
151 |
|
154 | |||
152 |
|
155 | |||
153 | cmdtable = { |
|
156 | cmdtable = { | |
154 | 'purge': |
|
157 | 'purge': | |
155 | (purge, |
|
158 | (purge, | |
156 | [('a', 'abort-on-err', None, _('abort if an error occurs')), |
|
159 | [('a', 'abort-on-err', None, _('abort if an error occurs')), | |
|
160 | ('', 'all', None, _('purge ignored files too')), | |||
157 | ('f', 'force', None, _('purge even when missing files are detected')), |
|
161 | ('f', 'force', None, _('purge even when missing files are detected')), | |
158 | ('p', 'print', None, _('print the file names instead of deleting them')), |
|
162 | ('p', 'print', None, _('print the file names instead of deleting them')), | |
159 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs' |
|
163 | ('0', 'print0', None, _('end filenames with NUL, for use with xargs' |
@@ -69,11 +69,14 b' ls' | |||||
69 | ls directory/untracked_file |
|
69 | ls directory/untracked_file | |
70 | rm directory/untracked_file |
|
70 | rm directory/untracked_file | |
71 |
|
71 | |||
72 | echo % delete ignored files |
|
72 | echo % skip ignored files if --all not specified | |
73 | touch ignored |
|
73 | touch ignored | |
74 | hg purge -p |
|
74 | hg purge -p | |
75 | hg purge -v |
|
75 | hg purge -v | |
76 | ls |
|
76 | ls | |
|
77 | hg purge -p --all | |||
|
78 | hg purge -v --all | |||
|
79 | ls | |||
77 |
|
80 | |||
78 | echo % abort with missing files until we support name mangling filesystems |
|
81 | echo % abort with missing files until we support name mangling filesystems | |
79 | touch untracked_file |
|
82 | touch untracked_file |
@@ -42,7 +42,10 b' Removing directory untracked_directory' | |||||
42 | directory |
|
42 | directory | |
43 | r1 |
|
43 | r1 | |
44 | directory/untracked_file |
|
44 | directory/untracked_file | |
45 | % delete ignored files |
|
45 | % skip ignored files if --all not specified | |
|
46 | directory | |||
|
47 | ignored | |||
|
48 | r1 | |||
46 | ignored |
|
49 | ignored | |
47 | Removing file ignored |
|
50 | Removing file ignored | |
48 | directory |
|
51 | directory |
General Comments 0
You need to be logged in to leave comments.
Login now