Class: Piston::Svn::Revision
Defined Under Namespace
Classes: InvalidRevision, RepositoryMoved, UuidChanged
Instance Attribute Summary
Attributes inherited from Revision
#recalled_values, #repository, #revision
Instance Method Summary
collapse
Methods inherited from Revision
#initialize, logger, #logger, #to_s
Instance Method Details
#checkout_to(path) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/piston/svn/revision.rb', line 23
def checkout_to(path)
@wcpath = path.kind_of?(Pathname) ? path : Pathname.new(path)
answer = svn(:checkout, "--revision", revision, repository.url, path)
if answer =~ /Checked out revision (\d+)[.]/ then
if revision == "HEAD" then
@revision = $1.to_i
elsif revision != $1.to_i then
raise Failed, "Did not get the revision I wanted to checkout. Subversion checked out #{$1}, I wanted #{revision}"
end
else
raise Failed, "Could not checkout revision #{revision} from #{repository.url} to #{path}\n#{answer}"
end
end
|
#client ⇒ Object
11
12
13
|
# File 'lib/piston/svn/revision.rb', line 11
def client
@client ||= Piston::Svn::Client.instance
end
|
#copy_to(relpath, abspath) ⇒ Object
54
55
56
57
58
59
|
# File 'lib/piston/svn/revision.rb', line 54
def copy_to(relpath, abspath)
raise ArgumentError, "Revision #{revision} of #{repository.url} was never checked out -- can't iterate over files" unless @wcpath
Pathname.new(abspath).dirname.mkpath
FileUtils.cp(@wcpath + relpath, abspath)
end
|
#each ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/piston/svn/revision.rb', line 45
def each
raise ArgumentError, "Revision #{revision} of #{repository.url} was never checked out -- can't iterate over files" unless @wcpath
svn(:ls, "--recursive", @wcpath).each do |relpath|
next if relpath =~ %r{/$}
yield relpath.chomp
end
end
|
#name ⇒ Object
19
20
21
|
# File 'lib/piston/svn/revision.rb', line 19
def name
"r#{revision}"
end
|
#recalled_uuid ⇒ Object
69
70
71
|
# File 'lib/piston/svn/revision.rb', line 69
def recalled_uuid
recalled_values[Piston::Svn::UUID]
end
|
#remember_values ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/piston/svn/revision.rb', line 37
def remember_values
str = svn(:info, "--revision", revision, repository.url)
raise Failed, "Could not get 'svn info' from #{repository.url} at revision #{revision}" if str.nil? || str.chomp.strip.empty?
info = YAML.load(str)
{ Piston::Svn::UUID => info["Repository UUID"],
Piston::Svn::REMOTE_REV => info["Revision"]}
end
|
#svn(*args) ⇒ Object
15
16
17
|
# File 'lib/piston/svn/revision.rb', line 15
def svn(*args)
client.svn(*args)
end
|
#validate! ⇒ Object
61
62
63
64
65
66
67
|
# File 'lib/piston/svn/revision.rb', line 61
def validate!
data = svn(:info, "--revision", revision, repository.url)
info = YAML.load(data)
actual_uuid = info["Repository UUID"]
raise RepositoryMoved, "Repository at #{repository.url} does not exist anymore:\n#{data}" if actual_uuid.blank?
raise UuidChanged, "Expected repository at #{repository.url} to have UUID #{recalled_uuid} but found #{actual_uuid}" if recalled_uuid != actual_uuid
end
|