summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
Diffstat (limited to 'command.py')
-rw-r--r--command.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/command.py b/command.py
index 38cacd3b..78dab96d 100644
--- a/command.py
+++ b/command.py
@@ -106,13 +106,13 @@ class Command(object):
106 def _UpdatePathToProjectMap(self, project): 106 def _UpdatePathToProjectMap(self, project):
107 self._by_path[project.worktree] = project 107 self._by_path[project.worktree] = project
108 108
109 def _GetProjectByPath(self, path): 109 def _GetProjectByPath(self, manifest, path):
110 project = None 110 project = None
111 if os.path.exists(path): 111 if os.path.exists(path):
112 oldpath = None 112 oldpath = None
113 while path \ 113 while path \
114 and path != oldpath \ 114 and path != oldpath \
115 and path != self.manifest.topdir: 115 and path != manifest.topdir:
116 try: 116 try:
117 project = self._by_path[path] 117 project = self._by_path[path]
118 break 118 break
@@ -126,13 +126,16 @@ class Command(object):
126 pass 126 pass
127 return project 127 return project
128 128
129 def GetProjects(self, args, groups='', missing_ok=False, submodules_ok=False): 129 def GetProjects(self, args, manifest=None, groups='', missing_ok=False,
130 submodules_ok=False):
130 """A list of projects that match the arguments. 131 """A list of projects that match the arguments.
131 """ 132 """
132 all_projects_list = self.manifest.projects 133 if not manifest:
134 manifest = self.manifest
135 all_projects_list = manifest.projects
133 result = [] 136 result = []
134 137
135 mp = self.manifest.manifestProject 138 mp = manifest.manifestProject
136 139
137 if not groups: 140 if not groups:
138 groups = mp.config.GetString('manifest.groups') 141 groups = mp.config.GetString('manifest.groups')
@@ -155,11 +158,11 @@ class Command(object):
155 self._ResetPathToProjectMap(all_projects_list) 158 self._ResetPathToProjectMap(all_projects_list)
156 159
157 for arg in args: 160 for arg in args:
158 projects = self.manifest.GetProjectsWithName(arg) 161 projects = manifest.GetProjectsWithName(arg)
159 162
160 if not projects: 163 if not projects:
161 path = os.path.abspath(arg).replace('\\', '/') 164 path = os.path.abspath(arg).replace('\\', '/')
162 project = self._GetProjectByPath(path) 165 project = self._GetProjectByPath(manifest, path)
163 166
164 # If it's not a derived project, update path->project mapping and 167 # If it's not a derived project, update path->project mapping and
165 # search again, as arg might actually point to a derived subproject. 168 # search again, as arg might actually point to a derived subproject.
@@ -170,7 +173,7 @@ class Command(object):
170 self._UpdatePathToProjectMap(subproject) 173 self._UpdatePathToProjectMap(subproject)
171 search_again = True 174 search_again = True
172 if search_again: 175 if search_again:
173 project = self._GetProjectByPath(path) or project 176 project = self._GetProjectByPath(manifest, path) or project
174 177
175 if project: 178 if project:
176 projects = [project] 179 projects = [project]