mirror of https://github.com/sbt/sbt.git
#1763 fix by removing one but all artificial callers
This commit is contained in:
parent
98d81a62f9
commit
22c743cf8a
|
|
@ -8,7 +8,8 @@ import sbt.serialization._
|
|||
import java.net.{ URLEncoder, URLDecoder }
|
||||
|
||||
private[sbt] object JsonUtil {
|
||||
val fakeCallerOrganization = "org.scala-sbt.temp-callers"
|
||||
def sbtOrgTemp = "org.scala-sbt.temp"
|
||||
def fakeCallerOrganization = "org.scala-sbt.temp-callers"
|
||||
|
||||
def parseUpdateReport(md: ModuleDescriptor, path: File, cachedDescriptor: File, log: Logger): UpdateReport =
|
||||
{
|
||||
|
|
@ -36,55 +37,23 @@ private[sbt] object JsonUtil {
|
|||
mr.evicted, mr.evictedData, mr.evictedReason,
|
||||
mr.problem, mr.homepage, mr.extraAttributes,
|
||||
mr.isDefault, mr.branch, mr.configurations, mr.licenses,
|
||||
summarizeCallers(mr.callers))
|
||||
filterOutArtificialCallers(mr.callers))
|
||||
})
|
||||
})
|
||||
})
|
||||
// #1763/#2030. Caller takes up 97% of space, so we need to shrink it down,
|
||||
// but there are semantics associated with some of them.
|
||||
def summarizeCallers(callers: Seq[Caller]): Seq[Caller] =
|
||||
def filterOutArtificialCallers(callers: Seq[Caller]): Seq[Caller] =
|
||||
if (callers.isEmpty) callers
|
||||
else {
|
||||
// Use the first element to represent all callers
|
||||
val head = callers.head
|
||||
val name =
|
||||
URLEncoder.encode(
|
||||
(for {
|
||||
caller <- callers
|
||||
m = caller.caller
|
||||
} yield s"${m.organization}:${m.name}:${m.revision}").mkString(";"), "UTF-8")
|
||||
val version = head.caller.revision
|
||||
val fakeCaller = ModuleID(fakeCallerOrganization, name, version)
|
||||
val caller = new Caller(
|
||||
fakeCaller, head.callerConfigurations, head.callerExtraAttributes,
|
||||
callers exists { _.isForceDependency },
|
||||
callers exists { _.isChangingDependency },
|
||||
callers exists { _.isTransitiveDependency },
|
||||
callers exists { _.isDirectlyForceDependency })
|
||||
Seq(caller)
|
||||
}
|
||||
def unsummarizeCallers(callers: Seq[Caller]): Seq[Caller] =
|
||||
if (callers.isEmpty) callers
|
||||
else {
|
||||
val head = callers.head
|
||||
val m = head.caller
|
||||
if (m.organization != fakeCallerOrganization) callers
|
||||
else {
|
||||
// likely the caller is generated using the above summarizeCallers
|
||||
val s = URLDecoder.decode(m.name, "UTF-8")
|
||||
s.split(";").toList map { x =>
|
||||
x.split(":").toList match {
|
||||
case List(organization, name, revision) =>
|
||||
val caller = ModuleID(organization, name, revision)
|
||||
new Caller(
|
||||
caller, head.callerConfigurations, head.callerExtraAttributes,
|
||||
head.isForceDependency, head.isChangingDependency,
|
||||
head.isTransitiveDependency, head.isDirectlyForceDependency
|
||||
)
|
||||
case xs => sys.error(s"Unexpected caller $xs")
|
||||
}
|
||||
}
|
||||
val nonArtificial = callers filter { c =>
|
||||
(c.caller.organization != sbtOrgTemp) &&
|
||||
(c.caller.organization != fakeCallerOrganization)
|
||||
}
|
||||
val interProj = (callers filter { c =>
|
||||
(c.caller.organization == sbtOrgTemp)
|
||||
}).headOption.toList
|
||||
interProj ::: nonArtificial.toList
|
||||
}
|
||||
|
||||
def fromLite(lite: UpdateReportLite, cachedDescriptor: File): UpdateReport =
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import scala.concurrent.duration._
|
|||
private[sbt] object CachedResolutionResolveCache {
|
||||
def createID(organization: String, name: String, revision: String) =
|
||||
ModuleRevisionId.newInstance(organization, name, revision)
|
||||
def sbtOrgTemp = "org.scala-sbt.temp"
|
||||
def sbtOrgTemp = JsonUtil.sbtOrgTemp
|
||||
def graphVersion = "0.13.9B"
|
||||
val buildStartup: Long = System.currentTimeMillis
|
||||
lazy val todayStr: String = toYyyymmdd(buildStartup)
|
||||
|
|
@ -398,7 +398,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
|
|||
// group by takes up too much memory. trading space with time.
|
||||
val orgNamePairs = (reports0 map { oar => (oar.organization, oar.name) }).distinct
|
||||
// this might take up some memory, but it's limited to a single
|
||||
val reports1 = reports0 map { recoverCallers }
|
||||
val reports1 = reports0 map { filterOutCallers }
|
||||
val allModules: ListMap[(String, String), Vector[OrganizationArtifactReport]] =
|
||||
ListMap(orgNamePairs map {
|
||||
case (organization, name) =>
|
||||
|
|
@ -447,26 +447,17 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
|
|||
})
|
||||
}
|
||||
val sorted = sortModules(allModules, 0)
|
||||
val result = resolveConflicts(sorted.toList) map { summarizeCallers }
|
||||
val result = resolveConflicts(sorted.toList)
|
||||
result.toVector
|
||||
}
|
||||
def recoverCallers(report0: OrganizationArtifactReport): OrganizationArtifactReport =
|
||||
def filterOutCallers(report0: OrganizationArtifactReport): OrganizationArtifactReport =
|
||||
OrganizationArtifactReport(
|
||||
report0.organization,
|
||||
report0.name,
|
||||
report0.modules map { mr =>
|
||||
val original = JsonUtil.unsummarizeCallers(mr.callers)
|
||||
// https://github.com/sbt/sbt/issues/1763
|
||||
mr.copy(callers = original filter { c =>
|
||||
(c.caller.organization != sbtOrgTemp) &&
|
||||
(c.caller.organization != JsonUtil.fakeCallerOrganization)
|
||||
})
|
||||
mr.copy(callers = JsonUtil.filterOutArtificialCallers(mr.callers))
|
||||
})
|
||||
def summarizeCallers(report0: OrganizationArtifactReport): OrganizationArtifactReport =
|
||||
OrganizationArtifactReport(
|
||||
report0.organization,
|
||||
report0.name,
|
||||
report0.modules map { mr => mr.copy(callers = JsonUtil.summarizeCallers(mr.callers)) })
|
||||
/**
|
||||
* Merges ModuleReports, which represents orgnization, name, and version.
|
||||
* Returns a touple of (surviving modules ++ non-conflicting modules, newly evicted modules).
|
||||
|
|
|
|||
Loading…
Reference in New Issue