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
- (Node) initialize(opts = {})
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
- (Object) executable
Executable flag of the node (if file).
21
22
23
|
# File 'lib/mercurial-ruby/node.rb', line 21
def executable
@executable
end
|
- (Object) fmode
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
|
- (Object) nodeid
nodeid value for the node (if file).
24
25
26
|
# File 'lib/mercurial-ruby/node.rb', line 24
def nodeid
@nodeid
end
|
- (Object) parent
Node's parent, instance of Node.
27
28
29
|
# File 'lib/mercurial-ruby/node.rb', line 27
def parent
@parent
end
|
- (Object) path
Absolute path to the node.
15
16
17
|
# File 'lib/mercurial-ruby/node.rb', line 15
def path
@path
end
|
- (Object) repository
12
13
14
|
# File 'lib/mercurial-ruby/node.rb', line 12
def repository
@repository
end
|
Instance Method Details
- (Boolean) binary?
90
91
92
|
# File 'lib/mercurial-ruby/node.rb', line 90
def binary?
false
end
|
- (Object) blame
68
69
70
|
# File 'lib/mercurial-ruby/node.rb', line 68
def blame
repository.blames.for_path(path, revision)
end
|
- (Object) contents
94
95
96
|
# File 'lib/mercurial-ruby/node.rb', line 94
def contents
hg(["cat ? -r ?", path, revision])
end
|
- (Object) diff_to(revision_b, options = {})
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
|
- (Boolean) directory?
78
79
80
|
# File 'lib/mercurial-ruby/node.rb', line 78
def directory?
not file?
end
|
- (Object) entries
60
61
62
|
# File 'lib/mercurial-ruby/node.rb', line 60
def entries
@_entries ||= repository.nodes.entries_for(path, revision, self)
end
|
- (Boolean) file?
82
83
84
|
# File 'lib/mercurial-ruby/node.rb', line 82
def file?
(name =~ /\/$/).nil?
end
|
- (Boolean) has_entry?(name)
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
|
- (Object) name
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
|
- (Object) path_without_parent
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
|
- (Object) revision
48
49
50
|
# File 'lib/mercurial-ruby/node.rb', line 48
def revision
@revision || (parent ? parent.revision : nil) || 'tip'
end
|
- (Boolean) root?
86
87
88
|
# File 'lib/mercurial-ruby/node.rb', line 86
def root?
false
end
|
- (Object) size
98
99
100
|
# File 'lib/mercurial-ruby/node.rb', line 98
def size
contents.size
end
|