Show More
@@ -48,6 +48,7 b" testedwith = b'ships-with-hg-core'" | |||
|
48 | 48 | [ |
|
49 | 49 | (b'a', b'abort-on-err', None, _(b'abort if an error occurs')), |
|
50 | 50 | (b'', b'all', None, _(b'purge ignored files too')), |
|
51 | (b'i', b'ignored', None, _(b'purge only ignored files')), | |
|
51 | 52 | (b'', b'dirs', None, _(b'purge empty directories')), |
|
52 | 53 | (b'', b'files', None, _(b'purge files')), |
|
53 | 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 | 81 | But it will leave untouched: |
|
81 | 82 | |
|
82 | 83 | - Modified and unmodified tracked files |
|
83 | - Ignored files (unless --all is specified) | |
|
84 | - Ignored files (unless -i or --all is specified) | |
|
84 | 85 | - New files added to the repository (with :hg:`add`) |
|
85 | 86 | |
|
86 | 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 | 97 | option. |
|
97 | 98 | ''' |
|
98 | 99 | opts = pycompat.byteskwargs(opts) |
|
100 | cmdutil.check_at_most_one_arg(opts, b'all', b'ignored') | |
|
99 | 101 | |
|
100 | 102 | act = not opts.get(b'print') |
|
101 | 103 | eol = b'\n' |
|
102 | 104 | if opts.get(b'print0'): |
|
103 | 105 | eol = b'\0' |
|
104 | 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 | 114 | removefiles = opts.get(b'files') |
|
107 | 115 | removedirs = opts.get(b'dirs') |
@@ -115,7 +123,8 b' def purge(ui, repo, *dirs, **opts):' | |||
|
115 | 123 | paths = mergemod.purge( |
|
116 | 124 | repo, |
|
117 | 125 | match, |
|
118 | ignored=opts.get(b'all', False), | |
|
126 | unknown=unknown, | |
|
127 | ignored=ignored, | |
|
119 | 128 | removeemptydirs=removedirs, |
|
120 | 129 | removefiles=removefiles, |
|
121 | 130 | abortonerror=opts.get(b'abort_on_err'), |
@@ -2698,6 +2698,7 b' def graft(' | |||
|
2698 | 2698 | def purge( |
|
2699 | 2699 | repo, |
|
2700 | 2700 | matcher, |
|
2701 | unknown=True, | |
|
2701 | 2702 | ignored=False, |
|
2702 | 2703 | removeemptydirs=True, |
|
2703 | 2704 | removefiles=True, |
@@ -2709,7 +2710,9 b' def purge(' | |||
|
2709 | 2710 | ``matcher`` is a matcher configured to scan the working directory - |
|
2710 | 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 | 2717 | ``removeemptydirs`` controls whether empty directories should be removed. |
|
2715 | 2718 | |
@@ -2746,7 +2749,7 b' def purge(' | |||
|
2746 | 2749 | directories = [] |
|
2747 | 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 | 2754 | if removefiles: |
|
2752 | 2755 | for f in sorted(status.unknown + status.ignored): |
@@ -1,5 +1,7 b'' | |||
|
1 | 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 | 6 | == New Experimental Features == |
|
5 | 7 |
@@ -120,19 +120,32 b' delete only part of the tree' | |||
|
120 | 120 | directory/untracked_file |
|
121 | 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 | 125 | $ touch ignored |
|
126 | 126 | $ hg purge -p |
|
127 | 127 | $ hg purge -v |
|
128 | $ touch untracked_file | |
|
128 | 129 | $ ls |
|
129 | 130 | directory |
|
130 | 131 | ignored |
|
131 | 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 | 143 | $ hg purge -p --all |
|
133 | 144 | ignored |
|
145 | untracked_file | |
|
134 | 146 | $ hg purge -v --all |
|
135 | 147 | removing file ignored |
|
148 | removing file untracked_file | |
|
136 | 149 | $ ls |
|
137 | 150 | directory |
|
138 | 151 | r1 |
General Comments 0
You need to be logged in to leave comments.
Login now