summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony <anthony@bnovc.com>2009-09-26 13:38:52 -0400
committerShawn O. Pearce <sop@google.com>2010-04-14 14:21:50 -0700
commitf3fdf823cf9785e4ceca3e8416b719282d84b6d0 (patch)
treecfc10b9660e8e01c73166d9368dcca4bd4828c56
parenta1bfd2cd7253b1662e08f5ec5be3d863430c756c (diff)
downloadgit-repo-f3fdf823cf9785e4ceca3e8416b719282d84b6d0.tar.gz
sync: Safely skip already deleted projectsv1.6.9.3
Do not error if a project is missing on the filesystem, is deleted from manifest.xml, but still exists in project.list. Change-Id: I1d13e435473c83091e27e4df571504ef493282dd
-rw-r--r--subcmds/sync.py54
1 files changed, 29 insertions, 25 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index deff171a..02dd82df 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -147,32 +147,36 @@ later is required to fix a server side protocol bug.
147 if not path: 147 if not path:
148 continue 148 continue
149 if path not in new_project_paths: 149 if path not in new_project_paths:
150 project = Project( 150 """If the path has already been deleted, we don't need to do it
151 manifest = self.manifest, 151 """
152 name = path, 152 if os.path.exists(self.manifest.topdir + '/' + path):
153 remote = RemoteSpec('origin'), 153 project = Project(
154 gitdir = os.path.join(self.manifest.topdir, 154 manifest = self.manifest,
155 path, '.git'), 155 name = path,
156 worktree = os.path.join(self.manifest.topdir, path), 156 remote = RemoteSpec('origin'),
157 relpath = path, 157 gitdir = os.path.join(self.manifest.topdir,
158 revisionExpr = 'HEAD', 158 path, '.git'),
159 revisionId = None) 159 worktree = os.path.join(self.manifest.topdir, path),
160 if project.IsDirty(): 160 relpath = path,
161 print >>sys.stderr, 'error: Cannot remove project "%s": \ 161 revisionExpr = 'HEAD',
162 revisionId = None)
163
164 if project.IsDirty():
165 print >>sys.stderr, 'error: Cannot remove project "%s": \
162uncommitted changes are present' % project.relpath 166uncommitted changes are present' % project.relpath
163 print >>sys.stderr, ' commit changes, then run sync again' 167 print >>sys.stderr, ' commit changes, then run sync again'
164 return -1 168 return -1
165 else: 169 else:
166 print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree 170 print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree
167 shutil.rmtree(project.worktree) 171 shutil.rmtree(project.worktree)
168 # Try deleting parent subdirs if they are empty 172 # Try deleting parent subdirs if they are empty
169 dir = os.path.dirname(project.worktree) 173 dir = os.path.dirname(project.worktree)
170 while dir != self.manifest.topdir: 174 while dir != self.manifest.topdir:
171 try: 175 try:
172 os.rmdir(dir) 176 os.rmdir(dir)
173 except OSError: 177 except OSError:
174 break 178 break
175 dir = os.path.dirname(dir) 179 dir = os.path.dirname(dir)
176 180
177 new_project_paths.sort() 181 new_project_paths.sort()
178 fd = open(file_path, 'w') 182 fd = open(file_path, 'w')