Fixes off-by-one error; rename method

This commit is contained in:
sam boyer 2017-08-31 01:14:10 -04:00
Родитель 5c96c1022c
Коммит 65c8f22216
3 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -217,6 +217,9 @@ type completeDep struct {
pl []string
}
// dependency represents an incomplete edge in the depgraph. It has a
// fully-realized atom as the depender (the tail/source of the edge), and a set
// of requirements that any atom to be attached at the head/target must satisfy.
type dependency struct {
depender atom
dep completeDep

Просмотреть файл

@ -54,7 +54,7 @@ func (s *solver) check(a atomWithPackages, pkgonly bool) error {
if err = s.checkIdentMatches(a, dep); err != nil {
return err
}
if err = s.checkCaseConflicts(a, dep); err != nil {
if err = s.checkRootCaseConflicts(a, dep); err != nil {
return err
}
if err = s.checkDepsConstraintsAllowable(a, dep); err != nil {
@ -221,19 +221,19 @@ func (s *solver) checkIdentMatches(a atomWithPackages, cdep completeDep) error {
return nil
}
// checkCaseConflicts ensures that the ProjectRoot specified in the completeDep
// checkRootCaseConflicts ensures that the ProjectRoot specified in the completeDep
// does not have case conflicts with any existing dependencies.
//
// We only need to check the ProjectRoot, rather than any packages therein, as
// the later check for package existence is case-sensitive.
func (s *solver) checkCaseConflicts(a atomWithPackages, cdep completeDep) error {
func (s *solver) checkRootCaseConflicts(a atomWithPackages, cdep completeDep) error {
pr := cdep.workingConstraint.Ident.ProjectRoot
hasConflict, current := s.sel.findCaseConflicts(pr)
if !hasConflict {
return nil
}
curid, _ := s.sel.getIdentFor(pr)
curid, _ := s.sel.getIdentFor(current)
deps := s.sel.getDependenciesOn(curid)
for _, d := range deps {
s.fail(d.depender.id)

Просмотреть файл

@ -83,11 +83,11 @@ func (s *selection) findCaseConflicts(pr ProjectRoot) (bool, ProjectRoot) {
func (s *selection) pushDep(dep dependency) {
pr := dep.dep.Ident.ProjectRoot
deps := s.deps[pr]
s.deps[pr] = append(deps, dep)
if len(deps) == 1 {
if len(deps) == 0 {
s.foldRoots[toFold(string(pr))] = pr
}
s.deps[pr] = append(deps, dep)
}
func (s *selection) popDep(id ProjectIdentifier) (dep dependency) {