Commit 5ec8d4d295efba114a8afa3c5cbe0dad50b5bbe2
- Date: Thu Oct 11 05:15:11 +0000 2007
- Committer: fbos (fbos@d6c2ea82-c31b-0410-8381-e9c44f9824c5)
- Author: fbos (fbos@d6c2ea82-c31b-0410-8381-e9c44f9824c5)
- Commit SHA1: 5ec8d4d295efba114a8afa3c5cbe0dad50b5bbe2
- Tree SHA1: 2387c71413c486f357a486cc9a584d1840f28e56
Added Piston::Repository#destroy! and #last_changed_rev
git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@132 d6c2ea82-c31b-0410-8381-e9c44f9824c5
Commit diff
| |   |
| 21 | 21 | end |
| 22 | 22 | end |
| 23 | 23 | |
| 24 | class NoDestroyOnRemoteRepositoryUrl < RepositoryError |
| 25 | def initialize(url) |
| 26 | super "URL #{url.inspect} is remote -- cannot destroy there" |
| 27 | end |
| 28 | end |
| 29 | |
| 24 | 30 | class FileNotFound < RepositoryError |
| 25 | 31 | def initialize(url, revision) |
| 26 | 32 | super "URL #{url.inspect} does not exist in revision #{revision}" |
| … | … | |
| 68 | 68 | def youngest |
| 69 | 69 | self.info["Revision"].to_i |
| 70 | 70 | end |
| 71 | |
| 72 | def last_changed_rev |
| 73 | self.info["Last Changed Rev"].to_i |
| 74 | end |
| 71 | 75 | |
| 72 | 76 | def uuid |
| 73 | 77 | self.info["Repository UUID"] |
| … | … | |
| 96 | 96 | FileUtils.mkdir_p(repos_parent_dir) |
| 97 | 97 | raise DirectoryAlreadyExists.new(self.local_path) if File.directory?(self.local_path) |
| 98 | 98 | |
| 99 | | svnadmin :create, local_path |
| 99 | svnadmin :create, self.local_path |
| 100 | 100 | self |
| 101 | 101 | end |
| 102 | |
| 103 | # Deletes the repository if it is a local one |
| 104 | def destroy! |
| 105 | raise NoDestroyOnRemoteRepositoryUrl.new(self.url) unless self.url =~ %r{\Afile://} |
| 106 | FileUtils.rm_rf(self.local_path) |
| 107 | self |
| 108 | end |
| 102 | 109 | end |
| 103 | 110 | end |
| toggle raw diff |
--- a/lib/piston/repository.rb
+++ b/lib/piston/repository.rb
@@ -21,6 +21,12 @@ module Piston
end
end
+ class NoDestroyOnRemoteRepositoryUrl < RepositoryError
+ def initialize(url)
+ super "URL #{url.inspect} is remote -- cannot destroy there"
+ end
+ end
+
class FileNotFound < RepositoryError
def initialize(url, revision)
super "URL #{url.inspect} does not exist in revision #{revision}"
@@ -62,6 +68,10 @@ module Piston
def youngest
self.info["Revision"].to_i
end
+
+ def last_changed_rev
+ self.info["Last Changed Rev"].to_i
+ end
def uuid
self.info["Repository UUID"]
@@ -86,8 +96,15 @@ module Piston
FileUtils.mkdir_p(repos_parent_dir)
raise DirectoryAlreadyExists.new(self.local_path) if File.directory?(self.local_path)
- svnadmin :create, local_path
+ svnadmin :create, self.local_path
self
end
+
+ # Deletes the repository if it is a local one
+ def destroy!
+ raise NoDestroyOnRemoteRepositoryUrl.new(self.url) unless self.url =~ %r{\Afile://}
+ FileUtils.rm_rf(self.local_path)
+ self
+ end
end
end
|