Class: Hglib::Extension::Topic::StackEntry

Inherits:
Object
  • Object
show all
Extended by:
MethodUtilities
Includes:
Inspection
Defined in:
lib/hglib/extension/topic.rb

Overview

A changeset in a topic

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MethodUtilities

attr_predicate, attr_predicate_accessor, singleton_attr_accessor, singleton_attr_reader, singleton_attr_writer, singleton_method_alias

Methods included from Inspection

#inspect

Constructor Details

#initialize(repo, entryhash) ⇒ StackEntry

Create a new StackEntry for the specified repo given an entryhash like that returned by the JSON template for the ‘topics` command.



103
104
105
106
107
108
109
110
111
112
# File 'lib/hglib/extension/topic.rb', line 103

def initialize( repo, entryhash )
	@repo = repo

	@description = entryhash[:desc]
	@is_entry    = entryhash[:isentry]
	@node        = entryhash[:node]
	@stack_index = entryhash[:stack_index]
	@state       = entryhash[:state]
	@symbol      = entryhash[:symbol]
end

Instance Attribute Details

#descriptionObject (readonly) Also known as: desc

The changeset description



125
126
127
# File 'lib/hglib/extension/topic.rb', line 125

def description
  @description
end

#nodeObject (readonly)

The node identifier of the changeset



136
137
138
# File 'lib/hglib/extension/topic.rb', line 136

def node
  @node
end

#repoObject (readonly)

The Hglib::Repo of the repository the changeset belongs to



121
122
123
# File 'lib/hglib/extension/topic.rb', line 121

def repo
  @repo
end

#stack_indexObject (readonly)

The index of the changeset in the topic it is currently in



140
141
142
# File 'lib/hglib/extension/topic.rb', line 140

def stack_index
  @stack_index
end

#stateObject (readonly)

An array of states that apply to this changeset(?) :TODO: Figure out what these mean



145
146
147
# File 'lib/hglib/extension/topic.rb', line 145

def state
  @state
end

#symbolObject (readonly)

A character that represents the changeset’s (state?) :TODO: Figure out what this means



150
151
152
# File 'lib/hglib/extension/topic.rb', line 150

def symbol
  @symbol
end

Instance Method Details

#is_entryObject

True if the changeset is an entry(?) :TODO: Figure out what this means



131
# File 'lib/hglib/extension/topic.rb', line 131

attr_predicate :is_entry

#to_sObject Also known as: inspect_details

Return the entry as a String (in a similar form to the regular ‘hg topics` output)



154
155
156
157
158
159
160
161
162
163
# File 'lib/hglib/extension/topic.rb', line 154

def to_s
	displayed_states = self.state - ['clean']

	rval = String.new( encoding: 'utf-8' )
	rval << %{s%d%s "%s"} % [ self.stack_index, self.symbol, self.description ]
	rval << " (%s)" % [ displayed_states.join(', ') ] unless displayed_states.empty?
	rval.freeze

	return rval
end