Show More
@@ -48,6 +48,7 b" testedwith = b'ships-with-hg-core'" | |||||
48 | [ |
|
48 | [ | |
49 | (b'a', b'abort-on-err', None, _(b'abort if an error occurs')), |
|
49 | (b'a', b'abort-on-err', None, _(b'abort if an error occurs')), | |
50 | (b'', b'all', None, _(b'purge ignored files too')), |
|
50 | (b'', b'all', None, _(b'purge ignored files too')), | |
|
51 | (b'i', b'ignored', None, _(b'purge only ignored files')), | |||
51 | (b'', b'dirs', None, _(b'purge empty directories')), |
|
52 | (b'', b'dirs', None, _(b'purge empty directories')), | |
52 | (b'', b'files', None, _(b'purge files')), |
|
53 | (b'', b'files', None, _(b'purge files')), | |
53 | (b'p', b'print', None, _(b'print filenames instead of deleting them')), |
|
54 | (b'p', b'print', None, _(b'print filenames instead of deleting them')), | |
@@ -80,7 +81,7 b' def purge(ui, repo, *dirs, **opts):' | |||||
80 | But it will leave untouched: |
|
81 | But it will leave untouched: | |
81 |
|
82 | |||
82 | - Modified and unmodified tracked files |
|
83 | - Modified and unmodified tracked files | |
83 | - Ignored files (unless --all is specified) |
|
84 | - Ignored files (unless -i or --all is specified) | |
84 | - New files added to the repository (with :hg:`add`) |
|
85 | - New files added to the repository (with :hg:`add`) | |
85 |
|
86 | |||
86 | The --files and --dirs options can be used to direct purge to delete |
|
87 | The --files and --dirs options can be used to direct purge to delete | |
@@ -96,12 +97,19 b' def purge(ui, repo, *dirs, **opts):' | |||||
96 | option. |
|
97 | option. | |
97 | ''' |
|
98 | ''' | |
98 | opts = pycompat.byteskwargs(opts) |
|
99 | opts = pycompat.byteskwargs(opts) | |
|
100 | cmdutil.check_at_most_one_arg(opts, b'all', b'ignored') | |||
99 |
|
101 | |||
100 | act = not opts.get(b'print') |
|
102 | act = not opts.get(b'print') | |
101 | eol = b'\n' |
|
103 | eol = b'\n' | |
102 | if opts.get(b'print0'): |
|
104 | if opts.get(b'print0'): | |
103 | eol = b'\0' |
|
105 | eol = b'\0' | |
104 | act = False # --print0 implies --print |
|
106 | act = False # --print0 implies --print | |
|
107 | if opts.get(b'all', False): | |||
|
108 | ignored = True | |||
|
109 | unknown = True | |||
|
110 | else: | |||
|
111 | ignored = opts.get(b'ignored', False) | |||
|
112 | unknown = not ignored | |||
105 |
|
113 | |||
106 | removefiles = opts.get(b'files') |
|
114 | removefiles = opts.get(b'files') | |
107 | removedirs = opts.get(b'dirs') |
|
115 | removedirs = opts.get(b'dirs') | |
@@ -115,7 +123,8 b' def purge(ui, repo, *dirs, **opts):' | |||||
115 | paths = mergemod.purge( |
|
123 | paths = mergemod.purge( | |
116 | repo, |
|
124 | repo, | |
117 | match, |
|
125 | match, | |
118 | ignored=opts.get(b'all', False), |
|
126 | unknown=unknown, | |
|
127 | ignored=ignored, | |||
119 | removeemptydirs=removedirs, |
|
128 | removeemptydirs=removedirs, | |
120 | removefiles=removefiles, |
|
129 | removefiles=removefiles, | |
121 | abortonerror=opts.get(b'abort_on_err'), |
|
130 | abortonerror=opts.get(b'abort_on_err'), |
@@ -2698,6 +2698,7 b' def graft(' | |||||
2698 | def purge( |
|
2698 | def purge( | |
2699 | repo, |
|
2699 | repo, | |
2700 | matcher, |
|
2700 | matcher, | |
|
2701 | unknown=True, | |||
2701 | ignored=False, |
|
2702 | ignored=False, | |
2702 | removeemptydirs=True, |
|
2703 | removeemptydirs=True, | |
2703 | removefiles=True, |
|
2704 | removefiles=True, | |
@@ -2709,7 +2710,9 b' def purge(' | |||||
2709 | ``matcher`` is a matcher configured to scan the working directory - |
|
2710 | ``matcher`` is a matcher configured to scan the working directory - | |
2710 | potentially a subset. |
|
2711 | potentially a subset. | |
2711 |
|
2712 | |||
2712 |
`` |
|
2713 | ``unknown`` controls whether unknown files should be purged. | |
|
2714 | ||||
|
2715 | ``ignored`` controls whether ignored files should be purged. | |||
2713 |
|
2716 | |||
2714 | ``removeemptydirs`` controls whether empty directories should be removed. |
|
2717 | ``removeemptydirs`` controls whether empty directories should be removed. | |
2715 |
|
2718 | |||
@@ -2746,7 +2749,7 b' def purge(' | |||||
2746 | directories = [] |
|
2749 | directories = [] | |
2747 | matcher.traversedir = directories.append |
|
2750 | matcher.traversedir = directories.append | |
2748 |
|
2751 | |||
2749 |
status = repo.status(match=matcher, ignored=ignored, unknown= |
|
2752 | status = repo.status(match=matcher, ignored=ignored, unknown=unknown) | |
2750 |
|
2753 | |||
2751 | if removefiles: |
|
2754 | if removefiles: | |
2752 | for f in sorted(status.unknown + status.ignored): |
|
2755 | for f in sorted(status.unknown + status.ignored): |
@@ -1,5 +1,7 b'' | |||||
1 | == New Features == |
|
1 | == New Features == | |
2 |
|
2 | |||
|
3 | * `hg purge`/`hg clean` can now delete ignored files instead of | |||
|
4 | untracked files, with the new -i flag. | |||
3 |
|
5 | |||
4 | == New Experimental Features == |
|
6 | == New Experimental Features == | |
5 |
|
7 |
@@ -120,19 +120,32 b' delete only part of the tree' | |||||
120 | directory/untracked_file |
|
120 | directory/untracked_file | |
121 | $ rm directory/untracked_file |
|
121 | $ rm directory/untracked_file | |
122 |
|
122 | |||
123 | skip ignored files if --all not specified |
|
123 | skip ignored files if -i or --all not specified | |
124 |
|
124 | |||
125 | $ touch ignored |
|
125 | $ touch ignored | |
126 | $ hg purge -p |
|
126 | $ hg purge -p | |
127 | $ hg purge -v |
|
127 | $ hg purge -v | |
|
128 | $ touch untracked_file | |||
128 | $ ls |
|
129 | $ ls | |
129 | directory |
|
130 | directory | |
130 | ignored |
|
131 | ignored | |
131 | r1 |
|
132 | r1 | |
|
133 | untracked_file | |||
|
134 | $ hg purge -p -i | |||
|
135 | ignored | |||
|
136 | $ hg purge -v -i | |||
|
137 | removing file ignored | |||
|
138 | $ ls | |||
|
139 | directory | |||
|
140 | r1 | |||
|
141 | untracked_file | |||
|
142 | $ touch ignored | |||
132 | $ hg purge -p --all |
|
143 | $ hg purge -p --all | |
133 | ignored |
|
144 | ignored | |
|
145 | untracked_file | |||
134 | $ hg purge -v --all |
|
146 | $ hg purge -v --all | |
135 | removing file ignored |
|
147 | removing file ignored | |
|
148 | removing file untracked_file | |||
136 | $ ls |
|
149 | $ ls | |
137 | directory |
|
150 | directory | |
138 | r1 |
|
151 | r1 |
General Comments 0
You need to be logged in to leave comments.
Login now