diff options
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 54 |
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": \ | ||
| 162 | uncommitted changes are present' % project.relpath | 166 | uncommitted 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') |
