bundler 2.2.29 → 2.5.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1129 -4
- data/README.md +4 -8
- data/bundler.gemspec +11 -11
- data/exe/bundle +5 -26
- data/exe/bundler +1 -1
- data/lib/bundler/.document +1 -0
- data/lib/bundler/build_metadata.rb +4 -4
- data/lib/bundler/capistrano.rb +1 -1
- data/lib/bundler/checksum.rb +254 -0
- data/lib/bundler/ci_detector.rb +75 -0
- data/lib/bundler/cli/add.rb +4 -4
- data/lib/bundler/cli/binstubs.rb +10 -6
- data/lib/bundler/cli/cache.rb +1 -1
- data/lib/bundler/cli/check.rb +3 -3
- data/lib/bundler/cli/common.rb +13 -3
- data/lib/bundler/cli/config.rb +18 -8
- data/lib/bundler/cli/console.rb +5 -4
- data/lib/bundler/cli/doctor.rb +12 -5
- data/lib/bundler/cli/exec.rb +1 -1
- data/lib/bundler/cli/fund.rb +1 -1
- data/lib/bundler/cli/gem.rb +141 -48
- data/lib/bundler/cli/info.rb +27 -17
- data/lib/bundler/cli/init.rb +6 -2
- data/lib/bundler/cli/install.rb +22 -39
- data/lib/bundler/cli/issue.rb +5 -4
- data/lib/bundler/cli/lock.rb +36 -29
- data/lib/bundler/cli/open.rb +9 -9
- data/lib/bundler/cli/outdated.rb +19 -12
- data/lib/bundler/cli/platform.rb +8 -6
- data/lib/bundler/cli/plugin.rb +9 -15
- data/lib/bundler/cli/pristine.rb +38 -30
- data/lib/bundler/cli/show.rb +3 -3
- data/lib/bundler/cli/update.rb +12 -7
- data/lib/bundler/cli/viz.rb +1 -1
- data/lib/bundler/cli.rb +266 -285
- data/lib/bundler/compact_index_client/cache.rb +53 -67
- data/lib/bundler/compact_index_client/cache_file.rb +153 -0
- data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
- data/lib/bundler/compact_index_client/parser.rb +84 -0
- data/lib/bundler/compact_index_client/updater.rb +83 -76
- data/lib/bundler/compact_index_client.rb +59 -87
- data/lib/bundler/constants.rb +9 -2
- data/lib/bundler/current_ruby.rb +12 -16
- data/lib/bundler/definition.rb +509 -319
- data/lib/bundler/dependency.rb +33 -71
- data/lib/bundler/digest.rb +71 -0
- data/lib/bundler/dsl.rb +88 -69
- data/lib/bundler/endpoint_specification.rb +32 -15
- data/lib/bundler/env.rb +5 -7
- data/lib/bundler/environment_preserver.rb +8 -22
- data/lib/bundler/errors.rb +101 -13
- data/lib/bundler/feature_flag.rb +0 -2
- data/lib/bundler/fetcher/base.rb +11 -11
- data/lib/bundler/fetcher/compact_index.rb +32 -52
- data/lib/bundler/fetcher/dependency.rb +3 -7
- data/lib/bundler/fetcher/downloader.rb +17 -16
- data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
- data/lib/bundler/fetcher/index.rb +2 -29
- data/lib/bundler/fetcher.rb +87 -79
- data/lib/bundler/force_platform.rb +18 -0
- data/lib/bundler/friendly_errors.rb +29 -40
- data/lib/bundler/gem_helper.rb +11 -23
- data/lib/bundler/gem_helpers.rb +30 -6
- data/lib/bundler/gem_version_promoter.rb +68 -109
- data/lib/bundler/graph.rb +9 -9
- data/lib/bundler/index.rb +71 -79
- data/lib/bundler/injector.rb +23 -11
- data/lib/bundler/inline.rb +11 -23
- data/lib/bundler/installer/gem_installer.rb +18 -11
- data/lib/bundler/installer/parallel_installer.rb +17 -65
- data/lib/bundler/installer/standalone.rb +56 -15
- data/lib/bundler/installer.rb +35 -61
- data/lib/bundler/lazy_specification.rb +92 -61
- data/lib/bundler/lockfile_generator.rb +12 -3
- data/lib/bundler/lockfile_parser.rb +137 -70
- data/lib/bundler/man/bundle-add.1 +19 -26
- data/lib/bundler/man/bundle-add.1.ronn +16 -4
- data/lib/bundler/man/bundle-binstubs.1 +4 -16
- data/lib/bundler/man/bundle-cache.1 +9 -24
- data/lib/bundler/man/bundle-cache.1.ronn +9 -2
- data/lib/bundler/man/bundle-check.1 +5 -12
- data/lib/bundler/man/bundle-check.1.ronn +3 -0
- data/lib/bundler/man/bundle-clean.1 +4 -11
- data/lib/bundler/man/bundle-clean.1.ronn +1 -1
- data/lib/bundler/man/bundle-config.1 +47 -224
- data/lib/bundler/man/bundle-config.1.ronn +40 -28
- data/lib/bundler/man/bundle-console.1 +35 -0
- data/lib/bundler/man/bundle-console.1.ronn +44 -0
- data/lib/bundler/man/bundle-doctor.1 +4 -18
- data/lib/bundler/man/bundle-exec.1 +16 -77
- data/lib/bundler/man/bundle-exec.1.ronn +8 -9
- data/lib/bundler/man/bundle-gem.1 +45 -72
- data/lib/bundler/man/bundle-gem.1.ronn +32 -5
- data/lib/bundler/man/bundle-help.1 +9 -0
- data/lib/bundler/man/bundle-help.1.ronn +12 -0
- data/lib/bundler/man/bundle-info.1 +5 -11
- data/lib/bundler/man/bundle-info.1.ronn +3 -3
- data/lib/bundler/man/bundle-init.1 +6 -11
- data/lib/bundler/man/bundle-init.1.ronn +2 -0
- data/lib/bundler/man/bundle-inject.1 +8 -18
- data/lib/bundler/man/bundle-inject.1.ronn +3 -1
- data/lib/bundler/man/bundle-install.1 +32 -155
- data/lib/bundler/man/bundle-install.1.ronn +11 -33
- data/lib/bundler/man/bundle-list.1 +4 -19
- data/lib/bundler/man/bundle-lock.1 +5 -29
- data/lib/bundler/man/bundle-open.1 +18 -18
- data/lib/bundler/man/bundle-open.1.ronn +9 -1
- data/lib/bundler/man/bundle-outdated.1 +17 -72
- data/lib/bundler/man/bundle-outdated.1.ronn +13 -18
- data/lib/bundler/man/bundle-platform.1 +16 -28
- data/lib/bundler/man/bundle-platform.1.ronn +14 -7
- data/lib/bundler/man/bundle-plugin.1 +58 -0
- data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
- data/lib/bundler/man/bundle-pristine.1 +5 -16
- data/lib/bundler/man/bundle-remove.1 +4 -14
- data/lib/bundler/man/bundle-show.1 +3 -10
- data/lib/bundler/man/bundle-update.1 +19 -138
- data/lib/bundler/man/bundle-update.1.ronn +2 -1
- data/lib/bundler/man/bundle-version.1 +22 -0
- data/lib/bundler/man/bundle-version.1.ronn +24 -0
- data/lib/bundler/man/bundle-viz.1 +6 -15
- data/lib/bundler/man/bundle-viz.1.ronn +2 -0
- data/lib/bundler/man/bundle.1 +17 -51
- data/lib/bundler/man/bundle.1.ronn +12 -7
- data/lib/bundler/man/gemfile.5 +130 -346
- data/lib/bundler/man/gemfile.5.ronn +121 -86
- data/lib/bundler/man/index.txt +4 -0
- data/lib/bundler/match_metadata.rb +17 -0
- data/lib/bundler/match_platform.rb +1 -2
- data/lib/bundler/match_remote_metadata.rb +29 -0
- data/lib/bundler/mirror.rb +8 -10
- data/lib/bundler/plugin/api/source.rb +9 -13
- data/lib/bundler/plugin/index.rb +13 -5
- data/lib/bundler/plugin/installer/git.rb +0 -4
- data/lib/bundler/plugin/installer/path.rb +18 -0
- data/lib/bundler/plugin/installer/rubygems.rb +0 -8
- data/lib/bundler/plugin/installer.rb +42 -19
- data/lib/bundler/plugin/source_list.rb +4 -4
- data/lib/bundler/plugin.rb +16 -7
- data/lib/bundler/process_lock.rb +1 -1
- data/lib/bundler/remote_specification.rb +11 -5
- data/lib/bundler/resolver/base.rb +111 -0
- data/lib/bundler/resolver/candidate.rb +82 -0
- data/lib/bundler/resolver/incompatibility.rb +15 -0
- data/lib/bundler/resolver/package.rb +81 -0
- data/lib/bundler/resolver/root.rb +25 -0
- data/lib/bundler/resolver/spec_group.rb +53 -66
- data/lib/bundler/resolver.rb +419 -307
- data/lib/bundler/retry.rb +1 -1
- data/lib/bundler/ruby_dsl.rb +42 -7
- data/lib/bundler/ruby_version.rb +16 -22
- data/lib/bundler/rubygems_ext.rb +250 -64
- data/lib/bundler/rubygems_gem_installer.rb +90 -64
- data/lib/bundler/rubygems_integration.rb +81 -190
- data/lib/bundler/runtime.rb +8 -13
- data/lib/bundler/safe_marshal.rb +31 -0
- data/lib/bundler/self_manager.rb +206 -0
- data/lib/bundler/settings.rb +139 -57
- data/lib/bundler/setup.rb +13 -1
- data/lib/bundler/shared_helpers.rb +67 -36
- data/lib/bundler/source/git/git_proxy.rb +285 -82
- data/lib/bundler/source/git.rb +81 -41
- data/lib/bundler/source/metadata.rb +17 -16
- data/lib/bundler/source/path/installer.rb +1 -22
- data/lib/bundler/source/path.rb +13 -25
- data/lib/bundler/source/rubygems/remote.rb +1 -1
- data/lib/bundler/source/rubygems.rb +164 -234
- data/lib/bundler/source/rubygems_aggregate.rb +1 -1
- data/lib/bundler/source.rb +7 -6
- data/lib/bundler/source_list.rb +40 -32
- data/lib/bundler/source_map.rb +15 -2
- data/lib/bundler/spec_set.rb +156 -46
- data/lib/bundler/stub_specification.rb +18 -5
- data/lib/bundler/templates/Executable +3 -5
- data/lib/bundler/templates/Executable.bundler +7 -12
- data/lib/bundler/templates/Executable.standalone +4 -4
- data/lib/bundler/templates/Gemfile +0 -2
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
- data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
- data/lib/bundler/templates/newgem/README.md.tt +7 -11
- data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
- data/lib/bundler/templates/newgem/bin/console.tt +0 -4
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +13 -3
- data/lib/bundler/templates/newgem/gitignore.tt +3 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +25 -17
- data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
- data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
- data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
- data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +38 -15
- data/lib/bundler/ui/silent.rb +21 -5
- data/lib/bundler/uri_credentials_filter.rb +2 -2
- data/lib/bundler/uri_normalizer.rb +23 -0
- data/lib/bundler/vendor/.document +1 -0
- data/lib/bundler/vendor/connection_pool/.document +1 -0
- data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
- data/lib/bundler/vendor/fileutils/.document +1 -0
- data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1340 -410
- data/lib/bundler/vendor/net-http-persistent/.document +1 -0
- data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +57 -57
- data/lib/bundler/vendor/pub_grub/.document +1 -0
- data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
- data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
- data/lib/bundler/vendor/thor/.document +1 -0
- data/lib/bundler/vendor/thor/LICENSE.md +20 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +12 -14
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
- data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
- data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +20 -1
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +27 -8
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +63 -7
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +48 -154
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
- data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +0 -45
- data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +134 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +155 -8
- data/lib/bundler/vendor/tsort/.document +1 -0
- data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
- data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
- data/lib/bundler/vendor/uri/.document +1 -0
- data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +316 -207
- data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +33 -13
- data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
- data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +105 -47
- data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
- data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
- data/lib/bundler/vendored_net_http.rb +23 -0
- data/lib/bundler/vendored_persistent.rb +0 -36
- data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
- data/lib/bundler/vendored_timeout.rb +12 -0
- data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
- data/lib/bundler/vendored_uri.rb +18 -1
- data/lib/bundler/version.rb +5 -1
- data/lib/bundler/vlad.rb +1 -1
- data/lib/bundler/worker.rb +7 -9
- data/lib/bundler/yaml_serializer.rb +21 -12
- data/lib/bundler.rb +114 -121
- metadata +87 -41
- data/lib/bundler/dep_proxy.rb +0 -55
- data/lib/bundler/gemdeps.rb +0 -29
- data/lib/bundler/psyched_yaml.rb +0 -22
- data/lib/bundler/templates/gems.rb +0 -8
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
- data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
- data/lib/bundler/version_ranges.rb +0 -122
@@ -0,0 +1,189 @@
|
|
1
|
+
require_relative 'version_constraint'
|
2
|
+
require_relative 'incompatibility'
|
3
|
+
|
4
|
+
module Bundler::PubGrub
|
5
|
+
# Types:
|
6
|
+
#
|
7
|
+
# Where possible, Bundler::PubGrub will accept user-defined types, so long as they quack.
|
8
|
+
#
|
9
|
+
# ## "Package":
|
10
|
+
#
|
11
|
+
# This class will be used to represent the various packages being solved for.
|
12
|
+
# .to_s will be called when displaying errors and debugging info, it should
|
13
|
+
# probably return the package's name.
|
14
|
+
# It must also have a reasonable definition of #== and #hash
|
15
|
+
#
|
16
|
+
# Example classes: String ("rails")
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# ## "Version":
|
20
|
+
#
|
21
|
+
# This class will be used to represent a single version number.
|
22
|
+
#
|
23
|
+
# Versions don't need to store their associated package, however they will
|
24
|
+
# only be compared against other versions of the same package.
|
25
|
+
#
|
26
|
+
# It must be Comparible (and implement <=> reasonably)
|
27
|
+
#
|
28
|
+
# Example classes: Gem::Version, Integer
|
29
|
+
#
|
30
|
+
#
|
31
|
+
# ## "Dependency"
|
32
|
+
#
|
33
|
+
# This class represents the requirement one package has on another. It is
|
34
|
+
# returned by dependencies_for(package, version) and will be passed to
|
35
|
+
# parse_dependency to convert it to a format Bundler::PubGrub understands.
|
36
|
+
#
|
37
|
+
# It must also have a reasonable definition of #==
|
38
|
+
#
|
39
|
+
# Example classes: String ("~> 1.0"), Gem::Requirement
|
40
|
+
#
|
41
|
+
class BasicPackageSource
|
42
|
+
# Override me!
|
43
|
+
#
|
44
|
+
# This is called per package to find all possible versions of a package.
|
45
|
+
#
|
46
|
+
# It is called at most once per-package
|
47
|
+
#
|
48
|
+
# Returns: Array of versions for a package, in preferred order of selection
|
49
|
+
def all_versions_for(package)
|
50
|
+
raise NotImplementedError
|
51
|
+
end
|
52
|
+
|
53
|
+
# Override me!
|
54
|
+
#
|
55
|
+
# Returns: Hash in the form of { package => requirement, ... }
|
56
|
+
def dependencies_for(package, version)
|
57
|
+
raise NotImplementedError
|
58
|
+
end
|
59
|
+
|
60
|
+
# Override me!
|
61
|
+
#
|
62
|
+
# Convert a (user-defined) dependency into a format Bundler::PubGrub understands.
|
63
|
+
#
|
64
|
+
# Package is passed to this method but for many implementations is not
|
65
|
+
# needed.
|
66
|
+
#
|
67
|
+
# Returns: either a Bundler::PubGrub::VersionRange, Bundler::PubGrub::VersionUnion, or a
|
68
|
+
# Bundler::PubGrub::VersionConstraint
|
69
|
+
def parse_dependency(package, dependency)
|
70
|
+
raise NotImplementedError
|
71
|
+
end
|
72
|
+
|
73
|
+
# Override me!
|
74
|
+
#
|
75
|
+
# If not overridden, this will call dependencies_for with the root package.
|
76
|
+
#
|
77
|
+
# Returns: Hash in the form of { package => requirement, ... } (see dependencies_for)
|
78
|
+
def root_dependencies
|
79
|
+
dependencies_for(@root_package, @root_version)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Override me (maybe)
|
83
|
+
#
|
84
|
+
# If not overridden, the order returned by all_versions_for will be used
|
85
|
+
#
|
86
|
+
# Returns: Array of versions in preferred order
|
87
|
+
def sort_versions_by_preferred(package, sorted_versions)
|
88
|
+
indexes = @version_indexes[package]
|
89
|
+
sorted_versions.sort_by { |version| indexes[version] }
|
90
|
+
end
|
91
|
+
|
92
|
+
def initialize
|
93
|
+
@root_package = Package.root
|
94
|
+
@root_version = Package.root_version
|
95
|
+
|
96
|
+
@cached_versions = Hash.new do |h,k|
|
97
|
+
if k == @root_package
|
98
|
+
h[k] = [@root_version]
|
99
|
+
else
|
100
|
+
h[k] = all_versions_for(k)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
@sorted_versions = Hash.new { |h,k| h[k] = @cached_versions[k].sort }
|
104
|
+
@version_indexes = Hash.new { |h,k| h[k] = @cached_versions[k].each.with_index.to_h }
|
105
|
+
|
106
|
+
@cached_dependencies = Hash.new do |packages, package|
|
107
|
+
if package == @root_package
|
108
|
+
packages[package] = {
|
109
|
+
@root_version => root_dependencies
|
110
|
+
}
|
111
|
+
else
|
112
|
+
packages[package] = Hash.new do |versions, version|
|
113
|
+
versions[version] = dependencies_for(package, version)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def versions_for(package, range=VersionRange.any)
|
120
|
+
versions = range.select_versions(@sorted_versions[package])
|
121
|
+
|
122
|
+
# Conditional avoids (among other things) calling
|
123
|
+
# sort_versions_by_preferred with the root package
|
124
|
+
if versions.size > 1
|
125
|
+
sort_versions_by_preferred(package, versions)
|
126
|
+
else
|
127
|
+
versions
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def no_versions_incompatibility_for(_package, unsatisfied_term)
|
132
|
+
cause = Incompatibility::NoVersions.new(unsatisfied_term)
|
133
|
+
|
134
|
+
Incompatibility.new([unsatisfied_term], cause: cause)
|
135
|
+
end
|
136
|
+
|
137
|
+
def incompatibilities_for(package, version)
|
138
|
+
package_deps = @cached_dependencies[package]
|
139
|
+
sorted_versions = @sorted_versions[package]
|
140
|
+
package_deps[version].map do |dep_package, dep_constraint_name|
|
141
|
+
low = high = sorted_versions.index(version)
|
142
|
+
|
143
|
+
# find version low such that all >= low share the same dep
|
144
|
+
while low > 0 &&
|
145
|
+
package_deps[sorted_versions[low - 1]][dep_package] == dep_constraint_name
|
146
|
+
low -= 1
|
147
|
+
end
|
148
|
+
low =
|
149
|
+
if low == 0
|
150
|
+
nil
|
151
|
+
else
|
152
|
+
sorted_versions[low]
|
153
|
+
end
|
154
|
+
|
155
|
+
# find version high such that all < high share the same dep
|
156
|
+
while high < sorted_versions.length &&
|
157
|
+
package_deps[sorted_versions[high]][dep_package] == dep_constraint_name
|
158
|
+
high += 1
|
159
|
+
end
|
160
|
+
high =
|
161
|
+
if high == sorted_versions.length
|
162
|
+
nil
|
163
|
+
else
|
164
|
+
sorted_versions[high]
|
165
|
+
end
|
166
|
+
|
167
|
+
range = VersionRange.new(min: low, max: high, include_min: true)
|
168
|
+
|
169
|
+
self_constraint = VersionConstraint.new(package, range: range)
|
170
|
+
|
171
|
+
if !@packages.include?(dep_package)
|
172
|
+
# no such package -> this version is invalid
|
173
|
+
end
|
174
|
+
|
175
|
+
dep_constraint = parse_dependency(dep_package, dep_constraint_name)
|
176
|
+
if !dep_constraint
|
177
|
+
# falsey indicates this dependency was invalid
|
178
|
+
cause = Bundler::PubGrub::Incompatibility::InvalidDependency.new(dep_package, dep_constraint_name)
|
179
|
+
return [Incompatibility.new([Term.new(self_constraint, true)], cause: cause)]
|
180
|
+
elsif !dep_constraint.is_a?(VersionConstraint)
|
181
|
+
# Upgrade range/union to VersionConstraint
|
182
|
+
dep_constraint = VersionConstraint.new(dep_package, range: dep_constraint)
|
183
|
+
end
|
184
|
+
|
185
|
+
Incompatibility.new([Term.new(self_constraint, true), Term.new(dep_constraint, false)], cause: :dependency)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
module Bundler::PubGrub
|
2
|
+
class FailureWriter
|
3
|
+
def initialize(root)
|
4
|
+
@root = root
|
5
|
+
|
6
|
+
# { Incompatibility => Integer }
|
7
|
+
@derivations = {}
|
8
|
+
|
9
|
+
# [ [ String, Integer or nil ] ]
|
10
|
+
@lines = []
|
11
|
+
|
12
|
+
# { Incompatibility => Integer }
|
13
|
+
@line_numbers = {}
|
14
|
+
|
15
|
+
count_derivations(root)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write
|
19
|
+
return @root.to_s unless @root.conflict?
|
20
|
+
|
21
|
+
visit(@root)
|
22
|
+
|
23
|
+
padding = @line_numbers.empty? ? 0 : "(#{@line_numbers.values.last}) ".length
|
24
|
+
|
25
|
+
@lines.map do |message, number|
|
26
|
+
next "" if message.empty?
|
27
|
+
|
28
|
+
lead = number ? "(#{number}) " : ""
|
29
|
+
lead = lead.ljust(padding)
|
30
|
+
message = message.gsub("\n", "\n" + " " * (padding + 2))
|
31
|
+
"#{lead}#{message}"
|
32
|
+
end.join("\n")
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def write_line(incompatibility, message, numbered:)
|
38
|
+
if numbered
|
39
|
+
number = @line_numbers.length + 1
|
40
|
+
@line_numbers[incompatibility] = number
|
41
|
+
end
|
42
|
+
|
43
|
+
@lines << [message, number]
|
44
|
+
end
|
45
|
+
|
46
|
+
def visit(incompatibility, conclusion: false)
|
47
|
+
raise unless incompatibility.conflict?
|
48
|
+
|
49
|
+
numbered = conclusion || @derivations[incompatibility] > 1;
|
50
|
+
conjunction = conclusion || incompatibility == @root ? "So," : "And"
|
51
|
+
|
52
|
+
cause = incompatibility.cause
|
53
|
+
|
54
|
+
if cause.conflict.conflict? && cause.other.conflict?
|
55
|
+
conflict_line = @line_numbers[cause.conflict]
|
56
|
+
other_line = @line_numbers[cause.other]
|
57
|
+
|
58
|
+
if conflict_line && other_line
|
59
|
+
write_line(
|
60
|
+
incompatibility,
|
61
|
+
"Because #{cause.conflict} (#{conflict_line})\nand #{cause.other} (#{other_line}),\n#{incompatibility}.",
|
62
|
+
numbered: numbered
|
63
|
+
)
|
64
|
+
elsif conflict_line || other_line
|
65
|
+
with_line = conflict_line ? cause.conflict : cause.other
|
66
|
+
without_line = conflict_line ? cause.other : cause.conflict
|
67
|
+
line = @line_numbers[with_line]
|
68
|
+
|
69
|
+
visit(without_line);
|
70
|
+
write_line(
|
71
|
+
incompatibility,
|
72
|
+
"#{conjunction} because #{with_line} (#{line}),\n#{incompatibility}.",
|
73
|
+
numbered: numbered
|
74
|
+
)
|
75
|
+
else
|
76
|
+
single_line_conflict = single_line?(cause.conflict.cause)
|
77
|
+
single_line_other = single_line?(cause.other.cause)
|
78
|
+
|
79
|
+
if single_line_conflict || single_line_other
|
80
|
+
first = single_line_other ? cause.conflict : cause.other
|
81
|
+
second = single_line_other ? cause.other : cause.conflict
|
82
|
+
visit(first)
|
83
|
+
visit(second)
|
84
|
+
write_line(
|
85
|
+
incompatibility,
|
86
|
+
"Thus, #{incompatibility}.",
|
87
|
+
numbered: numbered
|
88
|
+
)
|
89
|
+
else
|
90
|
+
visit(cause.conflict, conclusion: true)
|
91
|
+
@lines << ["", nil]
|
92
|
+
visit(cause.other)
|
93
|
+
|
94
|
+
write_line(
|
95
|
+
incompatibility,
|
96
|
+
"#{conjunction} because #{cause.conflict} (#{@line_numbers[cause.conflict]}),\n#{incompatibility}.",
|
97
|
+
numbered: numbered
|
98
|
+
)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
elsif cause.conflict.conflict? || cause.other.conflict?
|
102
|
+
derived = cause.conflict.conflict? ? cause.conflict : cause.other
|
103
|
+
ext = cause.conflict.conflict? ? cause.other : cause.conflict
|
104
|
+
|
105
|
+
derived_line = @line_numbers[derived]
|
106
|
+
if derived_line
|
107
|
+
write_line(
|
108
|
+
incompatibility,
|
109
|
+
"Because #{ext}\nand #{derived} (#{derived_line}),\n#{incompatibility}.",
|
110
|
+
numbered: numbered
|
111
|
+
)
|
112
|
+
elsif collapsible?(derived)
|
113
|
+
derived_cause = derived.cause
|
114
|
+
if derived_cause.conflict.conflict?
|
115
|
+
collapsed_derived = derived_cause.conflict
|
116
|
+
collapsed_ext = derived_cause.other
|
117
|
+
else
|
118
|
+
collapsed_derived = derived_cause.other
|
119
|
+
collapsed_ext = derived_cause.conflict
|
120
|
+
end
|
121
|
+
|
122
|
+
visit(collapsed_derived)
|
123
|
+
|
124
|
+
write_line(
|
125
|
+
incompatibility,
|
126
|
+
"#{conjunction} because #{collapsed_ext}\nand #{ext},\n#{incompatibility}.",
|
127
|
+
numbered: numbered
|
128
|
+
)
|
129
|
+
else
|
130
|
+
visit(derived)
|
131
|
+
write_line(
|
132
|
+
incompatibility,
|
133
|
+
"#{conjunction} because #{ext},\n#{incompatibility}.",
|
134
|
+
numbered: numbered
|
135
|
+
)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
write_line(
|
139
|
+
incompatibility,
|
140
|
+
"Because #{cause.conflict}\nand #{cause.other},\n#{incompatibility}.",
|
141
|
+
numbered: numbered
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def single_line?(cause)
|
147
|
+
!cause.conflict.conflict? && !cause.other.conflict?
|
148
|
+
end
|
149
|
+
|
150
|
+
def collapsible?(incompatibility)
|
151
|
+
return false if @derivations[incompatibility] > 1
|
152
|
+
|
153
|
+
cause = incompatibility.cause
|
154
|
+
# If incompatibility is derived from two derived incompatibilities,
|
155
|
+
# there are too many transitive causes to display concisely.
|
156
|
+
return false if cause.conflict.conflict? && cause.other.conflict?
|
157
|
+
|
158
|
+
# If incompatibility is derived from two external incompatibilities, it
|
159
|
+
# tends to be confusing to collapse it.
|
160
|
+
return false unless cause.conflict.conflict? || cause.other.conflict?
|
161
|
+
|
162
|
+
# If incompatibility's internal cause is numbered, collapsing it would
|
163
|
+
# get too noisy.
|
164
|
+
complex = cause.conflict.conflict? ? cause.conflict : cause.other
|
165
|
+
|
166
|
+
!@line_numbers.has_key?(complex)
|
167
|
+
end
|
168
|
+
|
169
|
+
def count_derivations(incompatibility)
|
170
|
+
if @derivations.has_key?(incompatibility)
|
171
|
+
@derivations[incompatibility] += 1
|
172
|
+
else
|
173
|
+
@derivations[incompatibility] = 1
|
174
|
+
if incompatibility.conflict?
|
175
|
+
cause = incompatibility.cause
|
176
|
+
count_derivations(cause.conflict)
|
177
|
+
count_derivations(cause.other)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module Bundler::PubGrub
|
2
|
+
class Incompatibility
|
3
|
+
ConflictCause = Struct.new(:incompatibility, :satisfier) do
|
4
|
+
alias_method :conflict, :incompatibility
|
5
|
+
alias_method :other, :satisfier
|
6
|
+
end
|
7
|
+
|
8
|
+
InvalidDependency = Struct.new(:package, :constraint) do
|
9
|
+
end
|
10
|
+
|
11
|
+
NoVersions = Struct.new(:constraint) do
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :terms, :cause
|
15
|
+
|
16
|
+
def initialize(terms, cause:, custom_explanation: nil)
|
17
|
+
@cause = cause
|
18
|
+
@terms = cleanup_terms(terms)
|
19
|
+
@custom_explanation = custom_explanation
|
20
|
+
|
21
|
+
if cause == :dependency && @terms.length != 2
|
22
|
+
raise ArgumentError, "a dependency Incompatibility must have exactly two terms. Got #{@terms.inspect}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def hash
|
27
|
+
cause.hash ^ terms.hash
|
28
|
+
end
|
29
|
+
|
30
|
+
def eql?(other)
|
31
|
+
cause.eql?(other.cause) &&
|
32
|
+
terms.eql?(other.terms)
|
33
|
+
end
|
34
|
+
|
35
|
+
def failure?
|
36
|
+
terms.empty? || (terms.length == 1 && Package.root?(terms[0].package) && terms[0].positive?)
|
37
|
+
end
|
38
|
+
|
39
|
+
def conflict?
|
40
|
+
ConflictCause === cause
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns all external incompatibilities in this incompatibility's
|
44
|
+
# derivation graph
|
45
|
+
def external_incompatibilities
|
46
|
+
if conflict?
|
47
|
+
[
|
48
|
+
cause.conflict,
|
49
|
+
cause.other
|
50
|
+
].flat_map(&:external_incompatibilities)
|
51
|
+
else
|
52
|
+
[this]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
return @custom_explanation if @custom_explanation
|
58
|
+
|
59
|
+
case cause
|
60
|
+
when :root
|
61
|
+
"(root dependency)"
|
62
|
+
when :dependency
|
63
|
+
"#{terms[0].to_s(allow_every: true)} depends on #{terms[1].invert}"
|
64
|
+
when Bundler::PubGrub::Incompatibility::InvalidDependency
|
65
|
+
"#{terms[0].to_s(allow_every: true)} depends on unknown package #{cause.package}"
|
66
|
+
when Bundler::PubGrub::Incompatibility::NoVersions
|
67
|
+
"no versions satisfy #{cause.constraint}"
|
68
|
+
when Bundler::PubGrub::Incompatibility::ConflictCause
|
69
|
+
if failure?
|
70
|
+
"version solving has failed"
|
71
|
+
elsif terms.length == 1
|
72
|
+
term = terms[0]
|
73
|
+
if term.positive?
|
74
|
+
if term.constraint.any?
|
75
|
+
"#{term.package} cannot be used"
|
76
|
+
else
|
77
|
+
"#{term.to_s(allow_every: true)} cannot be used"
|
78
|
+
end
|
79
|
+
else
|
80
|
+
"#{term.invert} is required"
|
81
|
+
end
|
82
|
+
else
|
83
|
+
if terms.all?(&:positive?)
|
84
|
+
if terms.length == 2
|
85
|
+
"#{terms[0].to_s(allow_every: true)} is incompatible with #{terms[1]}"
|
86
|
+
else
|
87
|
+
"one of #{terms.map(&:to_s).join(" or ")} must be false"
|
88
|
+
end
|
89
|
+
elsif terms.all?(&:negative?)
|
90
|
+
if terms.length == 2
|
91
|
+
"either #{terms[0].invert} or #{terms[1].invert}"
|
92
|
+
else
|
93
|
+
"one of #{terms.map(&:invert).join(" or ")} must be true";
|
94
|
+
end
|
95
|
+
else
|
96
|
+
positive = terms.select(&:positive?)
|
97
|
+
negative = terms.select(&:negative?).map(&:invert)
|
98
|
+
|
99
|
+
if positive.length == 1
|
100
|
+
"#{positive[0].to_s(allow_every: true)} requires #{negative.join(" or ")}"
|
101
|
+
else
|
102
|
+
"if #{positive.join(" and ")} then #{negative.join(" or ")}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
else
|
107
|
+
raise "unhandled cause: #{cause.inspect}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def inspect
|
112
|
+
"#<#{self.class} #{to_s}>"
|
113
|
+
end
|
114
|
+
|
115
|
+
def pretty_print(q)
|
116
|
+
q.group 2, "#<#{self.class}", ">" do
|
117
|
+
q.breakable
|
118
|
+
q.text to_s
|
119
|
+
|
120
|
+
q.breakable
|
121
|
+
q.text " caused by "
|
122
|
+
q.pp @cause
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def cleanup_terms(terms)
|
129
|
+
terms.each do |term|
|
130
|
+
raise "#{term.inspect} must be a term" unless term.is_a?(Term)
|
131
|
+
end
|
132
|
+
|
133
|
+
if terms.length != 1 && ConflictCause === cause
|
134
|
+
terms = terms.reject do |term|
|
135
|
+
term.positive? && Package.root?(term.package)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Optimized simple cases
|
140
|
+
return terms if terms.length <= 1
|
141
|
+
return terms if terms.length == 2 && terms[0].package != terms[1].package
|
142
|
+
|
143
|
+
terms.group_by(&:package).map do |package, common_terms|
|
144
|
+
common_terms.inject do |acc, term|
|
145
|
+
acc.intersect(term)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler::PubGrub
|
4
|
+
class Package
|
5
|
+
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(name)
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def inspect
|
13
|
+
"#<#{self.class} #{name.inspect}>"
|
14
|
+
end
|
15
|
+
|
16
|
+
def <=>(other)
|
17
|
+
name <=> other.name
|
18
|
+
end
|
19
|
+
|
20
|
+
ROOT = Package.new(:root)
|
21
|
+
ROOT_VERSION = 0
|
22
|
+
|
23
|
+
def self.root
|
24
|
+
ROOT
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.root_version
|
28
|
+
ROOT_VERSION
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.root?(package)
|
32
|
+
if package.respond_to?(:root?)
|
33
|
+
package.root?
|
34
|
+
else
|
35
|
+
package == root
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
name.to_s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require_relative 'assignment'
|
2
|
+
|
3
|
+
module Bundler::PubGrub
|
4
|
+
class PartialSolution
|
5
|
+
attr_reader :assignments, :decisions
|
6
|
+
attr_reader :attempted_solutions
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
reset!
|
10
|
+
|
11
|
+
@attempted_solutions = 1
|
12
|
+
@backtracking = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def decision_level
|
16
|
+
@decisions.length
|
17
|
+
end
|
18
|
+
|
19
|
+
def relation(term)
|
20
|
+
package = term.package
|
21
|
+
return :overlap if !@terms.key?(package)
|
22
|
+
|
23
|
+
@relation_cache[package][term] ||=
|
24
|
+
@terms[package].relation(term)
|
25
|
+
end
|
26
|
+
|
27
|
+
def satisfies?(term)
|
28
|
+
relation(term) == :subset
|
29
|
+
end
|
30
|
+
|
31
|
+
def derive(term, cause)
|
32
|
+
add_assignment(Assignment.new(term, cause, decision_level, assignments.length))
|
33
|
+
end
|
34
|
+
|
35
|
+
def satisfier(term)
|
36
|
+
assignment =
|
37
|
+
@assignments_by[term.package].bsearch do |assignment_by|
|
38
|
+
@cumulative_assignments[assignment_by].satisfies?(term)
|
39
|
+
end
|
40
|
+
|
41
|
+
assignment || raise("#{term} unsatisfied")
|
42
|
+
end
|
43
|
+
|
44
|
+
# A list of unsatisfied terms
|
45
|
+
def unsatisfied
|
46
|
+
@required.keys.reject do |package|
|
47
|
+
@decisions.key?(package)
|
48
|
+
end.map do |package|
|
49
|
+
@terms[package]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def decide(package, version)
|
54
|
+
@attempted_solutions += 1 if @backtracking
|
55
|
+
@backtracking = false;
|
56
|
+
|
57
|
+
decisions[package] = version
|
58
|
+
assignment = Assignment.decision(package, version, decision_level, assignments.length)
|
59
|
+
add_assignment(assignment)
|
60
|
+
end
|
61
|
+
|
62
|
+
def backtrack(previous_level)
|
63
|
+
@backtracking = true
|
64
|
+
|
65
|
+
new_assignments = assignments.select do |assignment|
|
66
|
+
assignment.decision_level <= previous_level
|
67
|
+
end
|
68
|
+
|
69
|
+
new_decisions = Hash[decisions.first(previous_level)]
|
70
|
+
|
71
|
+
reset!
|
72
|
+
|
73
|
+
@decisions = new_decisions
|
74
|
+
|
75
|
+
new_assignments.each do |assignment|
|
76
|
+
add_assignment(assignment)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def reset!
|
83
|
+
# { Array<Assignment> }
|
84
|
+
@assignments = []
|
85
|
+
|
86
|
+
# { Package => Array<Assignment> }
|
87
|
+
@assignments_by = Hash.new { |h,k| h[k] = [] }
|
88
|
+
@cumulative_assignments = {}.compare_by_identity
|
89
|
+
|
90
|
+
# { Package => Package::Version }
|
91
|
+
@decisions = {}
|
92
|
+
|
93
|
+
# { Package => Term }
|
94
|
+
@terms = {}
|
95
|
+
@relation_cache = Hash.new { |h,k| h[k] = {} }
|
96
|
+
|
97
|
+
# { Package => Boolean }
|
98
|
+
@required = {}
|
99
|
+
end
|
100
|
+
|
101
|
+
def add_assignment(assignment)
|
102
|
+
term = assignment.term
|
103
|
+
package = term.package
|
104
|
+
|
105
|
+
@assignments << assignment
|
106
|
+
@assignments_by[package] << assignment
|
107
|
+
|
108
|
+
@required[package] = true if term.positive?
|
109
|
+
|
110
|
+
if @terms.key?(package)
|
111
|
+
old_term = @terms[package]
|
112
|
+
@terms[package] = old_term.intersect(term)
|
113
|
+
else
|
114
|
+
@terms[package] = term
|
115
|
+
end
|
116
|
+
@relation_cache[package].clear
|
117
|
+
|
118
|
+
@cumulative_assignments[assignment] = @terms[package]
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|