Class: Hglib::Repo::StatusEntry

Inherits:
Object
  • Object
show all
Extended by:
Loggability
Defined in:
lib/hglib/repo/status_entry.rb

Overview

An entry in a repository’s status list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entryhash) ⇒ StatusEntry

Create a new log entry from the raw entryhash.



24
25
26
27
28
# File 'lib/hglib/repo/status_entry.rb', line 24

def initialize( entryhash )
	@path   = Pathname( entryhash[:path] )
	@source = Pathname( entryhash[:source] ) if entryhash.key?( :source )
	@status = entryhash[ :status ]
end

Instance Attribute Details

#pathObject (readonly)

Return the Pathname of the file the status applies to



37
38
39
# File 'lib/hglib/repo/status_entry.rb', line 37

def path
  @path
end

#sourceObject (readonly)

The Pathname of the file the status applies to was copied from (if the status is ‘A`/`added`) and the addition was via a copy/move operation.



42
43
44
# File 'lib/hglib/repo/status_entry.rb', line 42

def source
  @source
end

#statusObject (readonly)

Return the character that denotes the file’s status



46
47
48
# File 'lib/hglib/repo/status_entry.rb', line 46

def status
  @status
end

Instance Method Details

#added?Boolean

Returns true if the status is ‘added’.

Returns:

  • (Boolean)


72
73
74
# File 'lib/hglib/repo/status_entry.rb', line 72

def added?
	return self.status == 'A'
end

#clean?Boolean

Returns true if the status is ‘clean’.

Returns:

  • (Boolean)


84
85
86
# File 'lib/hglib/repo/status_entry.rb', line 84

def clean?
	return self.status == 'C'
end

#ignored?Boolean

Returns true if the status is ‘ignored’.

Returns:

  • (Boolean)


109
110
111
# File 'lib/hglib/repo/status_entry.rb', line 109

def ignored?
	return self.status == 'I'
end

#inspectObject

Return a human-readable representation of the StatusEntry as a String.



115
116
117
118
119
120
121
122
123
# File 'lib/hglib/repo/status_entry.rb', line 115

def inspect
	return "#<%p:#%x %s: %s%s>" % [
		self.class,
		self.object_id * 2,
		self.path,
		self.status_description,
		self.source ? " via copy/move from #{self.source}" : '',
	]
end

#missing?Boolean

Returns true if the status is ‘missing’.

Returns:

  • (Boolean)


90
91
92
# File 'lib/hglib/repo/status_entry.rb', line 90

def missing?
	return self.status == '!'
end

#modified?Boolean

Returns true if the status is ‘modified’.

Returns:

  • (Boolean)


66
67
68
# File 'lib/hglib/repo/status_entry.rb', line 66

def modified?
	return self.status == 'M'
end

#not_tracked?Boolean Also known as: untracked?

Returns true if the status is ‘not tracked’.

Returns:

  • (Boolean)


96
97
98
# File 'lib/hglib/repo/status_entry.rb', line 96

def not_tracked?
	return self.status == '?'
end

#removed?Boolean

Returns true if the status is ‘removed’.

Returns:

  • (Boolean)


78
79
80
# File 'lib/hglib/repo/status_entry.rb', line 78

def removed?
	return self.status == 'R'
end

#status_descriptionObject

Return the human-readable status.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/hglib/repo/status_entry.rb', line 50

def status_description
	return case self.status
		when 'M' then 'modified'
		when 'A' then 'added'
		when 'R' then 'removed'
		when 'C' then 'clean'
		when '!' then 'missing'
		when '?' then 'not tracked'
		when 'I' then 'ignored'
		else
			raise "unknown status %p" % [ self.status ]
		end
end

#tracked?Boolean

Returns true if the status is anything other than ‘not tracked’.

Returns:

  • (Boolean)


103
104
105
# File 'lib/hglib/repo/status_entry.rb', line 103

def tracked?
	return !self.not_tracked?
end