Commits

Anonymous committed f65b175

started on getting stages in place to make committing more sane

Comments (0)

Files changed (6)

 loaded with its filename as the help entry's name. So, if you create a file
 called "ampfiles.md", then "amp help ampfiles" will present the file you created.
 
-# Insects (low-low-low-priority bugs)
+# Insects (low-low-low priority bugs)
 
 ## Test Reloading
 Files get double-loaded when we run tests. Fix this. Kill the fucking insect.
 
 ## StagingArea#file_status
 This is called like a million times and it's unnecessary. We can use memoization
-to alleviate any pains. But be apprised: we have yet to feel any pains from it.
+to alleviate any pains. But be apprised: we have yet to feel any pains from it.
+
+# Random Complaints
+The standards for committing are ridiculous. They are so unfriendly to human or
+machine.
+
+The nomenclature for files and their statuses is absurd. It changes all over the
+place and is completely unstandardized.
+
+Comments don't explain why a method does something.

lib/amp/commands/commands/workflows/hg/commit.rb

     opts.merge! :match => match, :extra => extra
     
     changes = calculate_dirstate_commit(repo, files, match)
-    opts[:modified], opts[:removed] = (changes[:modified] + changes[:added]), changes[:removed]
+    opts[:modified], opts[:removed] = changes[:modified], changes[:removed]
     File.open("/log.txt","a") {|f| f.puts "committing: #{opts.inspect} #{args.inspect} #{changes.inspect}\n"}
     repo.commit opts
   end
     # Forces a status check - kinda nice, actually.
     full_status = repo.status
     if files.any?
-      changes = {:modified => [], :removed => [], :added => []}
+      changes = {:modified => [], :removed => []}
       # split the files up so we can deal with them appropriately
       files.each do |file|
         case repo.staging_area.file_status file
           changes[:removed]  << file
         when :untracked
           if File.directory?(file)
-            changes[:modified].concat full_status[:modified].select {|x| x.start_with?(file)}
-            changes[:removed].concat  full_status[:removed].select  {|x| x.start_with?(file)}
+            changes[:modified].concat full_status[:modified].select {|x| x.start_with?(file) }
+            changes[:removed].concat  full_status[:removed].select  {|x| x.start_with?(file) }
             # no warning if given empty directory
           else
             Amp::UI.warn "#{file} not tracked!"

lib/amp/repository/abstract/abstract_staging_area.rb

         0
       end
       
+      ##
+      # All the files that are either added, modified, or merged.
+      # 
+      # @return [Array<String>] the files to be added in a commit
+      def modified
+        raise NotImplementedError.new("modified() must be implemented by subclasses of AbstractStagingArea.")
+      end
+      
+      ##
+      # All the files that are to be removed.
+      # 
+      # @return [Array<String>] the files to be removed in a commit
+      def removed
+        raise NotImplementedError.new("removed() must be implemented by subclasses of AbstractStagingArea.")
+      end
+      
     end
   end
 end

lib/amp/repository/abstract/common_methods/staging_area.rb

     module CommonStagingAreaMethods
       
       ##
+      # An easy format for #commit to figure out wtf is going on.
+      def to_stage
+        {:modified => modified,
+         :removed  => removed }
+      end
+      
+      ##
       # Returns whether or not the repository is tracking the given file.
       #
       # @api

lib/amp/repository/git/repo_format/staging_area.rb

             unlink = true
             filenames = filenames[0..-2]
           end
+          
           filenames.each do |file|
             @index.remove file
-          end          
+          end
+          
           filenames.each do |file|
-            File.rm_rf(repo.file_opener.join(file))
+            File.rm_rf repo.file_opener.join(file)
           end if unlink
         end
 

lib/amp/repository/mercurial/repo_format/staging_area.rb

         
         ######### API Methods #################################################
         
+        def modified
+          dirstate.files.select {|f| f.merged? || f.modified? || f.added? }
+        end
+        
+        def removed
+          dirstate.files.select {|f| f.removed? }
+        end
+        
         ##
         # The directory used by the VCS to store magical information (.hg, .git, etc.).
         #
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.