summaryrefslogtreecommitdiffstats
path: root/command.py
diff options
context:
space:
mode:
authorSimran Basi <sbasi@google.com>2015-08-20 12:19:28 -0700
committerDan Willemsen <dwillemsen@google.com>2015-08-28 10:53:05 -0700
commitb9a1b73425773dc97843f92aeee9c57c9a08c0f7 (patch)
tree592a3655e92af8c7265ba07e29ba35aa1a1a36a8 /command.py
parentdc2545cad60d7e8bae894f5d60eaeb3cff7485ae (diff)
downloadgit-repo-b9a1b73425773dc97843f92aeee9c57c9a08c0f7.tar.gz
GITC: Add repo start support.
Add repo start support for GITC checkouts. If the user is in the GITC FS view, they can now run repo start to check out the sources and create a new working branch. When "repo start" is called on a GITC project, the revision tag is set to an empty string and saved in a new tag: old-revision. This tells the GITC filesystem to display the local copy of the sources when being viewed. The local copy is created by pulling the project sources and the new branch is created based off the original project revision. Updated main.py to setup each command's gitc_manifest when appropriate. Updated repo sync's logic to sync opened projects and updating the GITC manifest file for the rest. Change-Id: I7e4809d1c4fc43c69b26f2f1bebe45aab0cae628
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]