manifest_xml: refactor manifest parsing from client management

We conflate the manifest & parsing logic with the management of the
repo client checkout in a single class.  This makes testing just one
part (the manifest parsing) hard as it requires a full checkout too.

Start splitting the two apart into separate classes to make it easy
to reason about & test.

Change-Id: Iaf897c93db9c724baba6044bfe7a589c024523b2
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/288682
Reviewed-by: Michael Mortensen <mmortensen@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger
2020-09-06 14:53:18 -04:00
parent a488af5ea5
commit 8c1e9cbef1
9 changed files with 164 additions and 44 deletions

View File

@@ -510,7 +510,7 @@ class Project(object):
with exponential backoff and jitter.
old_revision: saved git commit id for open GITC projects.
"""
self.manifest = manifest
self.client = self.manifest = manifest
self.name = name
self.remote = remote
self.gitdir = gitdir.replace('\\', '/')
@@ -551,7 +551,7 @@ class Project(object):
self.linkfiles = []
self.annotations = []
self.config = GitConfig.ForRepository(gitdir=self.gitdir,
defaults=self.manifest.globalConfig)
defaults=self.client.globalConfig)
if self.worktree:
self.work_git = self._GitGetByExec(self, bare=False, gitdir=gitdir)
@@ -1168,7 +1168,7 @@ class Project(object):
self._InitHooks()
def _CopyAndLinkFiles(self):
if self.manifest.isGitcClient:
if self.client.isGitcClient:
return
for copyfile in self.copyfiles:
copyfile._Copy()