public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
commit  b6511e48f77789ea3718cd82492c1a09de7dccff
tree    7515064682eed188cfb43f20340ae5005ee6e410
parent  c9907db998f58f0efcfc6e7df52c1e3eff9ebe41
piston / lib / piston / svn / working_copy.rb
100644 62 lines (50 sloc) 1.332 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require "yaml"
 
module Piston
  module Svn
    class WorkingCopy < Piston::WorkingCopy
      extend Piston::Svn::Client
 
      # Register ourselves as a handler for working copies
      Piston::WorkingCopy.add_handler self
 
      class << self
        def understands_dir?(dir)
          result = svn(:info, dir) rescue :failed
          result == :failed ? false : true
        end
      end
 
      def svn(*args)
        self.class.svn(*args)
      end
 
      def svnadmin(*args)
        self.class.svnadmin(*args)
      end
 
      def exist?
        result = svn(:info, path) rescue :failed
        logger.debug {"result: #{result.inspect}"}
        return false if result == :failed
        return false if result.nil? || result.chomp.strip.empty?
        return true if YAML.load(result).has_key?("Path")
      end
 
      def create
        svn(:mkdir, path)
      end
 
      def after_remember(path)
        info = svn(:info, path)
        return unless info =~ /\(not a versioned resource\)/i
        svn(:add, path)
      end
 
      def recall(keys)
        hash = Hash.new
        keys.each do |k|
          hash[k] = svn(:propget, k, path)
        end
 
        hash
      end
 
      def finalize
        targets = []
        Dir[path + "*"].each do |item|
          svn(:add, item)
        end
      end
    end
  end
end