diff options
author | Simran Basi <sbasi@google.com> | 2015-08-20 12:19:28 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-08-28 10:53:05 -0700 |
commit | b9a1b73425773dc97843f92aeee9c57c9a08c0f7 (patch) | |
tree | 592a3655e92af8c7265ba07e29ba35aa1a1a36a8 /project.py | |
parent | dc2545cad60d7e8bae894f5d60eaeb3cff7485ae (diff) | |
download | git-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 'project.py')
-rw-r--r-- | project.py | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -572,7 +572,8 @@ class Project(object): | |||
572 | parent=None, | 572 | parent=None, |
573 | is_derived=False, | 573 | is_derived=False, |
574 | dest_branch=None, | 574 | dest_branch=None, |
575 | optimized_fetch=False): | 575 | optimized_fetch=False, |
576 | old_revision=None): | ||
576 | """Init a Project object. | 577 | """Init a Project object. |
577 | 578 | ||
578 | Args: | 579 | Args: |
@@ -596,6 +597,7 @@ class Project(object): | |||
596 | dest_branch: The branch to which to push changes for review by default. | 597 | dest_branch: The branch to which to push changes for review by default. |
597 | optimized_fetch: If True, when a project is set to a sha1 revision, only | 598 | optimized_fetch: If True, when a project is set to a sha1 revision, only |
598 | fetch from the remote if the sha1 is not present locally. | 599 | fetch from the remote if the sha1 is not present locally. |
600 | old_revision: saved git commit id for open GITC projects. | ||
599 | """ | 601 | """ |
600 | self.manifest = manifest | 602 | self.manifest = manifest |
601 | self.name = name | 603 | self.name = name |
@@ -643,6 +645,7 @@ class Project(object): | |||
643 | self.bare_ref = GitRefs(gitdir) | 645 | self.bare_ref = GitRefs(gitdir) |
644 | self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=objdir) | 646 | self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=objdir) |
645 | self.dest_branch = dest_branch | 647 | self.dest_branch = dest_branch |
648 | self.old_revision = old_revision | ||
646 | 649 | ||
647 | # This will be filled in if a project is later identified to be the | 650 | # This will be filled in if a project is later identified to be the |
648 | # project containing repo hooks. | 651 | # project containing repo hooks. |
@@ -1195,6 +1198,8 @@ class Project(object): | |||
1195 | self._InitHooks() | 1198 | self._InitHooks() |
1196 | 1199 | ||
1197 | def _CopyAndLinkFiles(self): | 1200 | def _CopyAndLinkFiles(self): |
1201 | if self.manifest.isGitcClient: | ||
1202 | return | ||
1198 | for copyfile in self.copyfiles: | 1203 | for copyfile in self.copyfiles: |
1199 | copyfile._Copy() | 1204 | copyfile._Copy() |
1200 | for linkfile in self.linkfiles: | 1205 | for linkfile in self.linkfiles: |
@@ -1425,9 +1430,11 @@ class Project(object): | |||
1425 | 1430 | ||
1426 | ## Branch Management ## | 1431 | ## Branch Management ## |
1427 | 1432 | ||
1428 | def StartBranch(self, name): | 1433 | def StartBranch(self, name, branch_merge=''): |
1429 | """Create a new branch off the manifest's revision. | 1434 | """Create a new branch off the manifest's revision. |
1430 | """ | 1435 | """ |
1436 | if not branch_merge: | ||
1437 | branch_merge = self.revisionExpr | ||
1431 | head = self.work_git.GetHead() | 1438 | head = self.work_git.GetHead() |
1432 | if head == (R_HEADS + name): | 1439 | if head == (R_HEADS + name): |
1433 | return True | 1440 | return True |
@@ -1441,9 +1448,9 @@ class Project(object): | |||
1441 | 1448 | ||
1442 | branch = self.GetBranch(name) | 1449 | branch = self.GetBranch(name) |
1443 | branch.remote = self.GetRemote(self.remote.name) | 1450 | branch.remote = self.GetRemote(self.remote.name) |
1444 | branch.merge = self.revisionExpr | 1451 | branch.merge = branch_merge |
1445 | if not branch.merge.startswith('refs/') and not ID_RE.match(self.revisionExpr): | 1452 | if not branch.merge.startswith('refs/') and not ID_RE.match(branch_merge): |
1446 | branch.merge = R_HEADS + self.revisionExpr | 1453 | branch.merge = R_HEADS + branch_merge |
1447 | revid = self.GetRevisionId(all_refs) | 1454 | revid = self.GetRevisionId(all_refs) |
1448 | 1455 | ||
1449 | if head.startswith(R_HEADS): | 1456 | if head.startswith(R_HEADS): |
@@ -1451,7 +1458,6 @@ class Project(object): | |||
1451 | head = all_refs[head] | 1458 | head = all_refs[head] |
1452 | except KeyError: | 1459 | except KeyError: |
1453 | head = None | 1460 | head = None |
1454 | |||
1455 | if revid and head and revid == head: | 1461 | if revid and head and revid == head: |
1456 | ref = os.path.join(self.gitdir, R_HEADS + name) | 1462 | ref = os.path.join(self.gitdir, R_HEADS + name) |
1457 | try: | 1463 | try: |