Namespace
Methods
A
D
G
L
M
N
R
Constants
NullDevice = defined?(IO::NULL) ? IO::NULL : %w[/dev/null NUL NIL: NL:].find {|dev| File.exist?(dev)}
 
Class Public methods
detect(path)
# File tool/vcs.rb, line 74
def self.detect(path)
  @@dirs.each do |dir, klass|
    return klass.new(path) if File.directory?(File.join(path, dir))
    prev = path
    loop {
      curr = File.realpath(File.join(prev, '..'))
      break if curr == prev   # stop at the root directory
      return klass.new(path) if File.directory?(File.join(curr, dir))
      prev = curr
    }
  end
  raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
end
local_path?(path)
# File tool/vcs.rb, line 88
def self.local_path?(path)
  String === path or path.respond_to?(:to_path)
end
new(path)
# File tool/vcs.rb, line 92
def initialize(path)
  @srcdir = path
  super()
end
register(dir)
# File tool/vcs.rb, line 70
def self.register(dir)
  @@dirs << [dir, self]
end
Instance Public methods
after_export(dir)
# File tool/vcs.rb, line 162
def after_export(dir)
end
get_revisions(path)

return a pair of strings, the last revision and the last revision in which path was modified.

# File tool/vcs.rb, line 102
def get_revisions(path)
  if self.class.local_path?(path)
    path = relative_to(path)
  end
  last, changed, modified, *rest = (
    begin
      if NullDevice
        save_stderr = STDERR.dup
        STDERR.reopen NullDevice, 'w'
      end
      self.class.get_revisions(path, @srcdir)
    ensure
      if save_stderr
        STDERR.reopen save_stderr
        save_stderr.close
      end
    end
  )
  last or raise VCS::NotFoundError, "last revision not found"
  changed or raise VCS::NotFoundError, "changed revision not found"
  if modified
    /\A(\d+)-(\d+)-(\d+)\D(\d+):(\d+):(\d+(?:\.\d+)?)\s*(?:Z|([-+]\d\d)(\d\d))\z/ =~ modified or
      raise "unknown time format - #{modified}"
    match = $~[1..6].map { |x| x.to_i }
    off = $7 ? "#{$7}:#{$8}" : "+00:00"
    match << off
    begin
      modified = Time.new(*match)
    rescue ArgumentError
      modified = Time.utc(*$~[1..6]) + $7.to_i * 3600 + $8.to_i * 60
    end
  end
  return last, changed, modified, *rest
end
modified(path)
# File tool/vcs.rb, line 137
def modified(path)
  last, changed, modified, *rest = get_revisions(path)
  modified
end
relative_to(path)
# File tool/vcs.rb, line 142
def relative_to(path)
  if path
    srcdir = File.realpath(@srcdir)
    path = File.realdirpath(path)
    list1 = srcdir.split(%r{/})
    list2 = path.split(%r{/})
    while !list1.empty? && !list2.empty? && list1.first == list2.first
      list1.shift
      list2.shift
    end
    if list1.empty? && list2.empty?
      "."
    else
      ([".."] * list1.length + list2).join("/")
    end
  else
    '.'
  end
end