Class: Mercurial::Node
- Inherits:
-
Object
show all
- Includes:
- Helper
- Defined in:
- lib/mercurial-ruby/node.rb
Overview
This class represents a file or a directory stored inside a repository. The data is provided by Manifest.
To see how Node instances are assembled, check the NodeFactory.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Helper
#hg, #hg_to_array, #shell
Constructor Details
#initialize(opts = {}) ⇒ Node
Returns a new instance of Node.
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/mercurial-ruby/node.rb', line 29
def initialize(opts={})
@repository = opts[:repository]
@path = opts[:path]
@parent = opts[:parent]
@name = opts[:name]
@fmode = opts[:fmode]
@executable = opts[:executable] == '*' ? true : false
@revision = opts[:revision]
@nodeid = opts[:nodeid]
end
|
Instance Attribute Details
#executable ⇒ Object
Executable flag of the node (if file).
21
22
23
|
# File 'lib/mercurial-ruby/node.rb', line 21
def executable
@executable
end
|
#fmode ⇒ Object
File mode of the node in Octal notation (if file).
18
19
20
|
# File 'lib/mercurial-ruby/node.rb', line 18
def fmode
@fmode
end
|
#nodeid ⇒ Object
nodeid value for the node (if file).
24
25
26
|
# File 'lib/mercurial-ruby/node.rb', line 24
def nodeid
@nodeid
end
|
#parent ⇒ Object
Node’s parent, instance of Node.
27
28
29
|
# File 'lib/mercurial-ruby/node.rb', line 27
def parent
@parent
end
|
#path ⇒ Object
Absolute path to the node.
15
16
17
|
# File 'lib/mercurial-ruby/node.rb', line 15
def path
@path
end
|
#repository ⇒ Object
12
13
14
|
# File 'lib/mercurial-ruby/node.rb', line 12
def repository
@repository
end
|
Instance Method Details
#binary? ⇒ Boolean
90
91
92
|
# File 'lib/mercurial-ruby/node.rb', line 90
def binary?
false
end
|
#blame ⇒ Object
68
69
70
|
# File 'lib/mercurial-ruby/node.rb', line 68
def blame
repository.blames.for_path(path, revision)
end
|
#contents ⇒ Object
94
95
96
|
# File 'lib/mercurial-ruby/node.rb', line 94
def contents
hg(["cat ? -r ?", path, revision])
end
|
#diff_to(revision_b, options = {}) ⇒ Object
64
65
66
|
# File 'lib/mercurial-ruby/node.rb', line 64
def diff_to(revision_b, options={})
repository.diffs.for_path(path, revision, revision_b, options)
end
|
#directory? ⇒ Boolean
78
79
80
|
# File 'lib/mercurial-ruby/node.rb', line 78
def directory?
not file?
end
|
#entries ⇒ Object
60
61
62
|
# File 'lib/mercurial-ruby/node.rb', line 60
def entries
@_entries ||= repository.nodes.entries_for(path, revision, self)
end
|
#file? ⇒ Boolean
82
83
84
|
# File 'lib/mercurial-ruby/node.rb', line 82
def file?
(name =~ /\/$/).nil?
end
|
#has_entry?(name) ⇒ Boolean
72
73
74
75
76
|
# File 'lib/mercurial-ruby/node.rb', line 72
def has_entry?(name)
entries.find do |e|
e.name == name
end
end
|
#name ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/mercurial-ruby/node.rb', line 40
def name
@name ||= begin
n = path.split('/').last
n << '/' if path =~ /\/$/
n
end
end
|
#path_without_parent ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/mercurial-ruby/node.rb', line 52
def path_without_parent
if parent
path.gsub(/^#{ Regexp.escape(parent.path) }/, '')
else
path
end
end
|
#revision ⇒ Object
48
49
50
|
# File 'lib/mercurial-ruby/node.rb', line 48
def revision
@revision || (parent ? parent.revision : nil) || 'tip'
end
|
#root? ⇒ Boolean
86
87
88
|
# File 'lib/mercurial-ruby/node.rb', line 86
def root?
false
end
|
#size ⇒ Object
98
99
100
|
# File 'lib/mercurial-ruby/node.rb', line 98
def size
contents.size
end
|