mercurial-wrapper 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mercurial.rb +35 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 185e574bb08f9f83c0634b9b2fc9022a051f9cde
4
- data.tar.gz: 5971916e25606783411b06a47c7722b2ba6fe974
3
+ metadata.gz: b9f732f6cd5fba4c97c771474e64a8e25673cede
4
+ data.tar.gz: 2aadf35ea2b76fc0d16c713c0ee6055784636d13
5
5
  SHA512:
6
- metadata.gz: 418b3aa88f2d5e1c1eba66f4d6fc59040dc8379a25df75fe8c9954b46a20c6852646bd6688073d1dbe5ea69cf12c955f92927000a26aa125679a713539d59a53
7
- data.tar.gz: 9296477ba41b5b07ff1c395ecf5f72652eb62171f0581bb6da56084c64ce13c457b3f2985b2dca3c23080cde3408892fe5d51b8a3afad4cdbd458cf73b1501f1
6
+ metadata.gz: 9051e5d61e31b8b7173187ed8921e7b138b322e59dd9f18f5b4eddd51edd5d6e42e34bf16315009c5a033df45bf6b9075c18c8d9ca938b6b7f69b6af2d423d10
7
+ data.tar.gz: 42b6a528630e702c8a207d9a6e95a44ed6eb8978c8da45cf10126c5bbef0823fdb786b927800d3bbb92463236a33bb10be615ffd53ecbe12e0441eb24cc13105
data/lib/mercurial.rb CHANGED
@@ -234,6 +234,41 @@ class Mercurial
234
234
  out.unlink if out
235
235
  end
236
236
 
237
+ def log(options={}, basedir = nil)
238
+ cmd = [hg, 'log']
239
+ cmd += ['-u', options[:user]] if options[:user]
240
+ cmd += ['-l', options[:limit].to_s] if options[:limit]
241
+ cmd += ['-v'] if options[:verbose] if options[:verbose]
242
+ cmd += ['-b', options[:branch]] if options[:branch]
243
+ cmd += ['-p', options[:patch].to_s] if options[:patch]
244
+ cmd += ['-r', options[:revision].to_s] if options[:revision]
245
+ cmd += [options[:filename]] if options[:filename]
246
+ lines = execute_command(cmd, basedir).lines.map(&:chomp)
247
+ return lines if options[:raw]
248
+ to_log_structure(lines)
249
+ end
250
+
251
+ private
252
+
253
+ def to_log_structure(lines)
254
+ elem = {}
255
+ result = []
256
+ iterator = lines.each
257
+ begin
258
+ while true
259
+ line = iterator.next
260
+ result << elem and elem = {} if line.strip.empty? and not elem.empty?
261
+ unless line.strip.empty?
262
+ key, value = line.split(':', 2).map { |item| item.strip.chomp }
263
+ value = iterator.next if value.empty?
264
+ elem[key.to_sym] = value
265
+ end
266
+ end
267
+ rescue StopIteration
268
+ end
269
+ result
270
+ end
271
+
237
272
  end
238
273
 
239
274
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercurial-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Neves