summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
authorDavid James <davidjames@google.com>2013-10-11 17:03:19 -0700
committerDavid James <davidjames@google.com>2013-10-14 15:34:32 -0700
commit8d20116038ff78b22069dd4e993b5819775f03d1 (patch)
tree4c7ec381f2452d3ae4ed5332230a8d7a61e6ec2b /command.py
parentb25ea555c39cd500740acb74fa9f1dab71588266 (diff)
downloadgit-repo-8d20116038ff78b22069dd4e993b5819775f03d1.tar.gz
repo: Support multiple branches for the same project.
It is often useful to be able to include the same project more than once, but with different branches and placed in different paths in the workspace. Add this feature. This CL adds the concept of an object directory. The object directory stores objects that can be shared amongst several working trees. For newly synced repositories, we set up the git repo now to share its objects with an object repo. Each worktree for a given repo shares objects, but has an independent set of references and branches. This ensures that repo only has to update the objects once; however the references for each worktree are updated separately. Storing the references separately is needed to ensure that commits to a branch on one worktree will not change the HEAD commits of the others. One nice side effect of sharing objects between different worktrees is that you can easily cherry-pick changes between the two worktrees without needing to fetch them. Bug: Issue 141 Change-Id: I5e2f4e1a7abb56f9d3f310fa6fd0c17019330ecd
Diffstat (limited to 'command.py')
-rw-r--r--command.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/command.py b/command.py
index 287f4d30..207ef46b 100644
--- a/command.py
+++ b/command.py
@@ -129,7 +129,7 @@ class Command(object):
129 def GetProjects(self, args, missing_ok=False, submodules_ok=False): 129 def GetProjects(self, args, missing_ok=False, submodules_ok=False):
130 """A list of projects that match the arguments. 130 """A list of projects that match the arguments.
131 """ 131 """
132 all_projects = self.manifest.projects 132 all_projects_list = self.manifest.projects
133 result = [] 133 result = []
134 134
135 mp = self.manifest.manifestProject 135 mp = self.manifest.manifestProject
@@ -140,7 +140,6 @@ class Command(object):
140 groups = [x for x in re.split(r'[,\s]+', groups) if x] 140 groups = [x for x in re.split(r'[,\s]+', groups) if x]
141 141
142 if not args: 142 if not args:
143 all_projects_list = list(all_projects.values())
144 derived_projects = {} 143 derived_projects = {}
145 for project in all_projects_list: 144 for project in all_projects_list:
146 if submodules_ok or project.sync_s: 145 if submodules_ok or project.sync_s:
@@ -152,12 +151,12 @@ class Command(object):
152 project.MatchesGroups(groups)): 151 project.MatchesGroups(groups)):
153 result.append(project) 152 result.append(project)
154 else: 153 else:
155 self._ResetPathToProjectMap(all_projects.values()) 154 self._ResetPathToProjectMap(all_projects_list)
156 155
157 for arg in args: 156 for arg in args:
158 project = all_projects.get(arg) 157 projects = self.manifest.GetProjectsWithName(arg)
159 158
160 if not project: 159 if not projects:
161 path = os.path.abspath(arg).replace('\\', '/') 160 path = os.path.abspath(arg).replace('\\', '/')
162 project = self._GetProjectByPath(path) 161 project = self._GetProjectByPath(path)
163 162
@@ -172,14 +171,19 @@ class Command(object):
172 if search_again: 171 if search_again:
173 project = self._GetProjectByPath(path) or project 172 project = self._GetProjectByPath(path) or project
174 173
175 if not project: 174 if project:
176 raise NoSuchProjectError(arg) 175 projects = [project]
177 if not missing_ok and not project.Exists: 176
177 if not projects:
178 raise NoSuchProjectError(arg) 178 raise NoSuchProjectError(arg)
179 if not project.MatchesGroups(groups):
180 raise InvalidProjectGroupsError(arg)
181 179
182 result.append(project) 180 for project in projects:
181 if not missing_ok and not project.Exists:
182 raise NoSuchProjectError(arg)
183 if not project.MatchesGroups(groups):
184 raise InvalidProjectGroupsError(arg)
185
186 result.extend(projects)
183 187
184 def _getpath(x): 188 def _getpath(x):
185 return x.relpath 189 return x.relpath