Show More
@@ -33,6 +33,21 b' class Purge(object):' | |||||
33 | self._repo = repo |
|
33 | self._repo = repo | |
34 | self._ui = ui |
|
34 | self._ui = ui | |
35 |
|
35 | |||
|
36 | def error(self, msg): | |||
|
37 | if self._abort_on_err: | |||
|
38 | raise util.Abort(msg) | |||
|
39 | else: | |||
|
40 | self._ui.warn(_('warning: %s\n') % msg) | |||
|
41 | ||||
|
42 | def remove(remove_func, name): | |||
|
43 | if self._act: | |||
|
44 | try: | |||
|
45 | remove_func(os.path.join(self._repo.root, name)) | |||
|
46 | except OSError, e: | |||
|
47 | error(_('%s cannot be removed') % name) | |||
|
48 | else: | |||
|
49 | self._ui.write('%s%s' % (name, self._eol)) | |||
|
50 | ||||
36 | directories = [] |
|
51 | directories = [] | |
37 | files = [] |
|
52 | files = [] | |
38 | for src, f, st in repo.dirstate.statwalk(files=dirs, ignored=True, |
|
53 | for src, f, st in repo.dirstate.statwalk(files=dirs, ignored=True, | |
@@ -45,32 +60,14 b' class Purge(object):' | |||||
45 | directories.sort() |
|
60 | directories.sort() | |
46 |
|
61 | |||
47 | for f in files: |
|
62 | for f in files: | |
48 |
if f not in |
|
63 | if f not in repo.dirstate: | |
49 |
|
|
64 | ui.note(_('Removing file %s\n') % f) | |
50 |
|
|
65 | remove(os.remove, f) | |
51 |
|
66 | |||
52 | for f in directories[::-1]: |
|
67 | for f in directories[::-1]: | |
53 | if not os.listdir(repo.wjoin(f)): |
|
68 | if not os.listdir(repo.wjoin(f)): | |
54 |
|
|
69 | ui.note(_('Removing directory %s\n') % f) | |
55 |
|
|
70 | remove(os.rmdir, f) | |
56 |
|
||||
57 | self._repo = None |
|
|||
58 | self._ui = None |
|
|||
59 |
|
||||
60 | def _error(self, msg): |
|
|||
61 | if self._abort_on_err: |
|
|||
62 | raise util.Abort(msg) |
|
|||
63 | else: |
|
|||
64 | self._ui.warn(_('warning: %s\n') % msg) |
|
|||
65 |
|
||||
66 | def _remove(self, remove_func, name): |
|
|||
67 | if self._act: |
|
|||
68 | try: |
|
|||
69 | remove_func(self._repo.wjoin(name)) |
|
|||
70 | except OSError, e: |
|
|||
71 | self._error(_('%s cannot be removed') % name) |
|
|||
72 | else: |
|
|||
73 | self._ui.write('%s%s' % (name, self._eol)) |
|
|||
74 |
|
71 | |||
75 |
|
72 | |||
76 | def purge(ui, repo, *dirs, **opts): |
|
73 | def purge(ui, repo, *dirs, **opts): |
General Comments 0
You need to be logged in to leave comments.
Login now