From 8d20116038ff78b22069dd4e993b5819775f03d1 Mon Sep 17 00:00:00 2001 From: David James Date: Fri, 11 Oct 2013 17:03:19 -0700 Subject: 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 --- command.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'command.py') 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): def GetProjects(self, args, missing_ok=False, submodules_ok=False): """A list of projects that match the arguments. """ - all_projects = self.manifest.projects + all_projects_list = self.manifest.projects result = [] mp = self.manifest.manifestProject @@ -140,7 +140,6 @@ class Command(object): groups = [x for x in re.split(r'[,\s]+', groups) if x] if not args: - all_projects_list = list(all_projects.values()) derived_projects = {} for project in all_projects_list: if submodules_ok or project.sync_s: @@ -152,12 +151,12 @@ class Command(object): project.MatchesGroups(groups)): result.append(project) else: - self._ResetPathToProjectMap(all_projects.values()) + self._ResetPathToProjectMap(all_projects_list) for arg in args: - project = all_projects.get(arg) + projects = self.manifest.GetProjectsWithName(arg) - if not project: + if not projects: path = os.path.abspath(arg).replace('\\', '/') project = self._GetProjectByPath(path) @@ -172,14 +171,19 @@ class Command(object): if search_again: project = self._GetProjectByPath(path) or project - if not project: - raise NoSuchProjectError(arg) - if not missing_ok and not project.Exists: + if project: + projects = [project] + + if not projects: raise NoSuchProjectError(arg) - if not project.MatchesGroups(groups): - raise InvalidProjectGroupsError(arg) - result.append(project) + for project in projects: + if not missing_ok and not project.Exists: + raise NoSuchProjectError(arg) + if not project.MatchesGroups(groups): + raise InvalidProjectGroupsError(arg) + + result.extend(projects) def _getpath(x): return x.relpath -- cgit v1.2.3-54-g00ecf