From 8135cdc53c8737c242a5ba122491c9308a3407d8 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Tue, 2 Jun 2009 15:07:44 -0700 Subject: [PATCH] Delete empty parent subdirs after deleting obsolete paths. After sync, we delete obsolete project paths. Iterate and delete parent subdirs which are empty. Tested on projects within subdirectories. --- subcmds/sync.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subcmds/sync.py b/subcmds/sync.py index d431c02e..ecb89a10 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -154,6 +154,14 @@ uncommitted changes are present' % project.relpath else: print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree shutil.rmtree(project.worktree) + # Try deleting parent subdirs if they are empty + dir = os.path.dirname(project.worktree) + while dir != self.manifest.topdir: + try: + os.rmdir(dir) + except OSError: + break + dir = os.path.dirname(dir) fd = open(file_path, 'w') try: