Show More
@@ -34,23 +34,25 b' class Purge(object):' | |||
|
34 | 34 | self._repo = repo |
|
35 | 35 | self._ui = ui |
|
36 | 36 | self._hg_root = self._split_path(repo.root) |
|
37 | ||
|
38 | if not dirs: | |
|
39 |
|
|
|
37 | ||
|
38 | directories = [] | |
|
39 | files = [] | |
|
40 | for src, f, st in repo.dirstate.statwalk(files=dirs, ignored=True, | |
|
41 | directories=True): | |
|
42 | if src == 'd': | |
|
43 | directories.append(f) | |
|
44 | elif src == 'f' and f not in repo.dirstate: | |
|
45 | files.append(f) | |
|
40 | 46 | |
|
41 | for path in dirs: | |
|
42 | path = os.path.abspath(path) | |
|
43 | for root, dirs, files in os.walk(path, topdown=False): | |
|
44 | if '.hg' in self._split_path(root): | |
|
45 | # Skip files in the .hg directory. | |
|
46 | # Note that if the repository is in a directory | |
|
47 | # called .hg this command does not work. | |
|
48 | continue | |
|
49 | for name in files: | |
|
50 | self._remove_file(os.path.join(root, name)) | |
|
51 | if not os.listdir(root): | |
|
52 | # Remove this directory if it is empty. | |
|
53 | self._remove_dir(root) | |
|
47 | directories.sort() | |
|
48 | ||
|
49 | for f in files: | |
|
50 | self._remove_file(os.path.join(repo.root, f)) | |
|
51 | ||
|
52 | for f in directories[::-1]: | |
|
53 | f = os.path.join(repo.root, f) | |
|
54 | if not os.listdir(f): | |
|
55 | self._remove_dir(f) | |
|
54 | 56 | |
|
55 | 57 | self._repo = None |
|
56 | 58 | self._ui = None |
General Comments 0
You need to be logged in to leave comments.
Login now