<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,12 @@
-*SVN* (version numbers are overrated)
+*GIT* (version numbers are overrated)
+
+* (16 Jun 2008) Backwards Compatibility is overrated (big updates for rails 2.1)
+
+  * Use ActiveRecord 2.1's dirty attribute checking instead [Asa Calow]
+  * Remove last traces of #non_versioned_fields
+  * Remove AR::Base.find_version and AR::Base.find_versions, rely on AR association proxies and named_scope
+  * Remove #versions_count, rely on AR association counter caching.
+  * Remove #versioned_attributes, basically the same as AR::Base.versioned_columns
 
 * (5 Oct 2006) Allow customization of #versions association options [Dan Peterson]
 </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -177,15 +177,6 @@ module ActiveRecord #:nodoc:
             :version_column, :max_version_limit, :track_altered_attributes, :version_condition, :version_sequence_name, :non_versioned_columns,
             :version_association_options, :version_if_changed
 
-          # legacy
-          alias_method :non_versioned_fields,  :non_versioned_columns
-          alias_method :non_versioned_fields=, :non_versioned_columns=
-
-          class &lt;&lt; self
-            alias_method :non_versioned_fields,  :non_versioned_columns
-            alias_method :non_versioned_fields=, :non_versioned_columns=
-          end
-
           self.versioned_class_name         = options[:class_name]  || &quot;Version&quot;
           self.versioned_foreign_key        = options[:foreign_key] || self.to_s.foreign_key
           self.versioned_table_name         = options[:table_name]  || &quot;#{table_name_prefix}#{base_class.name.demodulize.underscore}_versions#{table_name_suffix}&quot;
@@ -280,11 +271,6 @@ module ActiveRecord #:nodoc:
           base.extend ClassMethods
         end
 
-        # Finds a specific version of this record
-        def find_version(version = nil)
-          self.class.find_version(id, version)
-        end
-
         # Saves a version of the model if applicable
         def save_version
           save_version_on_create if save_version?
@@ -293,9 +279,9 @@ module ActiveRecord #:nodoc:
         # Saves a version of the model in the versioned table.  This is called in the after_save callback by default
         def save_version_on_create
           rev = self.class.versioned_class.new
-          self.clone_versioned_model(self, rev)
+          clone_versioned_model(self, rev)
           rev.version = send(self.class.version_column)
-          rev.send(&quot;#{self.class.versioned_foreign_key}=&quot;, self.id)
+          rev.send(&quot;#{self.class.versioned_foreign_key}=&quot;, id)
           rev.save
         end
 
@@ -305,24 +291,19 @@ module ActiveRecord #:nodoc:
           return if self.class.max_version_limit == 0
           excess_baggage = send(self.class.version_column).to_i - self.class.max_version_limit
           if excess_baggage &gt; 0
-            sql = &quot;DELETE FROM #{self.class.versioned_table_name} WHERE version &lt;= #{excess_baggage} AND #{self.class.versioned_foreign_key} = #{self.id}&quot;
-            self.class.versioned_class.connection.execute sql
+            self.class.versioned_class.delete_all [&quot;version &lt;= ? and #{self.class.versioned_foreign_key} = ?&quot;, excess_baggage, id]
           end
         end
 
-        def versions_count
-          version
-        end
-
         # Reverts a model to a given version.  Takes either a version number or an instance of the versioned model
         def revert_to(version)
           if version.is_a?(self.class.versioned_class)
-            return false unless version.send(self.class.versioned_foreign_key) == self.id and !version.new_record?
+            return false unless version.send(self.class.versioned_foreign_key) == id and !version.new_record?
           else
             return false unless version = versions.find_by_version(version)
           end
           self.clone_versioned_model(version, self)
-          self.send(&quot;#{self.class.version_column}=&quot;, version.version)
+          send(&quot;#{self.class.version_column}=&quot;, version.version)
           true
         end
 
@@ -347,20 +328,15 @@ module ActiveRecord #:nodoc:
             end
           end
         end
-
-        # Returns an array of attribute keys that are versioned.  See non_versioned_columns
-        def versioned_attributes
-          self.attributes.keys.select { |k| !self.class.non_versioned_columns.include?(k) }
-        end
         
         def altered?
-          self.track_altered_attributes ? (self.version_if_changed.map(&amp;:to_s) - changed).length == 0 : changed?
+          track_altered_attributes ? (version_if_changed.map(&amp;:to_s) - changed).length == 0 : changed?
         end
 
         # Clones a model.  Used when saving a new version or reverting a model's version.
         def clone_versioned_model(orig_model, new_model)
-          self.versioned_attributes.each do |key|
-            new_model.send(&quot;#{key}=&quot;, orig_model.send(key)) if orig_model.has_attribute?(key)
+          self.class.versioned_columns.each do |col|
+            new_model.send(&quot;#{col.name}=&quot;, orig_model.send(col.name)) if orig_model.has_attribute?(col.name)
           end
 
           if orig_model.is_a?(self.class.versioned_class)
@@ -413,40 +389,18 @@ module ActiveRecord #:nodoc:
         protected
           # sets the new version before saving, unless you're using optimistic locking.  In that case, let it take care of the version.
           def set_new_version
-            self.send(&quot;#{self.class.version_column}=&quot;, self.next_version) if new_record? || (!locking_enabled? &amp;&amp; save_version?)
+            self.send(&quot;#{self.class.version_column}=&quot;, next_version) if new_record? || (!locking_enabled? &amp;&amp; save_version?)
           end
 
           # Gets the next available version for the current record, or 1 for a new record
           def next_version
-            return 1 if new_record?
-            (versions.calculate(:max, :version) || 0) + 1
+            (new_record? ? 0 : versions.calculate(:max, :version).to_i) + 1
           end
 
         module ClassMethods
-          # Finds a specific version of a specific row of this model
-          def find_version(id, version = nil)
-            return find(id) unless version
-
-            conditions = [&quot;#{versioned_foreign_key} = ? AND version = ?&quot;, id, version]
-            options = { :conditions =&gt; conditions, :limit =&gt; 1 }
-
-            if result = find_versions(id, options).first
-              result
-            else
-              raise RecordNotFound, &quot;Couldn't find #{name} with ID=#{id} and VERSION=#{version}&quot;
-            end
-          end
-
-          # Finds versions of a specific model.  Takes an options hash like &lt;tt&gt;find&lt;/tt&gt;
-          def find_versions(id, options = {})
-            versioned_class.find :all, {
-              :conditions =&gt; [&quot;#{versioned_foreign_key} = ?&quot;, id],
-              :order      =&gt; 'version' }.merge(options)
-          end
-
           # Returns an array of columns that are versioned.  See non_versioned_columns
           def versioned_columns
-            self.columns.select { |c| !non_versioned_columns.include?(c.name) }
+            @versioned_columns ||= columns.select { |c| !non_versioned_columns.include?(c.name) }
           end
 
           # Returns an instance of the dynamic versioned model
@@ -470,17 +424,17 @@ module ActiveRecord #:nodoc:
             self.versioned_columns.each do |col| 
               updated_col = col if !updated_col &amp;&amp; %(updated_at updated_on).include?(col.name)
               self.connection.add_column versioned_table_name, col.name, col.type, 
-                :limit =&gt; col.limit, 
-                :default =&gt; col.default,
-                :scale =&gt; col.scale,
+                :limit     =&gt; col.limit, 
+                :default   =&gt; col.default,
+                :scale     =&gt; col.scale,
                 :precision =&gt; col.precision
             end
 
             if type_col = self.columns_hash[inheritance_column]
               self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type, 
-                :limit =&gt; type_col.limit, 
-                :default =&gt; type_col.default,
-                :scale =&gt; type_col.scale,
+                :limit     =&gt; type_col.limit, 
+                :default   =&gt; type_col.default,
+                :scale     =&gt; type_col.scale,
                 :precision =&gt; type_col.precision
             end
 </diff>
      <filename>lib/acts_as_versioned.rb</filename>
    </modified>
    <modified>
      <diff>@@ -238,24 +238,11 @@ class VersionedTest &lt; Test::Unit::TestCase
   end
 
   def test_find_versions
-    assert_equal 2, locked_pages(:welcome).versions.size
-    assert_equal 1, locked_pages(:welcome).versions.find(:all, :conditions =&gt; ['title LIKE ?', '%weblog%']).length
-    assert_equal 2, locked_pages(:welcome).versions.find(:all, :conditions =&gt; ['title LIKE ?', '%web%']).length
-    assert_equal 0, locked_pages(:thinking).versions.find(:all, :conditions =&gt; ['title LIKE ?', '%web%']).length
-    assert_equal 2, locked_pages(:welcome).versions.length
+    assert_equal 1, locked_pages(:welcome).versions.find(:all, :conditions =&gt; ['title LIKE ?', '%weblog%']).size
   end
 
   def test_find_version
-    assert_equal page_versions(:welcome_1), Page.find_version(pages(:welcome).id, 23)
-    assert_equal page_versions(:welcome_2), Page.find_version(pages(:welcome).id, 24)
-    assert_equal pages(:welcome), Page.find_version(pages(:welcome).id)
-
-    assert_equal page_versions(:welcome_1), pages(:welcome).find_version(23)
-    assert_equal page_versions(:welcome_2), pages(:welcome).find_version(24)
-    assert_equal pages(:welcome), pages(:welcome).find_version
-
-    assert_raise(ActiveRecord::RecordNotFound) { Page.find_version(pages(:welcome).id, 1) }
-    assert_raise(ActiveRecord::RecordNotFound) { Page.find_version(0, 23) }
+    assert_equal page_versions(:welcome_1), pages(:welcome).versions.find_by_version(23)
   end
 
   def test_with_sequence
@@ -333,8 +320,6 @@ class VersionedTest &lt; Test::Unit::TestCase
   end
 
   def test_should_find_version_count
-    assert_equal 24, pages(:welcome).versions_count
-    assert_equal 24, page_versions(:welcome_1).versions_count
-    assert_equal 24, page_versions(:welcome_2).versions_count
+    assert_equal 2, pages(:welcome).versions.size
   end
 end
\ No newline at end of file</diff>
      <filename>test/versioned_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>550f5e0736a06185bf3585d8f6efa6662dc1fac2</id>
    </parent>
  </parents>
  <author>
    <name>rick</name>
    <email>technoweenie@gmail.com</email>
  </author>
  <url>http://github.com/technoweenie/acts_as_versioned/commit/36b078359dcd92295c992fff630076a634b2fda1</url>
  <id>36b078359dcd92295c992fff630076a634b2fda1</id>
  <committed-date>2008-06-16T23:26:42-07:00</committed-date>
  <authored-date>2008-06-16T23:26:42-07:00</authored-date>
  <message>* (16 Jun 2008) Backwards Compatibility is overrated (big updates for rails 2.1)

  * Remove last traces of #non_versioned_fields
  * Remove AR::Base.find_version and AR::Base.find_versions, rely on AR association proxies and named_scope
  * Remove #versions_count, rely on AR association counter caching.
  * Remove #versioned_attributes, basically the same as AR::Base.versioned_columns</message>
  <tree>18d410830d663e45f2a95d3fa2388ac12f5b0fbc</tree>
  <committer>
    <name>rick</name>
    <email>technoweenie@gmail.com</email>
  </committer>
</commit>
