summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaikumar Ganesh <jaikumar@google.com>2009-06-02 15:07:44 -0700
committerJaikumar Ganesh <jaikumar@google.com>2009-06-02 15:08:45 -0700
commit8135cdc53c8737c242a5ba122491c9308a3407d8 (patch)
tree06242ed7759f379e1836598a15cf2fcc91938daf
parent4f2517ff1174cd485f0ac93705b0fa9348595f6f (diff)
downloadgit-repo-8135cdc53c8737c242a5ba122491c9308a3407d8.tar.gz
Delete empty parent subdirs after deleting obsolete paths.v1.6.8
After sync, we delete obsolete project paths. Iterate and delete parent subdirs which are empty. Tested on projects within subdirectories.
-rw-r--r--subcmds/sync.py8
1 files changed, 8 insertions, 0 deletions
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
154 else: 154 else:
155 print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree 155 print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree
156 shutil.rmtree(project.worktree) 156 shutil.rmtree(project.worktree)
157 # Try deleting parent subdirs if they are empty
158 dir = os.path.dirname(project.worktree)
159 while dir != self.manifest.topdir:
160 try:
161 os.rmdir(dir)
162 except OSError:
163 break
164 dir = os.path.dirname(dir)
157 165
158 fd = open(file_path, 'w') 166 fd = open(file_path, 'w')
159 try: 167 try: