equal
deleted
inserted
replaced
32 |
32 |
33 def purge(self, ui, repo, dirs=None): |
33 def purge(self, ui, repo, dirs=None): |
34 self._repo = repo |
34 self._repo = repo |
35 self._ui = ui |
35 self._ui = ui |
36 self._hg_root = self._split_path(repo.root) |
36 self._hg_root = self._split_path(repo.root) |
|
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) |
37 |
46 |
38 if not dirs: |
47 directories.sort() |
39 dirs = [repo.root] |
|
40 |
48 |
41 for path in dirs: |
49 for f in files: |
42 path = os.path.abspath(path) |
50 self._remove_file(os.path.join(repo.root, f)) |
43 for root, dirs, files in os.walk(path, topdown=False): |
51 |
44 if '.hg' in self._split_path(root): |
52 for f in directories[::-1]: |
45 # Skip files in the .hg directory. |
53 f = os.path.join(repo.root, f) |
46 # Note that if the repository is in a directory |
54 if not os.listdir(f): |
47 # called .hg this command does not work. |
55 self._remove_dir(f) |
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) |
|
54 |
56 |
55 self._repo = None |
57 self._repo = None |
56 self._ui = None |
58 self._ui = None |
57 self._hg_root = None |
59 self._hg_root = None |
58 |
60 |