From cd81dd6403fc8dbe6ec5920c517d9083902c3c1f Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 26 Oct 2012 12:18:00 -0700 Subject: Revert "Represent git-submodule as nested projects" This reverts commit 69998b0c6ff724bf620480140ccce648fec7d6a9. Broke Android's non-gitmodule use case. Conflicts: project.py subcmds/sync.py Change-Id: I68ceeb63d8ee3b939f85a64736bdc81dfa352aed --- command.py | 72 +++++++++++++++++++++----------------------------------------- 1 file changed, 24 insertions(+), 48 deletions(-) (limited to 'command.py') diff --git a/command.py b/command.py index d543e3a8..0c3b360c 100644 --- a/command.py +++ b/command.py @@ -60,32 +60,6 @@ class Command(object): """ raise NotImplementedError - def _ResetPathToProjectMap(self, projects): - self._by_path = dict((p.worktree, p) for p in projects) - - def _UpdatePathToProjectMap(self, project): - self._by_path[project.worktree] = project - - def _GetProjectByPath(self, path): - project = None - if os.path.exists(path): - oldpath = None - while path \ - and path != oldpath \ - and path != self.manifest.topdir: - try: - project = self._by_path[path] - break - except KeyError: - oldpath = path - path = os.path.dirname(path) - else: - try: - project = self._by_path[path] - except KeyError: - pass - return project - def GetProjects(self, args, missing_ok=False): """A list of projects that match the arguments. """ @@ -100,38 +74,40 @@ class Command(object): groups = [x for x in re.split('[,\s]+', groups) if x] if not args: - all_projects_list = all_projects.values() - derived_projects = [] - for project in all_projects_list: - if project.Registered: - # Do not search registered subproject for derived projects - # since its parent has been searched already - continue - derived_projects.extend(project.GetDerivedSubprojects()) - all_projects_list.extend(derived_projects) - for project in all_projects_list: + for project in all_projects.values(): if ((missing_ok or project.Exists) and project.MatchesGroups(groups)): result.append(project) else: - self._ResetPathToProjectMap(all_projects.values()) + by_path = None for arg in args: project = all_projects.get(arg) if not project: path = os.path.abspath(arg).replace('\\', '/') - project = self._GetProjectByPath(path) - - # If it's not a derived project, update path->project mapping and - # search again, as arg might actually point to a derived subproject. - if project and not project.Derived: - search_again = False - for subproject in project.GetDerivedSubprojects(): - self._UpdatePathToProjectMap(subproject) - search_again = True - if search_again: - project = self._GetProjectByPath(path) or project + + if not by_path: + by_path = dict() + for p in all_projects.values(): + by_path[p.worktree] = p + + if os.path.exists(path): + oldpath = None + while path \ + and path != oldpath \ + and path != self.manifest.topdir: + try: + project = by_path[path] + break + except KeyError: + oldpath = path + path = os.path.dirname(path) + else: + try: + project = by_path[path] + except KeyError: + pass if not project: raise NoSuchProjectError(arg) -- cgit v1.2.3-54-g00ecf