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 /manifest_xml.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 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 6dc01a47..b33ec627 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -29,6 +29,7 @@ else: | |||
29 | urllib = imp.new_module('urllib') | 29 | urllib = imp.new_module('urllib') |
30 | urllib.parse = urlparse | 30 | urllib.parse = urlparse |
31 | 31 | ||
32 | import gitc_utils | ||
32 | from git_config import GitConfig | 33 | from git_config import GitConfig |
33 | from git_refs import R_HEADS, HEAD | 34 | from git_refs import R_HEADS, HEAD |
34 | from project import RemoteSpec, Project, MetaProject | 35 | from project import RemoteSpec, Project, MetaProject |
@@ -112,6 +113,7 @@ class XmlManifest(object): | |||
112 | self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME) | 113 | self.manifestFile = os.path.join(self.repodir, MANIFEST_FILE_NAME) |
113 | self.globalConfig = GitConfig.ForUser() | 114 | self.globalConfig = GitConfig.ForUser() |
114 | self.localManifestWarning = False | 115 | self.localManifestWarning = False |
116 | self.isGitcClient = False | ||
115 | 117 | ||
116 | self.repoProject = MetaProject(self, 'repo', | 118 | self.repoProject = MetaProject(self, 'repo', |
117 | gitdir = os.path.join(repodir, 'repo/.git'), | 119 | gitdir = os.path.join(repodir, 'repo/.git'), |
@@ -306,6 +308,8 @@ class XmlManifest(object): | |||
306 | if p.clone_depth: | 308 | if p.clone_depth: |
307 | e.setAttribute('clone-depth', str(p.clone_depth)) | 309 | e.setAttribute('clone-depth', str(p.clone_depth)) |
308 | 310 | ||
311 | self._output_manifest_project_extras(p, e) | ||
312 | |||
309 | if p.subprojects: | 313 | if p.subprojects: |
310 | subprojects = set(subp.name for subp in p.subprojects) | 314 | subprojects = set(subp.name for subp in p.subprojects) |
311 | output_projects(p, e, list(sorted(subprojects))) | 315 | output_projects(p, e, list(sorted(subprojects))) |
@@ -323,6 +327,10 @@ class XmlManifest(object): | |||
323 | 327 | ||
324 | doc.writexml(fd, '', ' ', '\n', 'UTF-8') | 328 | doc.writexml(fd, '', ' ', '\n', 'UTF-8') |
325 | 329 | ||
330 | def _output_manifest_project_extras(self, p, e): | ||
331 | """Manifests can modify e if they support extra project attributes.""" | ||
332 | pass | ||
333 | |||
326 | @property | 334 | @property |
327 | def paths(self): | 335 | def paths(self): |
328 | self._Load() | 336 | self._Load() |
@@ -712,7 +720,7 @@ class XmlManifest(object): | |||
712 | def _UnjoinName(self, parent_name, name): | 720 | def _UnjoinName(self, parent_name, name): |
713 | return os.path.relpath(name, parent_name) | 721 | return os.path.relpath(name, parent_name) |
714 | 722 | ||
715 | def _ParseProject(self, node, parent = None): | 723 | def _ParseProject(self, node, parent = None, **extra_proj_attrs): |
716 | """ | 724 | """ |
717 | reads a <project> element from the manifest file | 725 | reads a <project> element from the manifest file |
718 | """ | 726 | """ |
@@ -807,7 +815,8 @@ class XmlManifest(object): | |||
807 | clone_depth = clone_depth, | 815 | clone_depth = clone_depth, |
808 | upstream = upstream, | 816 | upstream = upstream, |
809 | parent = parent, | 817 | parent = parent, |
810 | dest_branch = dest_branch) | 818 | dest_branch = dest_branch, |
819 | **extra_proj_attrs) | ||
811 | 820 | ||
812 | for n in node.childNodes: | 821 | for n in node.childNodes: |
813 | if n.nodeName == 'copyfile': | 822 | if n.nodeName == 'copyfile': |
@@ -938,3 +947,26 @@ class XmlManifest(object): | |||
938 | diff['added'].append(toProjects[proj]) | 947 | diff['added'].append(toProjects[proj]) |
939 | 948 | ||
940 | return diff | 949 | return diff |
950 | |||
951 | |||
952 | class GitcManifest(XmlManifest): | ||
953 | |||
954 | def __init__(self, repodir, gitc_client_name): | ||
955 | """Initialize the GitcManifest object.""" | ||
956 | super(GitcManifest, self).__init__(repodir) | ||
957 | self.isGitcClient = True | ||
958 | self.gitc_client_name = gitc_client_name | ||
959 | self.gitc_client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR, | ||
960 | gitc_client_name) | ||
961 | self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest') | ||
962 | |||
963 | def _ParseProject(self, node, parent = None): | ||
964 | """Override _ParseProject and add support for GITC specific attributes.""" | ||
965 | return super(GitcManifest, self)._ParseProject( | ||
966 | node, parent=parent, old_revision=node.getAttribute('old-revision')) | ||
967 | |||
968 | def _output_manifest_project_extras(self, p, e): | ||
969 | """Output GITC Specific Project attributes""" | ||
970 | if p.old_revision: | ||
971 | e.setAttribute('old-revision', str(p.old_revision)) | ||
972 | |||