Class: Mercurial::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/mercurial-ruby/repository.rb

Class Method Summary collapse

Instance Method Summary collapse

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, cmd_options)
  create_destination(destination)
  opts = cmd_options.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

#blamesObject



61
62
63
# File 'lib/mercurial-ruby/repository.rb', line 61

def blames
  @_blames ||= Mercurial::BlameFactory.new(self)
end

#branchesObject



45
46
47
# File 'lib/mercurial-ruby/repository.rb', line 45

def branches
  @_branches ||= Mercurial::BranchFactory.new(self)
end

#cache_disabled_by_override?Boolean

Returns:

  • (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, cmd_options={})
  self.class.clone(file_system_url, destination_path, cmd_options)
end

#commitsObject



41
42
43
# File 'lib/mercurial-ruby/repository.rb', line 41

def commits
  @_commits ||= Mercurial::CommitFactory.new(self)
end

#configObject



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

#diffsObject



53
54
55
# File 'lib/mercurial-ruby/repository.rb', line 53

def diffs
  @_diffs ||= Mercurial::DiffFactory.new(self)
end

#dothg_pathObject



113
114
115
# File 'lib/mercurial-ruby/repository.rb', line 113

def dothg_path
  File.join(path, '.hg')
end

#file_indexObject



69
70
71
# File 'lib/mercurial-ruby/repository.rb', line 69

def file_index
  @_file_index ||= Mercurial::FileIndex.new(self)
end

#file_system_urlObject



105
106
107
# File 'lib/mercurial-ruby/repository.rb', line 105

def file_system_url
  %Q[file://#{ path }]
end

#hooksObject



37
38
39
# File 'lib/mercurial-ruby/repository.rb', line 37

def hooks
  @_hook_factory ||= Mercurial::HookFactory.new(self)
end

#manifestObject



65
66
67
# File 'lib/mercurial-ruby/repository.rb', line 65

def manifest
  @_manifest ||= Mercurial::Manifest.new(self)
end

#mtimeObject



117
118
119
# File 'lib/mercurial-ruby/repository.rb', line 117

def mtime
  File.mtime(dothg_path).to_i
end

#no_cacheObject



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

#nodesObject



57
58
59
# File 'lib/mercurial-ruby/repository.rb', line 57

def nodes
  @_nodes ||= Mercurial::NodeFactory.new(self)
end

#pathObject



109
110
111
# File 'lib/mercurial-ruby/repository.rb', line 109

def path
  File.expand_path(@path)
end

#pathsObject



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', cmd_options={})
  shell.hg(['pull ?', origin], cmd_options)
end

#shellObject



29
30
31
# File 'lib/mercurial-ruby/repository.rb', line 29

def shell
  @_shell ||= Mercurial::Shell.new(self)
end

#tagsObject



49
50
51
# File 'lib/mercurial-ruby/repository.rb', line 49

def tags
  @_tags ||= Mercurial::TagFactory.new(self)
end

#verifyObject



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