Revert "Represent git-submodule as nested projects"

This reverts commit 69998b0c6f.
Broke Android's non-gitmodule use case.

Conflicts:
	project.py
	subcmds/sync.py

Change-Id: I68ceeb63d8ee3b939f85a64736bdc81dfa352aed
This commit is contained in:
Shawn O. Pearce
2012-10-26 12:18:00 -07:00
parent 80d2ceb222
commit cd81dd6403
5 changed files with 54 additions and 339 deletions

View File

@ -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)