--- a/rakelib/hglib.rb Mon Apr 02 07:32:49 2018 +0100
+++ b/rakelib/hglib.rb Mon Apr 02 12:22:04 2018 +0100
@@ -109,11 +109,11 @@
stdout, stderr, status = Open3.capture3(*cmd)
case block.arity
when 1
- STDOUT.print stdout
- STDERR.print stderr
+ STDOUT.print stdout if defined? RakeFileUtils and RakeFileUtils.verbose
+ STDERR.print stderr if defined? RakeFileUtils and RakeFileUtils.verbose
yield status
when 2
- STDERR.print stderr
+ STDERR.print stderr if defined? RakeFileUtils and RakeFileUtils.verbose
yield status, stdout
when 3
yield status, stdout, stderr
@@ -334,11 +334,31 @@
log = []
hg('log', rev: revset, template: template) do |status, out|
if status.success?
- puts out
+ puts out if defined? RakeFileUtils and RakeFileUtils.verbose
log = out.split("\n")
end
end
- log
+ return log
+ end
+
+ def locate(revset = '.', pattern: '*')
+ files = []
+ hg('locate', rev: revset, include: pattern) do |status, out|
+ if status.success?
+ files = out.split("\n")
+ end
+ end
+ return files
+ end
+
+ # Return current branch name
+ def branch()
+ hg('branch') do | status, out |
+ if status.success?
+ return out.strip()
+ end
+ end
+ raise Exception.new("Failed to retrieve current branch")
end
# Return changeset IDs of all head revisions.