class Mercurial::Node
This class represents a file or a directory stored inside a repository. The data is provided by {Mercurial::Manifest Manifest}.
To see how Node
instances are assembled, check the {Mercurial::NodeFactory NodeFactory}.
Attributes
executable[R]
Executable flag of the node (if file).
fmode[R]
File mode of the node in Octal notation (if file).
nodeid[R]
nodeid value for the node (if file).
parent[R]
Node's parent, instance of {Mercurial::Node Node}.
path[R]
Absolute path to the node.
repository[R]
Instance of {Mercurial::Repository Repository}.
Public Class Methods
new(opts={})
click to toggle source
# 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
Public Instance Methods
binary?()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 90 def binary? false end
blame()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 68 def blame repository.blames.for_path(path, revision) end
contents()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 94 def contents hg(["cat ? -r ?", path, revision]) end
diff_to(revision_b, options={})
click to toggle source
# 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?()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 78 def directory? not file? end
entries()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 60 def entries @_entries ||= repository.nodes.entries_for(path, revision, self) end
file?()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 82 def file? (name =~ /\/$/).nil? end
has_entry?(name)
click to toggle source
# File lib/mercurial-ruby/node.rb, line 72 def has_entry?(name) entries.find do |e| e.name == name end end
name()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 48 def revision @revision || (parent ? parent.revision : nil) || 'tip' end
root?()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 86 def root? false end
size()
click to toggle source
# File lib/mercurial-ruby/node.rb, line 98 def size contents.size end