public
Description: git version of the rubygems svn repo
Homepage: http://rubygems.rubyforge.org
Clone URL: git://github.com/lstoll/rubygems.git
Search Repo:
Don't set install_dir by default, don't include satisfied dependencies 
when
installing.

git-svn-id: svn+ssh://rubyforge.org/var/svn/rubygems/trunk@1761 
3d4018f9-ac1a-0410-99e9-8a154d859a19
drbrain (author)
Mon Jun 09 16:01:25 -0700 2008
commit  af3b72bdae92b62cf602433e644074ede6c10c58
tree    edd89e32be28d01648f77f026135e690935ef514
parent  64eef53658d67140b360d750f5511c8a2c0db93d
...
1
2
3
4
 
 
5
6
7
8
 
 
 
 
9
10
11
...
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -1,11 +1,16 @@
0
 2008-06-09 Eric Hodel <drbrain@segment7.net>
0
 
0
   * lib/rubygems/dependency_installer.rb: Only install all dependencies
0
- when install_dir option is set.
0
+ when install_dir option is set. Don't include satisfied dependencies
0
+ when gathering dependencies.
0
   * lib/rubygems/commands/query_command.rb: Display authors, rubyforge
0
   and homepage urls with details.
0
   * lib/rubygems/commands/environment_command.rb: Add executable
0
   directory (from Rubinius).
0
+ * lib/rubygems/commands/install_command.rb: Don't set install_dir by
0
+ default.
0
+ * lib/rubygems/commands/update_command.rb: Don't set install_dir by
0
+ default. Use #find_missing for efficiency.
0
 
0
 2008-06-07 Eric Hodel <drbrain@segment7.net>
0
 
...
435
436
437
438
439
440
441
...
435
436
437
 
438
439
440
0
@@ -435,7 +435,6 @@ task :diff_rubinius do
0
   sh "diff #{diff_options} lib/ubygems.rb #{rubinius_dir}/lib/ubygems.rb; true"
0
   sh "diff #{diff_options} lib/rubygems.rb #{rubinius_dir}/lib/rubygems.rb; true"
0
   sh "diff #{diff_options} lib/rubygems #{rubinius_dir}/lib/rubygems; true"
0
- sh "diff #{diff_options} lib/rbconfig #{rubinius_dir}/lib/rbconfig; true"
0
   sh "diff #{diff_options} test #{rubinius_dir}/test/rubygems; true"
0
   sh "diff #{diff_options} util/gem_prelude.rb #{rubinius_dir}/kernel/core/gem_prelude.rb; true"
0
 end
...
16
17
18
19
20
21
22
...
16
17
18
 
19
20
21
0
@@ -16,7 +16,6 @@ class Gem::Commands::InstallCommand < Gem::Command
0
     defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
0
       :generate_rdoc => true,
0
       :generate_ri => true,
0
- :install_dir => Gem.dir,
0
       :format_executable => false,
0
       :test => false,
0
       :version => Gem::Requirement.default,
...
18
19
20
21
22
 
23
24
25
...
60
61
62
63
 
64
65
66
...
134
135
136
137
 
138
139
140
 
 
 
 
 
 
141
142
143
144
 
 
 
 
 
 
 
145
146
147
148
 
 
 
 
 
 
 
149
150
151
 
152
153
154
...
18
19
20
 
 
21
22
23
24
...
59
60
61
 
62
63
64
65
...
133
134
135
 
136
137
 
 
138
139
140
141
142
143
144
 
 
 
145
146
147
148
149
150
151
152
153
154
 
155
156
157
158
159
160
161
162
163
 
164
165
166
167
0
@@ -18,8 +18,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
0
       :generate_rdoc => true,
0
       :generate_ri => true,
0
       :force => false,
0
- :test => false,
0
- :install_dir => Gem.dir
0
+ :test => false
0
 
0
     add_install_update_options
0
 
0
@@ -60,7 +59,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
0
 
0
     hig = {} # highest installed gems
0
 
0
- Gem::SourceIndex.from_installed_gems.each do |name, spec|
0
+ Gem.source_index.each do |name, spec|
0
       if hig[spec.name].nil? or hig[spec.name].version < spec.version then
0
         hig[spec.name] = spec
0
       end
0
@@ -134,21 +133,35 @@ class Gem::Commands::UpdateCommand < Gem::Command
0
       next if not gem_names.empty? and
0
               gem_names.all? { |name| /#{name}/ !~ l_spec.name }
0
 
0
- dep = Gem::Dependency.new l_spec.name, ">= #{l_spec.version}"
0
+ dependency = Gem::Dependency.new l_spec.name, "> #{l_spec.version}"
0
 
0
- # TODO use #find_matching when SourceInfoCache is gone
0
- remote_gemspecs = Gem::SpecFetcher.fetcher.fetch dep, false, false
0
+ begin
0
+ fetcher = Gem::SpecFetcher.fetcher
0
+ spec_tuples = fetcher.find_matching dependency
0
+ rescue Gem::RemoteFetcher::FetchError => e
0
+ raise unless fetcher.warn_legacy e do
0
+ require 'rubygems/source_info_cache'
0
 
0
- matching_gems = remote_gemspecs.select do |spec,|
0
- spec.name == l_name and Gem.platforms.any? do |platform|
0
- platform == spec.platform
0
+ dependency.name = '' if dependency.name == //
0
+
0
+ specs = Gem::SourceInfoCache.search_with_source dependency
0
+
0
+ spec_tuples = specs.map do |spec, source_uri|
0
+ [[spec.name, spec.version, spec.original_platform], source_uri]
0
+ end
0
         end
0
       end
0
 
0
- highest_remote_gem = matching_gems.sort_by { |spec,| spec.version }.last
0
+ matching_gems = spec_tuples.select do |(name, version, platform),|
0
+ name == l_name and Gem::Platform.match platform
0
+ end
0
+
0
+ highest_remote_gem = matching_gems.sort_by do |(name, version),|
0
+ version
0
+ end.last
0
 
0
       if highest_remote_gem and
0
- l_spec.version < highest_remote_gem.first.version then
0
+ l_spec.version < highest_remote_gem.first[1] then
0
         result << l_name
0
       end
0
     end
...
133
134
135
 
 
 
 
 
 
 
136
137
138
...
185
186
187
188
 
189
190
191
...
133
134
135
136
137
138
139
140
141
142
143
144
145
...
192
193
194
 
195
196
197
198
0
@@ -133,6 +133,13 @@ class Gem::DependencyInstaller
0
         deps.each do |dep|
0
           results = find_gems_with_sources(dep).reverse
0
 
0
+ results.reject! do |spec,|
0
+ @source_index.any? do |_, installed_spec|
0
+ dep.name == installed_spec.name and
0
+ dep.version_requirements.satisfied_by? installed_spec.version
0
+ end
0
+ end
0
+
0
           results.each do |dep_spec, source_uri|
0
             next if seen[dep_spec.name]
0
             @specs_and_sources << [dep_spec, source_uri]
0
@@ -185,7 +192,7 @@ class Gem::DependencyInstaller
0
 
0
     if spec_and_source.nil? then
0
       raise Gem::GemNotFoundException,
0
- "could not find #{gem_name} locally or in a repository"
0
+ "could not find gem #{gem_name} locally or in a repository"
0
     end
0
 
0
     @specs_and_sources = [spec_and_source]
...
214
215
216
 
 
 
 
 
 
217
218
219
...
214
215
216
217
218
219
220
221
222
223
224
225
0
@@ -214,6 +214,12 @@ class RubyGemTestCase < Test::Unit::TestCase
0
     end
0
   end
0
 
0
+ def util_clear_gems
0
+ FileUtils.rm_r File.join(@gemhome, 'gems')
0
+ FileUtils.rm_r File.join(@gemhome, 'specifications')
0
+ Gem.source_index.refresh!
0
+ end
0
+
0
   def util_gem(name, version, &block)
0
     spec = quick_gem(name, version, &block)
0
 
...
66
67
68
69
 
70
71
72
...
66
67
68
 
69
70
71
72
0
@@ -66,7 +66,7 @@ class TestGemCommandManager < RubyGemTestCase
0
       assert_equal :both, check_options[:domain]
0
       assert_equal true, check_options[:wrappers]
0
       assert_equal Gem::Requirement.default, check_options[:version]
0
- assert_equal Gem.dir, check_options[:install_dir]
0
+ assert_equal nil, check_options[:install_dir]
0
       assert_equal nil, check_options[:bin_dir]
0
 
0
       #check settings
...
72
73
74
75
 
76
77
78
...
97
98
99
100
 
101
102
103
...
72
73
74
 
75
76
77
78
...
97
98
99
 
100
101
102
103
0
@@ -72,7 +72,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
0
     end
0
 
0
     # HACK no repository was checked
0
- assert_equal "ERROR: could not find no_such_gem locally or in a repository\n",
0
+ assert_equal "ERROR: could not find gem no_such_gem locally or in a repository\n",
0
                  @ui.error
0
   end
0
 
0
@@ -97,7 +97,7 @@ class TestGemCommandsInstallCommand < RubyGemTestCase
0
       assert_equal 2, e.exit_code
0
     end
0
 
0
- assert_equal "ERROR: could not find nonexistent locally or in a repository\n",
0
+ assert_equal "ERROR: could not find gem nonexistent locally or in a repository\n",
0
                  @ui.error
0
   end
0
 
...
23
24
25
26
 
27
28
29
...
82
83
84
85
 
86
87
88
...
106
107
108
109
 
110
111
112
...
126
127
128
129
 
130
131
132
...
144
145
146
147
 
148
149
150
...
161
162
163
164
165
166
167
168
169
170
...
23
24
25
 
26
27
28
29
...
82
83
84
 
85
86
87
88
...
106
107
108
 
109
110
111
112
...
126
127
128
 
129
130
131
132
...
144
145
146
 
147
148
149
150
...
161
162
163
 
 
 
 
 
164
165
0
@@ -23,7 +23,7 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
0
   end
0
 
0
   def test_execute
0
- util_remove_gems
0
+ util_clear_gems
0
 
0
     Gem::Installer.new(@a1_path).install
0
 
0
@@ -82,7 +82,7 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
0
     @fetcher.data["#{@gem_repo}gems/#{@c2.full_name}.gem"] = read_binary @c2_path
0
 
0
     util_setup_spec_fetcher @a1, @a2, @b2, @c1_2, @c2
0
- util_remove_gems
0
+ util_clear_gems
0
 
0
     Gem::Installer.new(@c1_2_path).install
0
     Gem::Installer.new(@a1_path).install
0
@@ -106,7 +106,7 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
0
   end
0
 
0
   def test_execute_named
0
- util_remove_gems
0
+ util_clear_gems
0
 
0
     Gem::Installer.new(@a1_path).install
0
 
0
@@ -126,7 +126,7 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
0
   end
0
 
0
   def test_execute_named_up_to_date
0
- util_remove_gems
0
+ util_clear_gems
0
 
0
     Gem::Installer.new(@a2_path).install
0
 
0
@@ -144,7 +144,7 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
0
   end
0
 
0
   def test_execute_up_to_date
0
- util_remove_gems
0
+ util_clear_gems
0
 
0
     Gem::Installer.new(@a2_path).install
0
 
0
@@ -161,10 +161,5 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
0
     assert out.empty?, out.inspect
0
   end
0
 
0
- def util_remove_gems
0
- FileUtils.rm_r File.join(@gemhome, 'gems')
0
- FileUtils.rm_r File.join(@gemhome, 'specifications')
0
- end
0
-
0
 end
0
 
...
48
49
50
51
52
 
53
54
55
...
83
84
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
87
88
...
96
97
98
99
 
100
101
102
...
393
394
395
 
 
396
397
398
...
532
533
534
 
 
535
536
537
...
563
564
565
 
 
566
567
568
...
48
49
50
 
 
51
52
53
54
...
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
...
125
126
127
 
128
129
130
131
...
422
423
424
425
426
427
428
429
...
563
564
565
566
567
568
569
570
...
596
597
598
599
600
601
602
603
0
@@ -48,8 +48,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
0
     si = util_setup_spec_fetcher @a1, @b1, @d1, @d2, @x1_m, @x1_o, @w1, @y1,
0
                                  @y1_1_p, @z1
0
 
0
- FileUtils.rm_rf File.join(@gemhome, 'gems')
0
- Gem.source_index.refresh!
0
+ util_clear_gems
0
   end
0
 
0
   def test_install
0
@@ -83,6 +82,36 @@ class TestGemDependencyInstaller < RubyGemTestCase
0
     assert File.exist?(File.join(@tempdir, 'cache', "#{@b1.full_name}.gem"))
0
   end
0
 
0
+ def test_install_dependencies_satisfied
0
+ a2, a2_gem = util_gem 'a', '2'
0
+
0
+ FileUtils.rm_rf File.join(@gemhome, 'gems')
0
+ Gem.source_index.refresh!
0
+
0
+ FileUtils.mv @a1_gem, @tempdir
0
+ FileUtils.mv a2_gem, @tempdir # not in index
0
+ FileUtils.mv @b1_gem, @tempdir
0
+ inst = nil
0
+
0
+ Dir.chdir @tempdir do
0
+ inst = Gem::DependencyInstaller.new
0
+ inst.install 'a-2'
0
+ end
0
+
0
+ FileUtils.rm File.join(@tempdir, "#{a2.full_name}.gem")
0
+
0
+ Dir.chdir @tempdir do
0
+ inst = Gem::DependencyInstaller.new
0
+ inst.install 'b'
0
+ end
0
+
0
+ installed = Gem::SourceIndex.from_installed_gems.map { |n,s| s.full_name }
0
+
0
+ assert_equal %w[a-2 b-1], installed.sort
0
+
0
+ assert_equal %w[b-1], inst.installed_gems.map { |s| s.full_name }
0
+ end
0
+
0
   def test_install_dependency
0
     FileUtils.mv @a1_gem, @tempdir
0
     FileUtils.mv @b1_gem, @tempdir
0
@@ -96,7 +125,7 @@ class TestGemDependencyInstaller < RubyGemTestCase
0
     assert_equal %w[a-1 b-1], inst.installed_gems.map { |s| s.full_name }
0
   end
0
 
0
- def test_install_with_development_dependency
0
+ def test_install_dependency_development
0
     FileUtils.mv @a1_gem, @tempdir
0
     FileUtils.mv @aa1_gem, @tempdir
0
     FileUtils.mv @b1_gem, @tempdir
0
@@ -393,6 +422,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
0
       s.platform = Gem::Platform.new %w[cpu other_platform 1]
0
     end
0
 
0
+ util_clear_gems
0
+
0
     si = util_setup_spec_fetcher @a1, a2_o
0
 
0
     @fetcher.data['http://gems.example.com/gems/yaml'] = si.to_yaml
0
@@ -532,6 +563,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
0
     b2, = util_gem 'b', '2'
0
     c1, = util_gem 'c', '1' do |s| s.add_dependency 'b' end
0
 
0
+ util_clear_gems
0
+
0
     si = util_setup_spec_fetcher @a1, @b1, b2, c1
0
 
0
     inst = Gem::DependencyInstaller.new
0
@@ -563,6 +596,8 @@ class TestGemDependencyInstaller < RubyGemTestCase
0
   def test_gather_dependencies_old_required
0
     e1, = util_gem 'e', '1' do |s| s.add_dependency 'd', '= 1' end
0
 
0
+ util_clear_gems
0
+
0
     si = util_setup_spec_fetcher @d1, @d2, e1
0
 
0
     inst = Gem::DependencyInstaller.new

Comments

    No one has commented yet.