Class: VCLog::Adapters::Darcs

Inherits:
Abstract
  • Object
show all
Defined in:
lib/vclog/adapters/darcs.rb

Overview

Darcs SCM adapter.

FIXME: This needs to be fixed!!!!!!!

Instance Attribute Summary

Attributes inherited from Abstract

#config, #heuristics, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#change_by_date, #change_points, #changes, #email, #extract_changes, #extract_tags, #initialize_framework, #repository, #tag?, #tags, #tempfile, #user, #uuid, #version, #version_tag?

Constructor Details

#initializeDarcs

Returns a new instance of Darcs.



14
15
16
# File 'lib/vclog/adapters/darcs.rb', line 14

def initialize(*)
  raise "Darcs is not yet supported. Please help us fix that!"
end

Class Method Details

.repository?Boolean

Is a darcs repository?

Returns:

  • (Boolean)


19
20
21
# File 'lib/vclog/adapters/darcs.rb', line 19

def repository?
  File.directory?('_darcs')
end

Instance Method Details

#calculate_versionObject

Retrieve the “revision number” from the darcs tree.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/vclog/adapters/darcs.rb', line 56

def calculate_version
  raise "not a darcs repository" unless repository?

  status = info.status

  changes = `darcs changes`
  count   = 0
  tag     = "0.0"

  changes.each("\n\n") do |change|
    head, title, desc = change.split("\n", 3)
    if title =~ /^  \*/
      # Normal change.
      count += 1
    elsif title =~ /tagged (.*)/
      # Tag.  We look for these.
      tag = $1
      break
    else
      warn "Unparsable change: #{change}"
    end
  end
  ver = "#{tag}.#{count.to_s}"

  return ver
  #format_version_stamp(ver, status) # ,released)
end

#changelogObject

Cached Changelog.



27
28
29
# File 'lib/vclog/adapters/darcs.rb', line 27

def changelog
  @changelog ||= generate_changelog
end

#generate_changelogObject

Generate Changelog object.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vclog/adapters/darcs.rb', line 32

def generate_changelog
  raise "not a darcs repository" unless repository?

  log = Changelog.new

  txt = `darcs changes` #--repo=#{@repository}`

  txt.each_line do |line|
    case line
    when /^\s*$/
    when /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/
    when /^\s*tagged/
      log << $'
      log << "\n"
    else
      log << line
      log << "\n"
    end
  end

  return log
end

#repository?Boolean (private)

Is a darcs repository?

Returns:

  • (Boolean)


19
20
21
# File 'lib/vclog/adapters/darcs.rb', line 19

def repository?
  File.directory?('_darcs')
end

#tag(ref, label, msg) ⇒ Object

TODO



85
86
87
# File 'lib/vclog/adapters/darcs.rb', line 85

def tag(ref, label, msg)
  `darcs tag #{label}`
end