Class: Mercurial::Node
- Inherits:
-
Object
show all
- Includes:
- Helper
- Defined in:
- lib/mercurial-ruby/node.rb
Overview
The class represents Mercurial file or directory. Data obtained by scanning hg manifest output.
The class represents Node object itself, NodeFactory is responsible for assembling instances of Node. For the list of all possible branch-related operations please look documentation for NodeFactory.
Additionally Manifest is responsible for reading and scanning the manifest.
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.
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/mercurial-ruby/node.rb', line 33
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).
25
26
27
|
# File 'lib/mercurial-ruby/node.rb', line 25
def executable
@executable
end
|
#fmode ⇒ Object
File mode of the node in Octal notation (if file).
22
23
24
|
# File 'lib/mercurial-ruby/node.rb', line 22
def fmode
@fmode
end
|
#nodeid ⇒ Object
nodeid value for the node (if file).
28
29
30
|
# File 'lib/mercurial-ruby/node.rb', line 28
def nodeid
@nodeid
end
|
#parent ⇒ Object
Node’s parent, instance of Node.
31
32
33
|
# File 'lib/mercurial-ruby/node.rb', line 31
def parent
@parent
end
|
#path ⇒ Object
Absolute path to the node.
19
20
21
|
# File 'lib/mercurial-ruby/node.rb', line 19
def path
@path
end
|
#repository ⇒ Object
16
17
18
|
# File 'lib/mercurial-ruby/node.rb', line 16
def repository
@repository
end
|
Instance Method Details
#binary? ⇒ Boolean
94
95
96
|
# File 'lib/mercurial-ruby/node.rb', line 94
def binary?
false
end
|
#blame ⇒ Object
72
73
74
|
# File 'lib/mercurial-ruby/node.rb', line 72
def blame
repository.blames.for_path(path, revision)
end
|
#contents ⇒ Object
98
99
100
|
# File 'lib/mercurial-ruby/node.rb', line 98
def contents
hg(["cat ? -r ?", path, revision])
end
|
#diff_to(revision_b) ⇒ Object
68
69
70
|
# File 'lib/mercurial-ruby/node.rb', line 68
def diff_to(revision_b)
repository.diffs.for_path(path, revision, revision_b)
end
|
#directory? ⇒ Boolean
82
83
84
|
# File 'lib/mercurial-ruby/node.rb', line 82
def directory?
not file?
end
|
#entries ⇒ Object
64
65
66
|
# File 'lib/mercurial-ruby/node.rb', line 64
def entries
@_entries ||= repository.nodes.entries_for(path, revision, self)
end
|
#file? ⇒ Boolean
86
87
88
|
# File 'lib/mercurial-ruby/node.rb', line 86
def file?
(name =~ /\/$/).nil?
end
|
#has_entry?(name) ⇒ Boolean
76
77
78
79
80
|
# File 'lib/mercurial-ruby/node.rb', line 76
def has_entry?(name)
entries.find do |e|
e.name == name
end
end
|
#name ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/mercurial-ruby/node.rb', line 44
def name
@name ||= begin
n = path.split('/').last
n << '/' if path =~ /\/$/
n
end
end
|
#path_without_parent ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/mercurial-ruby/node.rb', line 56
def path_without_parent
if parent
path.gsub(/^#{ Regexp.escape(parent.path) }/, '')
else
path
end
end
|
#revision ⇒ Object
52
53
54
|
# File 'lib/mercurial-ruby/node.rb', line 52
def revision
@revision || (parent ? parent.revision : nil) || 'tip'
end
|
#root? ⇒ Boolean
90
91
92
|
# File 'lib/mercurial-ruby/node.rb', line 90
def root?
false
end
|
#size ⇒ Object
102
103
104
|
# File 'lib/mercurial-ruby/node.rb', line 102
def size
contents.size
end
|