hgext/purge.py
changeset 44289 9f8eddd2723f
parent 43077 687b865b95ad
child 45133 81859d38e009
--- a/hgext/purge.py	Thu Jan 30 19:50:43 2020 -0500
+++ b/hgext/purge.py	Sat Feb 08 10:22:47 2020 -0500
@@ -48,6 +48,7 @@
     [
         (b'a', b'abort-on-err', None, _(b'abort if an error occurs')),
         (b'', b'all', None, _(b'purge ignored files too')),
+        (b'i', b'ignored', None, _(b'purge only ignored files')),
         (b'', b'dirs', None, _(b'purge empty directories')),
         (b'', b'files', None, _(b'purge files')),
         (b'p', b'print', None, _(b'print filenames instead of deleting them')),
@@ -80,7 +81,7 @@
     But it will leave untouched:
 
     - Modified and unmodified tracked files
-    - Ignored files (unless --all is specified)
+    - Ignored files (unless -i or --all is specified)
     - New files added to the repository (with :hg:`add`)
 
     The --files and --dirs options can be used to direct purge to delete
@@ -96,12 +97,19 @@
     option.
     '''
     opts = pycompat.byteskwargs(opts)
+    cmdutil.check_at_most_one_arg(opts, b'all', b'ignored')
 
     act = not opts.get(b'print')
     eol = b'\n'
     if opts.get(b'print0'):
         eol = b'\0'
         act = False  # --print0 implies --print
+    if opts.get(b'all', False):
+        ignored = True
+        unknown = True
+    else:
+        ignored = opts.get(b'ignored', False)
+        unknown = not ignored
 
     removefiles = opts.get(b'files')
     removedirs = opts.get(b'dirs')
@@ -115,7 +123,8 @@
     paths = mergemod.purge(
         repo,
         match,
-        ignored=opts.get(b'all', False),
+        unknown=unknown,
+        ignored=ignored,
         removeemptydirs=removedirs,
         removefiles=removefiles,
         abortonerror=opts.get(b'abort_on_err'),