Commit Graph

297 Commits

Author SHA1 Message Date
ekatek
27f7daa7f8 Merge branch 'master' into devel 2015-01-20 18:03:40 -08:00
ekatek
99124d881a increment package versions 2015-01-20 10:25:22 -08:00
David Greenspan
c71e495e10 Only test constraint-solver and PVP on server
You can still include them on the client, but they don’t work in
Safari 4 and IE 8 because semver.js uses ES 5 methods including
String#trim, Array#map/filter/forEach, and possibly others.

This should fix any unit test failures in these packages.
2015-01-15 22:15:23 -05:00
David Greenspan
c1556f250b remove old comment 2015-01-14 20:29:39 -08:00
ekatek
40fa95830f increment version numbers 2015-01-13 19:30:27 -08:00
David Greenspan
7f87518477 Unit test for upgrading indirect dependencies
This test is a more representative example of the new type of
PackagesResolver tests we can have now using CS.Input.
2015-01-13 13:42:45 -08:00
David Greenspan
bb573f9119 Reproduce slow version solving in a test
This unit test demonstrates 20-second solving time.  Thanks to the
CatalogCache abstraction, the data provided to the solver in the test
is exactly the data it gets when running the “meteor” command in a test
app with a bunch of packages in .meteor/packages and no .meteor/versions
file.

The test is hidden behind an environment variable:
CONSTRAINT_SOLVER_SLOW_TESTS
2015-01-13 11:03:51 -08:00
David Greenspan
4f473ff2d2 “meteor update” can update non-root dependencies
Previously, “meteor update foo” meant “ignore .meteor/versions for foo”,
which would upgrade if “foo” was a root dependency, and downgrade if foo
was only a transitive dependency.

Now, we make sure to try to upgrade foo even if it is not a root
dependency.

See #3282.
2015-01-13 09:34:50 -08:00
David Greenspan
16e74a8fe0 Constraint[List].isSatisfied doesn’t need resolver
More code simplification
2015-01-09 19:07:05 -08:00
David Greenspan
7bdc6ccdeb Create CS.Input and clean up resolver options
CS.Input is a serializable representation of the “problem.”  It includes
the arguments to PackagesResolver#resolve, and also the catalog data
loaded into the CatalogCache.  It’s independent of the solver, and
doesn’t even know about PackagesResolver or Resolver.

Along the way, get rid of the _testing and _debug flags.  “_testing”
came about to avoid running the real cost function on some of the unit
tests, but it doesn’t actually seem to matter anymore for correctness
or performance of the tests.  “_debug” was just used to enable some
console.logs, and possibly shouldn’t have been committed in the first
place.
2015-01-09 18:55:10 -08:00
David Greenspan
3447f85326 PackagesResolver: Delete line that does nothing 2015-01-09 16:42:41 -08:00
David Greenspan
4e3a8d9506 Clarify options to resolve(…) and Resolver
Don’t mutate the “options” object in PackageResolver#resolve, and don’t
pass it on to _getResolverOptions.

At this point, this is rearranging deck chairs on the Titanic, but
making this code more understandable helps me replace it.
2015-01-09 12:24:35 -08:00
David Greenspan
9d9dec602f Use the CatalogLoader in PackageResolver
PackageResolver no longer loads data from the Catalog.  Instead, it
tells CatalogLoader what to load, and it sets up the Resolver based
on what it finds in the CatalogCache.

PackageResolver now creates the Resolver inside resolve(…).  If the tool
were to invoke resolve(…) multiple times on the same PackageResolver
(which it doesn’t at the moment), the CatalogCache would persist, but
not the Resolver.  (Note that PackageResolver#resolve makes multiple
calls to the same Resolver#resolve internally.)

The purpose of this change is to stop using Resolver to store the
dependency graph.  Resolver will be replaced with a logic-solver-based
implementation that will not represent the graph as is, but instead
encode the graph as a satisfiability problem.  Meanwhile, CatalogCache
is better at storing the graph than Resolver was, because it is easy
to populate, query, and serialize.

This change brings us back to a functional “devel”.
2015-01-09 10:26:06 -08:00
David Greenspan
329227db53 CS.CatalogLoader 2015-01-08 16:25:42 -08:00
David Greenspan
2fbb1b9cb5 CS.CatalogCache and tests 2015-01-08 15:34:04 -08:00
David Greenspan
68e3cbe07f Dependency can take a String argument 2015-01-08 15:33:55 -08:00
David Greenspan
f8d2622235 Introduce CS.Dependency and CS.PackageAndVersion 2015-01-08 14:08:37 -08:00
David Greenspan
eb084ae60f Fix comment 2015-01-08 13:38:17 -08:00
David Greenspan
c99bad804b Document PackageConstraint form
…and commit a line I forgot
2015-01-07 20:14:42 -08:00
David Greenspan
e885e78348 Change the format returned by PVP.parseConstraint
This is a breaking change to package-version-parser.

A PackageConstraint used to look like this:

```
{ name: String,
  constraintString: String,
  constraints: [{version: String|null,
                 type: String}]}
```

Now it looks like this:
```
{ name: String,
  constraintString: String,
  vConstraint: {
    raw: String,
    alternatives: [{versionString: String|null,
                    type: String}]}}
```

Where (vConstraint instanceof VersionConstraint) and
(vConstraint.raw === constraintString).

This achieves several desirable changes at once.

* `constraint.constraints` for the disjuncts in “1.0.0||2.0.0”
  was confusing.  `alternatives` is better.
* Having a class for VersionConstraint will come in handy because
  we can add methods to it, and we can use it in the constraint
  solver to represent the problem statement.
* The names “vConstraint” and “versionString” are a little verbose,
  but there really shouldn’t be a lot of code that dives into this
  structure, and I really wanted to avoid anyone ever writing:
  `constraint.constraint.alternatives[0].version`, and then wondering
  what sort of object that was (not a parsed PackageVersion! we could
  parse eagerly but that might be slow).
2015-01-07 20:10:44 -08:00
David Greenspan
184ab3bde1 PV.parseConstraint returns a PackageConstraint
Mostly I just made parseConstraint clearer and gave the return value a
prototype.

There are new unit tests, and the existing ones have been given much
better names.

PV.parseConstraint also now optionally takes two arguments, a package name and a version constraint.  We can eventually propagate this feature to the tool and stop concatenating with “@” so much.

I’m referring to “foo@=1.0.0” as a PackageConstraint and “=1.0.0” as a version constraint.  I’ll probably add a VersionConstraint class too.
2015-01-07 19:04:55 -08:00
David Greenspan
a559d708ab Kill “removeBuildIDs” option to parseConstraint
It was only used in one place in resolver.js.  If the semantics of constraints are that buildIDs are ignored, that should be implemented when interpreting a constraint, not parsing it.  We don’t use buildIDs ourselves anymore, so it’s rather theoretical, but we’ve always stripped them out of constraint strings so it’s not even clear why we allow them at all — ie. why we are willing to parse “=1.0.0+foo” as a valid constraint and then throw away the “+foo”.

Bonus: One less place where we conflate two different options objects (utils.parseConstraint and PV.parseConstraint).
2015-01-07 15:52:06 -08:00
David Glasser
6b204ca73a Bump package versions for 1.0.2 2014-12-19 10:31:59 -08:00
David Glasser
73b809c122 Bump versions for 1.0.2. 2014-12-11 22:44:41 -08:00
David Glasser
0ed8a9b32d bump package versions for a test release 2014-12-10 14:50:11 -08:00
David Glasser
6ea8443f30 Update calls to addFiles, onUse, and onTest 2014-12-09 20:18:31 -08:00
David Glasser
2f90467da0 Optimize constraint solver's catalog interface
We shouldn't ask sqlite for a list of rows and then go back and ask for
each row one by one!

Addresses #3043.
2014-12-01 19:20:28 -08:00
David Glasser
de9536172e Fix anticipated pre-release calculation
This commit fixes a 0.9.3 regression where the calculation of the
topLevelPrereleases object was not updated with the introduction of
disjunction constraints (||) and would always be empty.

topLevelPrereleases and useRCsOK are merged into a single
anticipatedPrereleases option which is now passed in to the
constraint-solver package rather than constructed inside it. (This
object will also be used in ProjectContext as part of PackageDelta
calculation.)

The usedRCs return flag is now called
neededToUseUnanticipatedPrereleases.
2014-12-01 01:26:34 -08:00
David Glasser
de5f68cf70 bump all versions (due to source-map upgrade) 2014-11-25 09:06:26 -08:00
David Greenspan
b132dcb677 Minor changes to Resolver
There were too many things called `constraints` — ConstraintsList objects, arrays and maps of Constraint strings or objects… Also “alternatives” is already taken, so use “disjunction.”  Consider propagating this rename upstream to package-version-parser, since it’s kind of weird that “constraints” is implicitly a disjunction (rather than, say, a conjunction).

Don’t call a constraint string a version string.
2014-11-24 17:16:33 -08:00
David Greenspan
29fb67931b Clean up logic around pre-releases in solver
When it comes to pre-releases, Constraints aren’t “context-free.”  That’s ok for now, but at least hoist the pre-release check out of the innermost loop.  Ideally we’d hoist it higher, but I can see that it’s pretty convenient this way.

Should be identical in behavior to before (differing maybe in some super edge case, but I doubt it).
2014-11-24 15:28:06 -08:00
David Greenspan
fee326899a Remove unreachable case in Constraint#isSatisfied 2014-11-24 14:25:48 -08:00
David Greenspan
9a4428bf6e Don’t support #arch when parsing a constraint 2014-11-22 17:29:54 -08:00
David Glasser
fb6b39d956 explicitly search for non-weak dep
dep.references ought to never be empty, but if it is we should consider
that to not be a dependency!
2014-11-22 14:20:57 -08:00
David Glasser
cec75e527c constraint edges are by package, not unibuild
Consider the following situation:

  - app uses package P
  - Every version of P contains `api.use('s', 'server')`
  - Every version of S contains `api.use('c', 'client')`
  - There's nothing else around using S or C

When we bundle our app, we will not end up putting any unibuilds from C
into the bundle. That's fine.

The previous version of the constraint solver understood this, and so C
wasn't even part of the constraint solver solution.

HOWEVER, even though C does not contribute any unibuilds to the app
bundle, we still need to compile C in order to compile S. That's because
our current implementation never compiles only part of an isopack, even
if only part of the isopack will be needed for the app.

The structured project initialization done via ProjectContext will thus
decide to not build or load C, which will make it fail to compile S when
it gets around to compiling the client unibuilds in S.

We could make the model more complex by making it possible to compile
only part of S.

Instead, we'll make the Meteor package model simpler.  Constraints, as
far as the constraint solver is concerned, are now at a package level.
So in this case, "C" will actually be part of the project (will end up
in .meteor/versions, etc) even though it will continue to not provide
any part of any of the bundled client or server programs.

This means that nodes in the constraint solver's graph will now just be
package versions, not unibuild versions.  That's already the language
that the constraint solver spoke in as far as its inputs, outputs, and
error messages were concerned!

An example of an app that couldn't be built on the isopack-cache branch
before this commit and can be now is
  https://github.com/glasser/precise-constraints-example
(It can be built with 1.0, but only by compiling a version of `c` that
isn't part of .meteor/versions!)

Note that this also means that .meteor/versions expresses enough to
allow us to implement a simpler constraint check that doesn't need to do
the full tree walk of the constraint solver.  Such a checker would be
implemented as:

  - gather root dependencies and constraints (project constraints,
    release constraints, etc)
  - add the dependencies and constraints from all versions mentioned
    in .meteor/versions
  - see if the choices made in .meteor/versions satisfy these
    dependencies and constraints

This algorithm did NOT work previously, because you couldn't just look
at the constraints coming from `s@0.0.0` and say "they're satifisfied"
because you had to know to "ignore" the constraint on c#web.browser
because s#web.browser is not part of the app, which is not a fact that
actually got recorded in .meteor/versions.

(This commit does not implement this simpler constraint check, though.)
2014-11-22 14:20:39 -08:00
David Greenspan
b1ba8c3a64 Fix comment in resolver 2014-11-21 12:43:01 -08:00
David Greenspan
34b1f5b428 Add a simple test around build IDS 2014-11-14 23:53:17 -08:00
David Greenspan
f8783d4461 Remove unnecessary parts of Catalog stubs 2014-11-14 22:34:34 -08:00
David Greenspan
49533d35ca Comment more about benchmark data 2014-11-14 21:58:09 -08:00
David Greenspan
0d80637f05 Remove unnecessary code in benchmark tests 2014-11-14 21:47:34 -08:00
David Greenspan
5253e2b9ac Merge branch 'devel' into fix-gems-benchmark
Conflicts:
	packages/constraint-solver/constraint-solver-tests.js
2014-11-14 21:37:15 -08:00
David Greenspan
995b8477b4 Simulate non-semver >= using alternations
The original benchmark/test translated all constraints into either inexact or exact Meteor constraints — that is, Rails’s `~>1.2.3`, `>1.2.3`, and `>=1.2.3` became the inexact `1.2.3`, and `=1.2.3` became `=1.2.3` — but also gave all versions of all packages an ECV of 0.0.0, meaning all versions are compatible with each other.

In order to make this test pass without ECV, we need to emulate pure `>=` (without incompatibility between major versions) in some other way.  So, for each constraint of the form `foo@a.b.c` where `foo` has larger major versions available than `a`, we allow those major versions as well.  For example, if we depend on `foo@1.1.11` and the largest version of `foo` is `3.2.0`, we rewrite `1.1.11` to `1.1.11 || 2.0.0 || 3.0.0` in order to emulate a pure `>=1.1.11` with no concern for major version compatibility.
2014-11-14 21:32:30 -08:00
David Greenspan
10fd23cc99 Revert accidental committal of client test-data
Client should not get test-data right now; that was just for debugging.
2014-11-14 16:28:47 -08:00
David Greenspan
95cdfc5662 Remove or translate all “numbers” besides a.b.c
in test-data.  Importantly, tests still pass!

For example:
- Convert 1.2 to 1.2.0
- Convert 1.2.0.0 to 1.2.0
- Remove 1.2.0.1 completely
- Remove all rcs, betas, alphas, pres, etc.

Remove unused “platform” property.

Next step: Make the test not depend on setting ECVs in order to pass.
2014-11-14 16:26:57 -08:00
David Greenspan
7f695a2c4a Pre-convert all constraints 2014-11-14 14:40:20 -08:00
David Greenspan
f3c420e350 Move benchmark tests to own file, add comments 2014-11-14 13:35:05 -08:00
David Greenspan
8fd3b98368 Merge branch 'constraint-explorer' into devel 2014-11-14 13:03:20 -08:00
David Greenspan
1094c62e32 Clean up branch for merge
Disable new test until we “fix” it (make it break)
2014-11-14 13:00:23 -08:00
David Glasser
dde817ea10 Include missing test change 2014-11-10 15:10:20 -08:00
David Glasser
3444b9a6d3 Remove support for earliestCompatibleVersion
This was an undocumented and entirely unused feature (only two dummy
packages on the package server have this set to a non-default value).

No attempt is being made to remove the field from existing isopacks or
catalog entries. To continue to support existing clients, the package
server has been modified to ignore any provided
earliestCompatibleVersion and instead always write the default ECV to
the catalog.
2014-11-10 13:33:41 -08:00