Class: FlatHash::Hg

Inherits:
Vcs show all
Defined in:
lib/flat_hash/hg.rb

Instance Method Summary collapse

Methods inherited from Vcs

#commit, #execute, #init, #sh

Instance Method Details

#addremovecommit(comment) ⇒ Object



9
10
11
12
# File 'lib/flat_hash/hg.rb', line 9

def addremovecommit comment
  execute "addremove"
  commit comment
end

#changeset(id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/flat_hash/hg.rb', line 18

def changeset id
  change = FlatHash::Changeset.new
  style = File.join(File.dirname(__FILE__), 'delta.hg')
  lines = sh("hg log --style \"#{style}\" -r #{id} --removed")
  change.id = lines.shift
  change.time = lines.shift
  change.author = lines.shift
  change.modifications = read_until(lines, 'additions:')
  change.additions = read_until(lines, 'deletions:')
  change.deletions = read_until(lines, 'description:')
  change.modifications = change.modifications - change.additions
  change.modifications = change.modifications - change.deletions
  change.description = lines.join("\n")
  change
end

#changesets(path = '.') ⇒ Object



14
15
16
# File 'lib/flat_hash/hg.rb', line 14

def changesets path='.'
  execute "log --removed --template \"{node}\\n\" #{path}"
end

#content_at(path, commit) ⇒ Object



34
35
36
# File 'lib/flat_hash/hg.rb', line 34

def content_at path, commit
  execute("cat -r #{commit} #{path}").join("\n")
end

#files_at(commit, path = '.') ⇒ Object



38
39
40
41
42
43
# File 'lib/flat_hash/hg.rb', line 38

def files_at commit, path='.'
  sh "hg locate -r #{commit} '#{path}/*'" do |status, lines|
    raise "failed with status #{status.exitstatus}:\n#{lines.join("\n")}" unless status.exitstatus == 1
    []
  end
end

#nameObject



5
6
7
# File 'lib/flat_hash/hg.rb', line 5

def name
  :hg
end