Toplevel namespace
The default path to the `hg` command
Version control revision
Package version
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
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
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
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
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
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
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
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