2017-05-02 19:26:49 +03:00
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
2016-07-12 21:56:12 +03:00
package gps
2016-03-15 06:36:42 +03:00
2016-04-04 22:32:22 +03:00
import (
"bytes"
"fmt"
2016-07-27 05:10:52 +03:00
"sort"
2016-05-03 16:47:48 +03:00
"strings"
2016-04-04 22:32:22 +03:00
)
2016-07-21 20:16:38 +03:00
func a2vs ( a atom ) string {
if a . v == rootRev || a . v == nil {
return "(root)"
}
2017-08-30 23:03:33 +03:00
return fmt . Sprintf ( "%s@%s" , a . id , a . v )
2016-07-21 20:16:38 +03:00
}
2016-05-04 22:30:16 +03:00
type traceError interface {
traceString ( ) string
}
2016-03-15 06:36:42 +03:00
type noVersionError struct {
2016-04-29 01:53:42 +03:00
pn ProjectIdentifier
2016-04-04 22:32:22 +03:00
fails [ ] failedVersion
2016-03-15 06:36:42 +03:00
}
func ( e * noVersionError ) Error ( ) string {
2016-04-04 22:32:22 +03:00
if len ( e . fails ) == 0 {
2016-07-09 07:18:22 +03:00
return fmt . Sprintf ( "No versions found for project %q." , e . pn . ProjectRoot )
2016-04-04 22:32:22 +03:00
}
var buf bytes . Buffer
2016-07-09 07:18:22 +03:00
fmt . Fprintf ( & buf , "No versions of %s met constraints:" , e . pn . ProjectRoot )
2016-04-04 22:32:22 +03:00
for _ , f := range e . fails {
2016-04-22 15:35:34 +03:00
fmt . Fprintf ( & buf , "\n\t%s: %s" , f . v , f . f . Error ( ) )
2016-04-04 22:32:22 +03:00
}
return buf . String ( )
2016-03-15 06:36:42 +03:00
}
2016-05-04 22:30:16 +03:00
func ( e * noVersionError ) traceString ( ) string {
if len ( e . fails ) == 0 {
return fmt . Sprintf ( "No versions found" )
}
var buf bytes . Buffer
2016-07-09 07:18:22 +03:00
fmt . Fprintf ( & buf , "No versions of %s met constraints:" , e . pn . ProjectRoot )
2016-05-04 22:30:16 +03:00
for _ , f := range e . fails {
if te , ok := f . f . ( traceError ) ; ok {
fmt . Fprintf ( & buf , "\n %s: %s" , f . v , te . traceString ( ) )
} else {
fmt . Fprintf ( & buf , "\n %s: %s" , f . v , f . f . Error ( ) )
}
}
return buf . String ( )
}
2017-08-29 07:13:04 +03:00
// caseMismatchFailure occurs when there are import paths that differ only by
// case. The compiler disallows this case.
type caseMismatchFailure struct {
// goal is the depender atom that tried to introduce the case-varying name,
// along with the case-varying name.
goal dependency
// current is the specific casing of a ProjectRoot that is presently
// selected for all possible case variations of its contained unicode code
// points.
current ProjectRoot
// failsib is the list of active dependencies that have determined the
// specific casing for the target project.
failsib [ ] dependency
}
func ( e * caseMismatchFailure ) Error ( ) string {
if len ( e . failsib ) == 1 {
str := "Could not introduce %s due to a case-only variation: it depends on %q, but %q was already established as the case variant for that project root by depender %s"
return fmt . Sprintf ( str , a2vs ( e . goal . depender ) , e . goal . dep . Ident . ProjectRoot , e . current , a2vs ( e . failsib [ 0 ] . depender ) )
}
var buf bytes . Buffer
str := "Could not introduce %s due to a case-only variation: it depends on %q, but %q was already established as the case variant for that project root by the following other dependers:\n"
2017-10-02 22:29:57 +03:00
fmt . Fprintf ( & buf , str , a2vs ( e . goal . depender ) , e . goal . dep . Ident . ProjectRoot , e . current )
2017-08-29 07:13:04 +03:00
for _ , c := range e . failsib {
fmt . Fprintf ( & buf , "\t%s\n" , a2vs ( c . depender ) )
}
return buf . String ( )
}
func ( e * caseMismatchFailure ) traceString ( ) string {
var buf bytes . Buffer
fmt . Fprintf ( & buf , "case-only variation in dependency on %q; %q already established by:\n" , e . goal . dep . Ident . ProjectRoot , e . current )
for _ , f := range e . failsib {
fmt . Fprintf ( & buf , "%s\n" , a2vs ( f . depender ) )
}
return buf . String ( )
}
2017-09-02 02:15:01 +03:00
// wrongCaseFailure occurs when one or more projects - A, B, ... - depend on
// another project - Z - with an incorrect case variant, as indicated by the
// case variant used internally by Z to reference its own packages.
//
// For example, github.com/sirupsen/logrus/hooks/syslog references itself via
// github.com/sirupsen/logrus, establishing that as the canonical case variant.
type wrongCaseFailure struct {
// correct is the canonical representation of the ProjectRoot
correct ProjectRoot
// goal is the incorrectly-referenced target project
goal dependency
// badcase is the list of active dependencies that have specified an
// incorrect ProjectRoot casing for the project in question.
badcase [ ] dependency
}
func ( e * wrongCaseFailure ) Error ( ) string {
if len ( e . badcase ) == 1 {
2017-09-05 08:45:16 +03:00
str := "Could not introduce %s; imports amongst its packages establish %q as the canonical casing for root, but %s tried to import it as %q"
2017-09-02 02:15:01 +03:00
return fmt . Sprintf ( str , a2vs ( e . goal . depender ) , e . correct , a2vs ( e . badcase [ 0 ] . depender ) , e . badcase [ 0 ] . dep . Ident . ProjectRoot )
}
var buf bytes . Buffer
2017-09-05 08:45:16 +03:00
str := "Could not introduce %s; imports amongst its packages establish %q as the canonical casing for root, but the following projects tried to import it as %q"
2017-09-02 07:08:01 +03:00
fmt . Fprintf ( & buf , str , a2vs ( e . goal . depender ) , e . correct , e . badcase [ 0 ] . dep . Ident . ProjectRoot )
2017-09-02 02:15:01 +03:00
for _ , c := range e . badcase {
fmt . Fprintf ( & buf , "\t%s\n" , a2vs ( c . depender ) )
}
return buf . String ( )
}
func ( e * wrongCaseFailure ) traceString ( ) string {
var buf bytes . Buffer
fmt . Fprintf ( & buf , "internal imports establish %q as correct casing; %q was used by:\n" , e . correct , e . goal . dep . Ident . ProjectRoot )
for _ , f := range e . badcase {
fmt . Fprintf ( & buf , "%s\n" , a2vs ( f . depender ) )
}
return buf . String ( )
}
2016-07-27 03:57:17 +03:00
// disjointConstraintFailure occurs when attempting to introduce an atom that
// itself has an acceptable version, but one of its dependency constraints is
// disjoint with one or more dependency constraints already active for that
// identifier.
2016-03-15 06:36:42 +03:00
type disjointConstraintFailure struct {
2016-07-27 03:57:17 +03:00
// goal is the dependency with the problematic constraint, forcing us to
// reject the atom that introduces it.
goal dependency
// failsib is the list of active dependencies that are disjoint with the
// goal dependency. This will be at least one, but may not be all of the
// active dependencies.
failsib [ ] dependency
// nofailsib is the list of active dependencies that are NOT disjoint with
// the goal dependency. The total of nofailsib and failsib will always be
// the total number of active dependencies on target identifier.
2016-06-30 05:57:23 +03:00
nofailsib [ ] dependency
2016-07-27 03:57:17 +03:00
// c is the current constraint on the target identifier. It is intersection
// of all the active dependencies' constraints.
c Constraint
2016-03-15 06:36:42 +03:00
}
func ( e * disjointConstraintFailure ) Error ( ) string {
2016-04-04 22:32:22 +03:00
if len ( e . failsib ) == 1 {
2016-07-21 20:16:38 +03:00
str := "Could not introduce %s, as it has a dependency on %s with constraint %s, which has no overlap with existing constraint %s from %s"
2017-08-30 23:03:33 +03:00
return fmt . Sprintf ( str , a2vs ( e . goal . depender ) , e . goal . dep . Ident , e . goal . dep . Constraint . String ( ) , e . failsib [ 0 ] . dep . Constraint . String ( ) , a2vs ( e . failsib [ 0 ] . depender ) )
2016-04-04 22:32:22 +03:00
}
var buf bytes . Buffer
2016-06-30 05:57:23 +03:00
var sibs [ ] dependency
2016-04-04 22:32:22 +03:00
if len ( e . failsib ) > 1 {
sibs = e . failsib
2016-07-21 20:16:38 +03:00
str := "Could not introduce %s, as it has a dependency on %s with constraint %s, which has no overlap with the following existing constraints:\n"
2017-08-30 23:03:33 +03:00
fmt . Fprintf ( & buf , str , a2vs ( e . goal . depender ) , e . goal . dep . Ident , e . goal . dep . Constraint . String ( ) )
2016-04-04 22:32:22 +03:00
} else {
sibs = e . nofailsib
2016-07-21 20:16:38 +03:00
str := "Could not introduce %s, as it has a dependency on %s with constraint %s, which does not overlap with the intersection of existing constraints from other currently selected packages:\n"
2017-08-30 23:03:33 +03:00
fmt . Fprintf ( & buf , str , a2vs ( e . goal . depender ) , e . goal . dep . Ident , e . goal . dep . Constraint . String ( ) )
2016-04-04 22:32:22 +03:00
}
for _ , c := range sibs {
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , "\t%s from %s\n" , c . dep . Constraint . String ( ) , a2vs ( c . depender ) )
2016-04-04 22:32:22 +03:00
}
return buf . String ( )
}
2016-05-04 22:30:16 +03:00
func ( e * disjointConstraintFailure ) traceString ( ) string {
var buf bytes . Buffer
2017-08-30 23:03:33 +03:00
fmt . Fprintf ( & buf , "constraint %s on %s disjoint with other dependers:\n" , e . goal . dep . Constraint . String ( ) , e . goal . dep . Ident )
2016-05-04 22:30:16 +03:00
for _ , f := range e . failsib {
2016-07-21 20:16:38 +03:00
fmt . Fprintf (
& buf ,
"%s from %s (no overlap)\n" ,
f . dep . Constraint . String ( ) ,
a2vs ( f . depender ) ,
)
2016-05-04 22:30:16 +03:00
}
for _ , f := range e . nofailsib {
2016-07-21 20:16:38 +03:00
fmt . Fprintf (
& buf ,
"%s from %s (some overlap)\n" ,
f . dep . Constraint . String ( ) ,
a2vs ( f . depender ) ,
)
2016-05-04 22:30:16 +03:00
}
return buf . String ( )
}
2016-04-04 22:32:22 +03:00
// Indicates that an atom could not be introduced because one of its dep
// constraints does not admit the currently-selected version of the target
// project.
type constraintNotAllowedFailure struct {
2016-07-27 03:39:02 +03:00
// The dependency with the problematic constraint that could not be
// introduced.
2016-06-30 05:57:23 +03:00
goal dependency
2016-07-27 03:39:02 +03:00
// The (currently selected) version of the target project that was not
// admissible by the goal dependency.
v Version
2016-04-04 22:32:22 +03:00
}
func ( e * constraintNotAllowedFailure ) Error ( ) string {
2016-07-21 20:16:38 +03:00
return fmt . Sprintf (
"Could not introduce %s, as it has a dependency on %s with constraint %s, which does not allow the currently selected version of %s" ,
a2vs ( e . goal . depender ) ,
2017-08-30 23:03:33 +03:00
e . goal . dep . Ident ,
2016-07-21 20:16:38 +03:00
e . goal . dep . Constraint ,
e . v ,
)
2016-04-04 22:32:22 +03:00
}
2016-05-04 22:30:16 +03:00
func ( e * constraintNotAllowedFailure ) traceString ( ) string {
2016-07-21 20:16:38 +03:00
return fmt . Sprintf (
"%s depends on %s with %s, but that's already selected at %s" ,
a2vs ( e . goal . depender ) ,
e . goal . dep . Ident . ProjectRoot ,
e . goal . dep . Constraint ,
e . v ,
)
2016-05-04 22:30:16 +03:00
}
2016-07-27 03:04:19 +03:00
// versionNotAllowedFailure describes a failure where an atom is rejected
// because its version is not allowed by current constraints.
//
// (This is one of the more straightforward types of failures)
2016-04-04 22:32:22 +03:00
type versionNotAllowedFailure struct {
2016-07-27 03:57:17 +03:00
// goal is the atom that was rejected by current constraints.
2016-07-27 03:04:19 +03:00
goal atom
2016-07-27 03:57:17 +03:00
// failparent is the list of active dependencies that caused the atom to be
// rejected. Note that this only includes dependencies that actually
// rejected the atom, which will be at least one, but may not be all the
// active dependencies on the atom's identifier.
2016-06-30 05:57:23 +03:00
failparent [ ] dependency
2016-07-27 03:57:17 +03:00
// c is the current constraint on the atom's identifier. This is the intersection
// of all active dependencies' constraints.
2016-07-27 03:04:19 +03:00
c Constraint
2016-04-04 22:32:22 +03:00
}
func ( e * versionNotAllowedFailure ) Error ( ) string {
if len ( e . failparent ) == 1 {
2016-07-21 20:16:38 +03:00
return fmt . Sprintf (
"Could not introduce %s, as it is not allowed by constraint %s from project %s." ,
a2vs ( e . goal ) ,
e . failparent [ 0 ] . dep . Constraint . String ( ) ,
2017-08-30 23:03:33 +03:00
e . failparent [ 0 ] . depender . id ,
2016-07-21 20:16:38 +03:00
)
2016-04-04 22:32:22 +03:00
}
var buf bytes . Buffer
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , "Could not introduce %s, as it is not allowed by constraints from the following projects:\n" , a2vs ( e . goal ) )
2016-04-04 22:32:22 +03:00
for _ , f := range e . failparent {
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , "\t%s from %s\n" , f . dep . Constraint . String ( ) , a2vs ( f . depender ) )
2016-04-04 22:32:22 +03:00
}
return buf . String ( )
2016-03-15 06:36:42 +03:00
}
2016-04-19 18:15:33 +03:00
2016-05-04 22:30:16 +03:00
func ( e * versionNotAllowedFailure ) traceString ( ) string {
var buf bytes . Buffer
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , "%s not allowed by constraint %s:\n" , a2vs ( e . goal ) , e . c . String ( ) )
2016-05-04 22:30:16 +03:00
for _ , f := range e . failparent {
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , " %s from %s\n" , f . dep . Constraint . String ( ) , a2vs ( f . depender ) )
2016-05-04 22:30:16 +03:00
}
return buf . String ( )
}
2016-04-19 18:15:33 +03:00
type missingSourceFailure struct {
2016-04-29 01:53:42 +03:00
goal ProjectIdentifier
2016-04-19 18:15:33 +03:00
prob string
}
func ( e * missingSourceFailure ) Error ( ) string {
return fmt . Sprintf ( e . prob , e . goal )
}
2016-04-20 21:52:46 +03:00
2016-06-30 05:50:05 +03:00
type badOptsFailure string
2016-04-20 21:52:46 +03:00
2016-06-30 05:50:05 +03:00
func ( e badOptsFailure ) Error ( ) string {
2016-04-20 21:52:46 +03:00
return string ( e )
}
2016-05-03 16:47:48 +03:00
type sourceMismatchFailure struct {
2016-07-26 23:31:24 +03:00
// The ProjectRoot over which there is disagreement about where it should be
// sourced from
shared ProjectRoot
// The current value for the network source
current string
// The mismatched value for the network source
mismatch string
// The currently selected dependencies which have agreed upon/established
// the given network source
sel [ ] dependency
// The atom with the constraint that has the new, incompatible network source
prob atom
2016-05-03 16:47:48 +03:00
}
func ( e * sourceMismatchFailure ) Error ( ) string {
var cur [ ] string
for _ , c := range e . sel {
2016-07-09 07:18:22 +03:00
cur = append ( cur , string ( c . depender . id . ProjectRoot ) )
2016-05-03 16:47:48 +03:00
}
2016-07-21 20:16:38 +03:00
str := "Could not introduce %s, as it depends on %s from %s, but %s is already marked as coming from %s by %s"
return fmt . Sprintf ( str , a2vs ( e . prob ) , e . shared , e . mismatch , e . shared , e . current , strings . Join ( cur , ", " ) )
2016-05-03 16:47:48 +03:00
}
2016-05-04 22:30:16 +03:00
func ( e * sourceMismatchFailure ) traceString ( ) string {
var buf bytes . Buffer
fmt . Fprintf ( & buf , "disagreement on network addr for %s:\n" , e . shared )
2017-08-30 23:03:33 +03:00
fmt . Fprintf ( & buf , " %s from %s\n" , e . mismatch , e . prob . id )
2016-05-04 22:30:16 +03:00
for _ , dep := range e . sel {
2017-08-30 23:03:33 +03:00
fmt . Fprintf ( & buf , " %s from %s\n" , e . current , dep . depender . id )
2016-05-04 22:30:16 +03:00
}
return buf . String ( )
}
2016-06-22 05:56:01 +03:00
type errDeppers struct {
err error
2016-06-30 05:57:23 +03:00
deppers [ ] atom
2016-06-22 05:56:01 +03:00
}
2016-07-27 04:12:55 +03:00
// checkeeHasProblemPackagesFailure indicates that the goal atom was rejected
// because one or more of the packages required by its deppers had errors.
//
// "errors" includes package nonexistence, which is indicated by a nil err in
// the corresponding errDeppers failpkg map value.
2016-07-27 05:10:52 +03:00
//
// checkeeHasProblemPackagesFailure complements depHasProblemPackagesFailure;
// one or the other could appear to describe the same fundamental issue,
// depending on the order in which dependencies were visited.
2016-06-22 05:56:01 +03:00
type checkeeHasProblemPackagesFailure struct {
2016-07-27 04:12:55 +03:00
// goal is the atom that was rejected due to problematic packages.
goal atom
// failpkg is a map of package names to the error describing the problem
// with them, plus a list of the selected atoms that require that package.
2016-06-22 05:56:01 +03:00
failpkg map [ string ] errDeppers
}
func ( e * checkeeHasProblemPackagesFailure ) Error ( ) string {
var buf bytes . Buffer
indent := ""
if len ( e . failpkg ) > 1 {
indent = "\t"
fmt . Fprintf (
2016-07-21 20:16:38 +03:00
& buf , "Could not introduce %s due to multiple problematic subpackages:\n" ,
a2vs ( e . goal ) ,
2016-06-22 05:56:01 +03:00
)
}
for pkg , errdep := range e . failpkg {
var cause string
if errdep . err == nil {
cause = "is missing"
} else {
cause = fmt . Sprintf ( "does not contain usable Go code (%T)." , errdep . err )
}
if len ( e . failpkg ) == 1 {
fmt . Fprintf (
2016-07-21 20:16:38 +03:00
& buf , "Could not introduce %s, as its subpackage %s %s." ,
a2vs ( e . goal ) ,
2016-06-22 05:56:01 +03:00
pkg ,
cause ,
)
} else {
fmt . Fprintf ( & buf , "\tSubpackage %s %s." , pkg , cause )
}
if len ( errdep . deppers ) == 1 {
fmt . Fprintf (
2016-07-21 20:16:38 +03:00
& buf , " (Package is required by %s.)" ,
a2vs ( errdep . deppers [ 0 ] ) ,
2016-06-22 05:56:01 +03:00
)
} else {
fmt . Fprintf ( & buf , " Package is required by:" )
for _ , pa := range errdep . deppers {
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , "\n%s\t%s" , indent , a2vs ( pa ) )
2016-06-22 05:56:01 +03:00
}
}
}
return buf . String ( )
}
func ( e * checkeeHasProblemPackagesFailure ) traceString ( ) string {
var buf bytes . Buffer
2016-07-09 07:18:22 +03:00
fmt . Fprintf ( & buf , "%s at %s has problem subpkg(s):\n" , e . goal . id . ProjectRoot , e . goal . v )
2016-06-22 05:56:01 +03:00
for pkg , errdep := range e . failpkg {
if errdep . err == nil {
fmt . Fprintf ( & buf , "\t%s is missing; " , pkg )
} else {
fmt . Fprintf ( & buf , "\t%s has err (%T); " , pkg , errdep . err )
}
if len ( errdep . deppers ) == 1 {
2016-07-21 20:16:38 +03:00
fmt . Fprintf ( & buf , "required by %s." , a2vs ( errdep . deppers [ 0 ] ) )
2016-06-22 05:56:01 +03:00
} else {
fmt . Fprintf ( & buf , " required by:" )
for _ , pa := range errdep . deppers {
2017-08-30 23:03:33 +03:00
fmt . Fprintf ( & buf , "\n\t\t%s at %s" , pa . id , pa . v )
2016-06-22 05:56:01 +03:00
}
}
}
return buf . String ( )
}
2016-06-22 07:03:51 +03:00
2016-07-27 05:10:52 +03:00
// depHasProblemPackagesFailure indicates that the goal dependency was rejected
// because there were problems with one or more of the packages the dependency
// requires in the atom currently selected for that dependency. (This failure
// can only occur if the target dependency is already selected.)
//
// "errors" includes package nonexistence, which is indicated by a nil err as
// the corresponding prob map value.
//
// depHasProblemPackagesFailure complements checkeeHasProblemPackagesFailure;
// one or the other could appear to describe the same fundamental issue,
// depending on the order in which dependencies were visited.
2016-06-22 07:03:51 +03:00
type depHasProblemPackagesFailure struct {
2016-07-27 05:10:52 +03:00
// goal is the dependency that was rejected due to the atom currently
// selected for the dependency's target id having errors (including, and
// probably most commonly,
// nonexistence) in one or more packages named by the dependency.
2016-06-30 05:57:23 +03:00
goal dependency
2016-07-27 05:10:52 +03:00
// v is the version of the currently selected atom targeted by the goal
// dependency.
v Version
// prob is a map of problem packages to their specific error. It does not
// include missing packages.
2016-06-22 07:03:51 +03:00
prob map [ string ] error
}
func ( e * depHasProblemPackagesFailure ) Error ( ) string {
fcause := func ( pkg string ) string {
2016-07-27 05:10:52 +03:00
if err := e . prob [ pkg ] ; err != nil {
return fmt . Sprintf ( "does not contain usable Go code (%T)." , err )
2016-06-22 07:03:51 +03:00
}
2016-07-27 05:10:52 +03:00
return "is missing."
2016-06-22 07:03:51 +03:00
}
2016-07-27 05:10:52 +03:00
if len ( e . prob ) == 1 {
var pkg string
for pkg = range e . prob {
}
2016-06-22 07:03:51 +03:00
return fmt . Sprintf (
2016-07-21 20:16:38 +03:00
"Could not introduce %s, as it requires package %s from %s, but in version %s that package %s" ,
a2vs ( e . goal . depender ) ,
2016-07-27 05:10:52 +03:00
pkg ,
2017-08-30 23:03:33 +03:00
e . goal . dep . Ident ,
2016-06-22 07:03:51 +03:00
e . v ,
2016-07-27 05:10:52 +03:00
fcause ( pkg ) ,
2016-06-22 07:03:51 +03:00
)
}
var buf bytes . Buffer
fmt . Fprintf (
2016-07-21 20:16:38 +03:00
& buf , "Could not introduce %s, as it requires problematic packages from %s (current version %s):" ,
a2vs ( e . goal . depender ) ,
2017-08-30 23:03:33 +03:00
e . goal . dep . Ident ,
2016-06-22 07:03:51 +03:00
e . v ,
)
2016-07-27 05:10:52 +03:00
pkgs := make ( [ ] string , len ( e . prob ) )
k := 0
for pkg := range e . prob {
pkgs [ k ] = pkg
k ++
}
sort . Strings ( pkgs )
for _ , pkg := range pkgs {
2016-06-22 07:03:51 +03:00
fmt . Fprintf ( & buf , "\t%s %s" , pkg , fcause ( pkg ) )
}
return buf . String ( )
}
func ( e * depHasProblemPackagesFailure ) traceString ( ) string {
var buf bytes . Buffer
fcause := func ( pkg string ) string {
2016-07-27 05:10:52 +03:00
if err := e . prob [ pkg ] ; err != nil {
return fmt . Sprintf ( "has parsing err (%T)." , err )
2016-06-22 07:03:51 +03:00
}
2016-07-27 05:10:52 +03:00
return "is missing"
2016-06-22 07:03:51 +03:00
}
fmt . Fprintf (
2016-07-21 20:16:38 +03:00
& buf , "%s depping on %s at %s has problem subpkg(s):" ,
a2vs ( e . goal . depender ) ,
2017-08-30 23:03:33 +03:00
e . goal . dep . Ident ,
2016-06-22 07:03:51 +03:00
e . v ,
)
2016-07-27 05:10:52 +03:00
pkgs := make ( [ ] string , len ( e . prob ) )
k := 0
for pkg := range e . prob {
pkgs [ k ] = pkg
k ++
}
sort . Strings ( pkgs )
for _ , pkg := range pkgs {
2016-06-22 07:03:51 +03:00
fmt . Fprintf ( & buf , "\t%s %s" , pkg , fcause ( pkg ) )
}
return buf . String ( )
}
2016-07-06 06:53:33 +03:00
// nonexistentRevisionFailure indicates that a revision constraint was specified
// for a given project, but that that revision does not exist in the source
// repository.
type nonexistentRevisionFailure struct {
goal dependency
r Revision
}
func ( e * nonexistentRevisionFailure ) Error ( ) string {
return fmt . Sprintf (
2016-07-21 20:16:38 +03:00
"Could not introduce %s, as it requires %s at revision %s, but that revision does not exist" ,
a2vs ( e . goal . depender ) ,
2017-08-30 23:03:33 +03:00
e . goal . dep . Ident ,
2016-07-06 06:53:33 +03:00
e . r ,
)
}
func ( e * nonexistentRevisionFailure ) traceString ( ) string {
return fmt . Sprintf (
2016-07-21 20:16:38 +03:00
"%s wants missing rev %s of %s" ,
a2vs ( e . goal . depender ) ,
2016-07-06 06:53:33 +03:00
e . r ,
2017-08-30 23:03:33 +03:00
e . goal . dep . Ident ,
2016-07-06 06:53:33 +03:00
)
}