##// END OF EJS Templates
purge: eliminate dopurge
Matt Mackall -
r6573:44cd348e default
parent child Browse files
Show More
@@ -31,9 +31,41 b' from mercurial import util, commands'
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, ignored=False,
34 def purge(ui, repo, *dirs, **opts):
35 abort_on_err=False, eol='\n',
35 '''removes files not tracked by mercurial
36 force=False, include=None, exclude=None):
36
37 Delete files not known to mercurial, this is useful to test local and
38 uncommitted changes in the otherwise clean source tree.
39
40 This means that purge will delete:
41 - Unknown files: files marked with "?" by "hg status"
42 - Ignored files: files usually ignored by Mercurial because they match
43 a pattern in a ".hgignore" file
44 - Empty directories: in fact Mercurial ignores directories unless they
45 contain files under source control managment
46 But it will leave untouched:
47 - Unmodified tracked files
48 - Modified tracked files
49 - New files added to the repository (with "hg add")
50
51 If directories are given on the command line, only files in these
52 directories are considered.
53
54 Be careful with purge, you could irreversibly delete some files you
55 forgot to add to the repository. If you only want to print the list of
56 files that this program would delete use the --print option.
57 '''
58 act = not opts['print']
59 ignored = bool(opts['all'])
60 abort_on_err = bool(opts['abort_on_err'])
61 eol = opts['print0'] and '\0' or '\n'
62 if eol == '\0':
63 # --print0 implies --print
64 act = False
65 force = bool(opts['force'])
66 include = opts['include']
67 exclude = opts['exclude']
68
37 def error(msg):
69 def error(msg):
38 if abort_on_err:
70 if abort_on_err:
39 raise util.Abort(msg)
71 raise util.Abort(msg)
@@ -57,7 +89,7 b' def dopurge(ui, repo, dirs=None, act=Tru'
57 missing = []
89 missing = []
58 roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs,
90 roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs,
59 include, exclude)
91 include, exclude)
60 for src, f, st in repo.dirstate.statwalk(files=roots, match=match,
92 for src, f, st in repo.dirstate.statwalk(roots, match,
61 ignored=ignored, directories=True):
93 ignored=ignored, directories=True):
62 if src == 'd':
94 if src == 'd':
63 directories.append(f)
95 directories.append(f)
@@ -99,45 +131,6 b' def _check_fs(ui, repo):'
99 "fully supported.\n"))
131 "fully supported.\n"))
100 raise util.Abort(_("outstanding uncommitted changes"))
132 raise util.Abort(_("outstanding uncommitted changes"))
101
133
102
103 def purge(ui, repo, *dirs, **opts):
104 '''removes files not tracked by mercurial
105
106 Delete files not known to mercurial, this is useful to test local and
107 uncommitted changes in the otherwise clean source tree.
108
109 This means that purge will delete:
110 - Unknown files: files marked with "?" by "hg status"
111 - Ignored files: files usually ignored by Mercurial because they match
112 a pattern in a ".hgignore" file
113 - Empty directories: in fact Mercurial ignores directories unless they
114 contain files under source control managment
115 But it will leave untouched:
116 - Unmodified tracked files
117 - Modified tracked files
118 - New files added to the repository (with "hg add")
119
120 If directories are given on the command line, only files in these
121 directories are considered.
122
123 Be careful with purge, you could irreversibly delete some files you
124 forgot to add to the repository. If you only want to print the list of
125 files that this program would delete use the --print option.
126 '''
127 act = not opts['print']
128 ignored = bool(opts['all'])
129 abort_on_err = bool(opts['abort_on_err'])
130 eol = opts['print0'] and '\0' or '\n'
131 if eol == '\0':
132 # --print0 implies --print
133 act = False
134 force = bool(opts['force'])
135 include = opts['include']
136 exclude = opts['exclude']
137 dopurge(ui, repo, dirs, act, ignored, abort_on_err,
138 eol, force, include, exclude)
139
140
141 cmdtable = {
134 cmdtable = {
142 'purge|clean':
135 'purge|clean':
143 (purge,
136 (purge,
General Comments 0
You need to be logged in to leave comments. Login now