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