lib/scm/hg.rb in scm-0.1.0.pre1 vs lib/scm/hg.rb in scm-0.1.0.pre2
- old
+ new
@@ -33,10 +33,14 @@
#
# @raise [RuntimeError]
# Could not initialize the Hg repository.
#
def self.create(path,options={})
+ if options[:bare]
+ raise("Hg does not support creating bare repositories")
+ end
+
unless path.start_with?('ssh://')
FileUtils.mkdir_p(path)
end
unless (result = system('hg','init',path))
@@ -396,11 +400,11 @@
# The commits in the repository.
#
def commits(options={})
return enum_for(:commits,options) unless block_given?
- arguments = []
+ arguments = ['-v']
if options[:commit]
arguments << '--rev' << options[:commit]
end
@@ -420,16 +424,22 @@
hash = nil
branch = nil
user = nil
date = nil
summary = nil
+ message = nil
+ files = nil
- popen('hg log',*arguments) do |line|
+ io = popen('hg log',*arguments)
+
+ until io.eof?
+ line = io.readline.chomp
+
if line.empty?
- yield Commits::Hg.new(revision,hash,branch,user,date,summary)
+ yield Commits::Hg.new(revision,hash,branch,user,date,summary,message,files)
- revision = hash = branch = user = date = summary = nil
+ revision = hash = branch = user = date = summary = message = files = nil
else
key, value = line.split(' ',2)
case key
when 'changeset:'
@@ -438,14 +448,37 @@
branch = value
when 'user:'
user = value
when 'date:'
date = Time.parse(value)
- when 'summary:'
- summary = value
+ when 'description:'
+ description = readlines_until(io)
+ summary = description[0]
+ message = description.join($/)
+ when 'files:'
+ files = value.split(' ')
end
end
end
+ end
+
+ #
+ # Lists the files of the Hg repository.
+ #
+ # @yield [file]
+ # The given block will be passed each file.
+ #
+ # @yieldparam [String] file
+ # A path of a file tracked by Hg.
+ #
+ # @return [Enumerator]
+ # If no block is given, an Enumerator will be returned.
+ #
+ def files(&block)
+ return enum_for(:files) unless block
+
+ popen('hg','manifest',&block)
+ return nil
end
protected
#