Commit dd14d094 by Sébastien Eustace

Improve dependency resolution debug info

parent 6244c49c
......@@ -7,7 +7,12 @@ from ..styles.poetry import PoetryStyle
class CommandFormatter(logging.Formatter):
_colors = {"error": "fg=red", "warning": "fg=yellow", "debug": "fg=blue"}
_colors = {
"error": "fg=red",
"warning": "fg=yellow",
"debug": "debug",
"info": "fg=blue",
}
def format(self, record):
if not record.exc_info:
......
......@@ -10,6 +10,7 @@ class PoetryStyle(CleoStyle):
self.output.get_formatter().add_style("warning", "yellow")
self.output.get_formatter().add_style("question", "blue")
self.output.get_formatter().add_style("comment", "cyan")
self.output.get_formatter().add_style("debug", "black", options=["bold"])
def writeln(
self,
......
......@@ -169,7 +169,7 @@ class VersionSolver:
return _conflict
self._log(
"<fg=blue>derived</>: {}{}".format(
"derived: {}{}".format(
"not " if unsatisfied.is_positive() else "", unsatisfied.dependency
)
)
......@@ -193,7 +193,7 @@ class VersionSolver:
.. _conflict resolution: https://github.com/dart-lang/pub/tree/master/doc/solver.md#conflict-resolution
"""
self._log("<fg=red;options=bold>conflict</>: {}".format(incompatibility))
self._log("conflict: {}".format(incompatibility))
new_incompatibility = False
while not incompatibility.is_failure():
......@@ -302,7 +302,7 @@ class VersionSolver:
new_incompatibility = True
partially = "" if difference is None else " partially"
bang = "<fg=red>!</>"
bang = "!"
self._log(
"{} {} is{} satisfied by {}".format(
bang, most_recent_term, partially, most_recent_satisfier
......@@ -397,9 +397,7 @@ class VersionSolver:
if not conflict:
self._solution.decide(version)
self._log(
"<fg=blue>selecting</> {} ({})".format(
version.name, version.full_pretty_version
)
"selecting {} ({})".format(version.name, version.full_pretty_version)
)
return dependency.name
......@@ -420,7 +418,7 @@ class VersionSolver:
)
def _add_incompatibility(self, incompatibility): # type: (Incompatibility) -> None
self._log("<fg=blue>fact</>: {}".format(incompatibility))
self._log("fact: {}".format(incompatibility))
for term in incompatibility.terms:
if term.dependency.name not in self._incompatibilities:
......
import logging
import os
import pkginfo
import re
import shutil
import time
......@@ -360,7 +361,9 @@ class Provider:
dependencies.append(deps[0])
continue
self.debug("Duplicate dependencies for {}".format(dep_name))
self.debug(
"<debug>Duplicate dependencies for {}</debug>".format(dep_name)
)
# Regrouping by constraint
by_constraint = {}
......@@ -465,6 +468,42 @@ class Provider:
return self._io
def debug(self, message, depth=0):
if message.startswith("fact:"):
if "depends on" in message:
message = re.sub(
"fact: (.+?)(?:( \()(.+?)(\)))? depends on (.+?) \((.+?)\)",
"<fg=blue>fact</>: <info>\\1</info>\\2<comment>\\3</comment>\\4 "
"depends on <info>\\5</info> (<comment>\\6</comment>)",
message,
)
else:
message = re.sub(
"fact: (.+) is (.+)",
"<fg=blue>fact</>: <info>\\1</info> is <comment>\\2</comment>",
message,
)
elif message.startswith("selecting "):
message = re.sub(
"selecting (.+?) \((.+?)\)",
"<fg=blue>selecting</> <info>\\1</info> (<comment>\\2</comment>)",
message,
)
elif message.startswith("derived:"):
message = re.sub(
"derived: (.+?)(?:( \()(.+?)(\)))?$",
"<fg=blue>derived</>: <info>\\1</info>\\2<comment>\\3</comment>\\4",
message,
)
elif message.startswith("conflict:"):
message = re.sub(
"conflict: (.+?)(?:( \()(.+?)(\)))? depends on (.+?) \((.+?)\)",
"<fg=red;options=bold>conflict</>: <info>\\1</info>\\2<comment>\\3</comment>\\4 "
"depends on <info>\\5</info> (<comment>\\6</comment>)",
message,
)
message = message.replace("! ", "<error>!</error> ")
if self.is_debugging():
debug_info = str(message)
debug_info = (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment