Hglib

module
Extended With
Loggability
Hglib::VersionInfo

Toplevel namespace

Constants

DEFAULT_HG_PATH

The default path to the `hg` command

REVISION

Version control revision

VERSION

Package version

Public Class Methods

anchor
clone( source_repo, local_dir=nil, **options )

Clone the source_repo to the specified local_dir, which defaults to a directory with the basename of the source_repo in the current working directory.

# File lib/hglib.rb, line 175
def self::clone( source_repo, local_dir=nil, **options )
        output = self.server.run( :clone, source_repo, local_dir, **options )
        self.log.debug "Clone output: %s" % [ output ]

        local_dir ||= Pathname.pwd + File.basename( source_repo )
        return self.repo( local_dir )
end
anchor
hg_path()

Return the currently-configured path to the `hg` binary./

# File lib/hglib.rb, line 123
def self::hg_path
        return @hg_path ||= DEFAULT_HG_PATH
end
anchor
hg_path=( new_path )

Set the path to the `hg` binary that will be used for any new commands.

# File lib/hglib.rb, line 129
def self::hg_path=( new_path )
        @hg_path = Pathname( new_path )
end
anchor
init( dir, **options )

Initialize a repository in the given dir and return a Hglib::Repo for it.

# File lib/hglib.rb, line 186
def self::init( dir, **options )
        output = self.server.run( :init, dir, **options )
        self.log.debug "Init output: %s" % [ output ]

        return self.repo( dir )
end
anchor
is_repo?( dir )

Returns true if the specified dir looks like it is a Mercurial repository.

# File lib/hglib.rb, line 159
def self::is_repo?( dir )
        dir = Pathname( dir )
        hgdir = dir + '.hg'
        return dir.directory? && hgdir.directory?
end
anchor
repo( path='.' )

Return an Hglib::Repo object for the specified path.

# File lib/hglib.rb, line 167
def self::repo( path='.' )
        return Hglib::Repo.new( path )
end
anchor
reset_server()

Shut down and remove the ::server if one exists. Mostly used for testing.

# File lib/hglib.rb, line 149
def self::reset_server
        if ( server = @hg_server )
                @hg_server = nil
                server.stop
        end
end
anchor
server()

Return an Hglib::Server started with no repository.

# File lib/hglib.rb, line 143
def self::server
        return @hg_server ||= Hglib::Server.new( nil )
end