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
diff --git a/project.py b/project.py
index a8d012d..f964b2f 100644
--- a/project.py
+++ b/project.py
@@ -572,7 +572,8 @@
parent=None,
is_derived=False,
dest_branch=None,
- optimized_fetch=False):
+ optimized_fetch=False,
+ old_revision=None):
"""Init a Project object.
Args:
@@ -596,6 +597,7 @@
dest_branch: The branch to which to push changes for review by default.
optimized_fetch: If True, when a project is set to a sha1 revision, only
fetch from the remote if the sha1 is not present locally.
+ old_revision: saved git commit id for open GITC projects.
"""
self.manifest = manifest
self.name = name
@@ -643,6 +645,7 @@
self.bare_ref = GitRefs(gitdir)
self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=objdir)
self.dest_branch = dest_branch
+ self.old_revision = old_revision
# This will be filled in if a project is later identified to be the
# project containing repo hooks.
@@ -1195,6 +1198,8 @@
self._InitHooks()
def _CopyAndLinkFiles(self):
+ if self.manifest.isGitcClient:
+ return
for copyfile in self.copyfiles:
copyfile._Copy()
for linkfile in self.linkfiles:
@@ -1425,9 +1430,11 @@
## Branch Management ##
- def StartBranch(self, name):
+ def StartBranch(self, name, branch_merge=''):
"""Create a new branch off the manifest's revision.
"""
+ if not branch_merge:
+ branch_merge = self.revisionExpr
head = self.work_git.GetHead()
if head == (R_HEADS + name):
return True
@@ -1441,9 +1448,9 @@
branch = self.GetBranch(name)
branch.remote = self.GetRemote(self.remote.name)
- branch.merge = self.revisionExpr
- if not branch.merge.startswith('refs/') and not ID_RE.match(self.revisionExpr):
- branch.merge = R_HEADS + self.revisionExpr
+ branch.merge = branch_merge
+ if not branch.merge.startswith('refs/') and not ID_RE.match(branch_merge):
+ branch.merge = R_HEADS + branch_merge
revid = self.GetRevisionId(all_refs)
if head.startswith(R_HEADS):
@@ -1451,7 +1458,6 @@
head = all_refs[head]
except KeyError:
head = None
-
if revid and head and revid == head:
ref = os.path.join(self.gitdir, R_HEADS + name)
try: