Class: Mercurial::Repository
- Inherits:
-
Object
- Object
- Mercurial::Repository
- Defined in:
- lib/mercurial-ruby/repository.rb
Class Method Summary collapse
- .clone(url, destination, cmd_options) ⇒ Object
- .create(destination) ⇒ Object
- .open(destination) ⇒ Object
Instance Method Summary collapse
- #blames ⇒ Object
- #branches ⇒ Object
- #cache_disabled_by_override? ⇒ Boolean
- #clone(destination_path, cmd_options = {}) ⇒ Object
- #commits ⇒ Object
- #config ⇒ Object
- #destroy! ⇒ Object
- #diffs ⇒ Object
- #dothg_path ⇒ Object
- #file_index ⇒ Object
- #file_system_url ⇒ Object
- #hooks ⇒ Object
-
#initialize(source) ⇒ Repository
constructor
A new instance of Repository.
- #manifest ⇒ Object
- #mtime ⇒ Object
- #no_cache ⇒ Object
- #node(name, hash_id) ⇒ Object
- #nodes ⇒ Object
- #path ⇒ Object
- #paths ⇒ Object
- #pull(origin = 'default', cmd_options = {}) ⇒ Object
- #shell ⇒ Object
- #tags ⇒ Object
- #verify ⇒ Object
Constructor Details
#initialize(source) ⇒ Repository
Returns a new instance of Repository.
25 26 27 |
# File 'lib/mercurial-ruby/repository.rb', line 25 def initialize(source) @path = source end |
Class Method Details
.clone(url, destination, cmd_options) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mercurial-ruby/repository.rb', line 18 def self.clone(url, destination, ) create_destination(destination) opts = .merge(:append_hg => true) Mercurial::Shell.run(["clone ? ?", url, destination], opts) open(destination) end |
.create(destination) ⇒ Object
6 7 8 |
# File 'lib/mercurial-ruby/repository.rb', line 6 def self.create(destination) init_repository(destination) end |
.open(destination) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/mercurial-ruby/repository.rb', line 10 def self.open(destination) if File.exists?(destination) new(destination) else raise Mercurial::RepositoryNotFound.new(destination) end end |
Instance Method Details
#blames ⇒ Object
61 62 63 |
# File 'lib/mercurial-ruby/repository.rb', line 61 def blames @_blames ||= Mercurial::BlameFactory.new(self) end |
#branches ⇒ Object
45 46 47 |
# File 'lib/mercurial-ruby/repository.rb', line 45 def branches @_branches ||= Mercurial::BranchFactory.new(self) end |
#cache_disabled_by_override? ⇒ Boolean
127 128 129 |
# File 'lib/mercurial-ruby/repository.rb', line 127 def cache_disabled_by_override? @cache_disabled_by_override || false end |
#clone(destination_path, cmd_options = {}) ⇒ Object
77 78 79 |
# File 'lib/mercurial-ruby/repository.rb', line 77 def clone(destination_path, ={}) self.class.clone(file_system_url, destination_path, ) end |
#commits ⇒ Object
41 42 43 |
# File 'lib/mercurial-ruby/repository.rb', line 41 def commits @_commits ||= Mercurial::CommitFactory.new(self) end |
#config ⇒ Object
33 34 35 |
# File 'lib/mercurial-ruby/repository.rb', line 33 def config @_config ||= Mercurial::ConfigFile.new(self) end |
#destroy! ⇒ Object
101 102 103 |
# File 'lib/mercurial-ruby/repository.rb', line 101 def destroy! FileUtils.rm_rf(path) end |
#diffs ⇒ Object
53 54 55 |
# File 'lib/mercurial-ruby/repository.rb', line 53 def diffs @_diffs ||= Mercurial::DiffFactory.new(self) end |
#dothg_path ⇒ Object
113 114 115 |
# File 'lib/mercurial-ruby/repository.rb', line 113 def dothg_path File.join(path, '.hg') end |
#file_index ⇒ Object
69 70 71 |
# File 'lib/mercurial-ruby/repository.rb', line 69 def file_index @_file_index ||= Mercurial::FileIndex.new(self) end |
#file_system_url ⇒ Object
105 106 107 |
# File 'lib/mercurial-ruby/repository.rb', line 105 def file_system_url %Q[file://#{ path }] end |
#hooks ⇒ Object
37 38 39 |
# File 'lib/mercurial-ruby/repository.rb', line 37 def hooks @_hook_factory ||= Mercurial::HookFactory.new(self) end |
#manifest ⇒ Object
65 66 67 |
# File 'lib/mercurial-ruby/repository.rb', line 65 def manifest @_manifest ||= Mercurial::Manifest.new(self) end |
#mtime ⇒ Object
117 118 119 |
# File 'lib/mercurial-ruby/repository.rb', line 117 def mtime File.mtime(dothg_path).to_i end |
#no_cache ⇒ Object
121 122 123 124 125 |
# File 'lib/mercurial-ruby/repository.rb', line 121 def no_cache @cache_disabled_by_override = true yield @cache_disabled_by_override = false end |
#node(name, hash_id) ⇒ Object
73 74 75 |
# File 'lib/mercurial-ruby/repository.rb', line 73 def node(name, hash_id) nodes.find(name, hash_id) end |
#nodes ⇒ Object
57 58 59 |
# File 'lib/mercurial-ruby/repository.rb', line 57 def nodes @_nodes ||= Mercurial::NodeFactory.new(self) end |
#path ⇒ Object
109 110 111 |
# File 'lib/mercurial-ruby/repository.rb', line 109 def path File.(@path) end |
#paths ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/mercurial-ruby/repository.rb', line 92 def paths {}.tap do |result| shell.hg('paths').each do |line| path, url = *line.strip.split(" = ") result[path] = url end end end |
#pull(origin = 'default', cmd_options = {}) ⇒ Object
81 82 83 |
# File 'lib/mercurial-ruby/repository.rb', line 81 def pull(origin='default', ={}) shell.hg(['pull ?', origin], ) end |
#shell ⇒ Object
29 30 31 |
# File 'lib/mercurial-ruby/repository.rb', line 29 def shell @_shell ||= Mercurial::Shell.new(self) end |
#tags ⇒ Object
49 50 51 |
# File 'lib/mercurial-ruby/repository.rb', line 49 def @_tags ||= Mercurial::TagFactory.new(self) end |
#verify ⇒ Object
85 86 87 88 89 90 |
# File 'lib/mercurial-ruby/repository.rb', line 85 def verify shell.hg('verify') true rescue Mercurial::CommandError false end |