Id

class
Superclass
Object
Extended With
Hglib::MethodUtilities

The identification of a particular revision of a repository.

Constants

DEFAULT_BRANCH

The default branch name to use

DEFAULT_ID

The SHA of the zeroth node

DEFAULT_NODE

The SHA of the node when the repo is at tip

Attributes

bookmarks[R]

The bookmarks set on the revision of the repo.

branch[R]

The name of the current branch

global[R]

The long-form revision ID

id[R]

The long-form revision ID

node[R]

The ID of the current changeset node

parents[R]

The current IDs of the current revision's parent(s).

tags[R]

The tags belonging to the revision of the repo.

Public Class Methods

anchor
new( id:, branch: DEFAULT_BRANCH, node: DEFAULT_NODE, dirty: false, parents: [], tags: [], bookmarks: [] )

Create a new repository ID with the given global revision identifier, one or more tags, and other options.

# File lib/hglib/repo/id.rb, line 24
def initialize( id:, branch: DEFAULT_BRANCH, node: DEFAULT_NODE, dirty: false,
        parents: [], tags: [], bookmarks: [] )

        @id = id[ /\p{XDigit}{40}/ ]
        @branch = branch
        @node = node
        @dirty = dirty == '+'
        @tags = Array( tags )
        @parents = Array( parents )
        @bookmarks = Array( bookmarks )
end

Public Instance Methods

anchor
==( other )

Comparison operator – returns true if the other object is another Hglib::Repo::Id with the same values, or a String containing the global revision identifier.

# File lib/hglib/repo/id.rb, line 94
def ==( other )
        return (other.is_a?( self.class ) && self.to_s == other.to_s) ||
                self.global == other
end
anchor
default?()

Returns true if the Id's revision ID is the DEFAULT_ID

# File lib/hglib/repo/id.rb, line 101
def default?
        return self.id == DEFAULT_ID
end
anchor
dirty()

Does the repo have uncommitted changes?

# File lib/hglib/repo/id.rb, line 60
attr_predicate :dirty
anchor
short_id()

Return the short form of the global ID.

# File lib/hglib/repo/id.rb, line 74
def short_id
        return self.id[ 0, 12 ]
end
anchor
to_s()

Return the ID as a String in the form used by the command line.

# File lib/hglib/repo/id.rb, line 80
def to_s
        str = self.global.dup

        str << '+' if self.uncommitted_changes?
        str << ' ' << self.tags.join( '/' ) unless self.tags.empty?
        str << ' ' << self.bookmarks.join( '/' ) unless self.bookmarks.empty?

        return str
end