changeset 3384:95c38de476a7 beta

cleanup would recurse into every leaf and could thus not be used on lots of large repositories.
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 19 Feb 2013 19:48:45 +0100
parents c8fd8cca71f2
children d21c762f5c4b
files rhodecode/lib/paster_commands/cleanup.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/paster_commands/cleanup.py	Tue Feb 19 19:44:30 2013 +0100
+++ b/rhodecode/lib/paster_commands/cleanup.py	Tue Feb 19 19:48:45 2013 +0100
@@ -85,10 +85,17 @@
         repos_location = RhodeCodeUi.get_repos_location()
         to_remove = []
         for dn, dirs, f in os.walk(safe_str(repos_location)):
-            for loc in dirs:
+            alldirs = list(dirs)
+            del dirs[:]
+            if ('.hg' in alldirs or
+                'objects' in alldirs and ('refs' in alldirs or 'packed-refs' in f)):
+                continue
+            for loc in alldirs:
                 if REMOVED_REPO_PAT.match(loc):
                     to_remove.append([os.path.join(dn, loc),
                                       self._extract_date(loc)])
+                else:
+                    dirs.append(loc)
 
         #filter older than (if present)!
         now = datetime.datetime.now()