mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-06-19 12:34:17 +00:00
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:
@ -16,7 +16,7 @@
|
||||
|
||||
from color import Coloring
|
||||
from command import PagedCommand
|
||||
from manifest_xml import XmlManifest
|
||||
from manifest_xml import RepoClient
|
||||
|
||||
|
||||
class _Coloring(Coloring):
|
||||
@ -183,7 +183,7 @@ synced and their revisions won't be found.
|
||||
self.OptionParser.error('missing manifests to diff')
|
||||
|
||||
def Execute(self, opt, args):
|
||||
self.out = _Coloring(self.manifest.globalConfig)
|
||||
self.out = _Coloring(self.client.globalConfig)
|
||||
self.printText = self.out.nofmt_printer('text')
|
||||
if opt.color:
|
||||
self.printProject = self.out.nofmt_printer('project', attr='bold')
|
||||
@ -193,12 +193,12 @@ synced and their revisions won't be found.
|
||||
else:
|
||||
self.printProject = self.printAdded = self.printRemoved = self.printRevision = self.printText
|
||||
|
||||
manifest1 = XmlManifest(self.manifest.repodir)
|
||||
manifest1 = RepoClient(self.manifest.repodir)
|
||||
manifest1.Override(args[0], load_local_manifests=False)
|
||||
if len(args) == 1:
|
||||
manifest2 = self.manifest
|
||||
else:
|
||||
manifest2 = XmlManifest(self.manifest.repodir)
|
||||
manifest2 = RepoClient(self.manifest.repodir)
|
||||
manifest2.Override(args[1], load_local_manifests=False)
|
||||
|
||||
diff = manifest1.projectsDiff(manifest2)
|
||||
|
@ -65,7 +65,7 @@ Displays detailed usage information about a command.
|
||||
def gitc_supported(cmd):
|
||||
if not isinstance(cmd, GitcAvailableCommand) and not isinstance(cmd, GitcClientCommand):
|
||||
return True
|
||||
if self.manifest.isGitcClient:
|
||||
if self.client.isGitcClient:
|
||||
return True
|
||||
if isinstance(cmd, GitcClientCommand):
|
||||
return False
|
||||
@ -127,7 +127,7 @@ Displays detailed usage information about a command.
|
||||
self.wrap.end_paragraph(1)
|
||||
self.wrap.end_paragraph(0)
|
||||
|
||||
out = _Out(self.manifest.globalConfig)
|
||||
out = _Out(self.client.globalConfig)
|
||||
out._PrintSection('Summary', 'helpSummary')
|
||||
cmd.OptionParser.print_help()
|
||||
out._PrintSection('Description', 'helpDescription')
|
||||
|
@ -44,7 +44,7 @@ class Info(PagedCommand):
|
||||
help="Disable all remote operations")
|
||||
|
||||
def Execute(self, opt, args):
|
||||
self.out = _Coloring(self.manifest.globalConfig)
|
||||
self.out = _Coloring(self.client.globalConfig)
|
||||
self.heading = self.out.printer('heading', attr='bold')
|
||||
self.headtext = self.out.nofmt_printer('headtext', fg='yellow')
|
||||
self.redtext = self.out.printer('redtext', fg='red')
|
||||
|
@ -365,7 +365,7 @@ to update the working directory files.
|
||||
return a
|
||||
|
||||
def _ShouldConfigureUser(self, opt):
|
||||
gc = self.manifest.globalConfig
|
||||
gc = self.client.globalConfig
|
||||
mp = self.manifest.manifestProject
|
||||
|
||||
# If we don't have local settings, get from global.
|
||||
@ -414,7 +414,7 @@ to update the working directory files.
|
||||
return False
|
||||
|
||||
def _ConfigureColor(self):
|
||||
gc = self.manifest.globalConfig
|
||||
gc = self.client.globalConfig
|
||||
if self._HasColorSet(gc):
|
||||
return
|
||||
|
||||
|
@ -165,7 +165,7 @@ the following meanings:
|
||||
proj_dirs, proj_dirs_parents, outstring)
|
||||
|
||||
if outstring:
|
||||
output = StatusColoring(self.manifest.globalConfig)
|
||||
output = StatusColoring(self.client.globalConfig)
|
||||
output.project('Objects not within a project (orphans)')
|
||||
output.nl()
|
||||
for entry in outstring:
|
||||
|
Reference in New Issue
Block a user