piston update is coming. I have the high-level workflow completed. Conceptually, updating is pretty simple:

 1 module Piston
 2   module Commands
 3     class Update < Piston::Commands::Base
 4       # +wcdir+ is the working copy we're going to change.
 5       # +to+ is the new target revision we want to be at after update returns.
 6       def run(wcdir, to)
 7         working_copy = Piston::WorkingCopy.guess(wcdir)
 8 
 9         logger.debug {"Recalling previously saved values"}
10         values = working_copy.recall
11 
12         repository_class = values["repository_class"]
13         repository_url = values["repository_url"]
14         repository = repository_class.constantize.new(repository_url)
15         from_revision = repository.at(values["handler"])
16         to_revision = repository.at(to)
17 
18         logger.debug {"Validating that #{from_revision} exists and is capable of performing the update"}
19         from_revision.validate!
20 
21         logger.info {"Updating from #{from_revision} to #{to_revision}"}
22         working_copy.apply_differences(from_revision.differences_with(to_revision))
23       end
24     end
25   end
26 end

Obviously, the devil’s in the details… Notice the last line above:

1 working_copy.apply_differences(from_revision.differences_with(to_revision))

from_revision will calculate a set of differences between itself and to_revision. In Subversion speak, that would probably mean an svn log followed by an svn diff, to get all changes (copies + diffs).

What Piston 1.x does is copy the newer file over the original file, and then applies the changes between the last changed revision of the local files and the working copy. This ensures changes that were made are kept in the new revision.

I know I can do it under Subversion, as I have already done it, but what about git ? I can probably use a combination of git-format-patch and git-apply to get the job done. That would certainly work.

I also thought about finding / using a patch implementation in Ruby. I wonder if that would be another acceptable road ? Anybody out there has / knows about a patch implementation in Ruby ?

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on