mercurial-ruby 0.3.0 → 0.4.0

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 (127) hide show
  1. data/VERSION +1 -1
  2. data/lib/mercurial-ruby.rb +4 -1
  3. data/lib/mercurial-ruby/blame.rb +29 -0
  4. data/lib/mercurial-ruby/blame_line.rb +19 -0
  5. data/lib/mercurial-ruby/factories/blame_factory.rb +28 -0
  6. data/lib/mercurial-ruby/repository.rb +4 -0
  7. data/mercurial-ruby.gemspec +8 -117
  8. data/test/fixtures/test-repo.zip +0 -0
  9. data/test/helper.rb +13 -1
  10. data/test/test_blame.rb +28 -0
  11. data/test/test_blame_factory.rb +43 -0
  12. metadata +10 -119
  13. data/test/fixtures/test-repo/.DotFile +0 -1
  14. data/test/fixtures/test-repo/.hg/00changelog.i +0 -0
  15. data/test/fixtures/test-repo/.hg/branch +0 -1
  16. data/test/fixtures/test-repo/.hg/cache/branchheads +0 -6
  17. data/test/fixtures/test-repo/.hg/cache/tags +0 -7
  18. data/test/fixtures/test-repo/.hg/dirstate +0 -0
  19. data/test/fixtures/test-repo/.hg/hgrc +0 -3
  20. data/test/fixtures/test-repo/.hg/last-message.txt +0 -1
  21. data/test/fixtures/test-repo/.hg/requires +0 -4
  22. data/test/fixtures/test-repo/.hg/store/00changelog.i +0 -0
  23. data/test/fixtures/test-repo/.hg/store/00manifest.i +0 -0
  24. data/test/fixtures/test-repo/.hg/store/data/_file _with _whitespace.pdf.i +0 -0
  25. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e.txt.i +0 -0
  26. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e2.txt.i +0 -0
  27. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e3.txt.i +0 -0
  28. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e4.txt.i +0 -0
  29. data/test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markdown.i +0 -0
  30. data/test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markup.i +0 -0
  31. data/test/fixtures/test-repo/.hg/store/data/_rakefile.i +0 -0
  32. data/test/fixtures/test-repo/.hg/store/data/_rakefile2.i +0 -0
  33. data/test/fixtures/test-repo/.hg/store/data/_rakefile3.i +0 -0
  34. data/test/fixtures/test-repo/.hg/store/data/check ~5c this ~5c out ~22 now.i +0 -0
  35. data/test/fixtures/test-repo/.hg/store/data/directory two/minitest__mixin.rb.i +0 -0
  36. data/test/fixtures/test-repo/.hg/store/data/directory two/options.rb.i +0 -0
  37. data/test/fixtures/test-repo/.hg/store/data/directory two/rdoc__mixin.rb.i +0 -0
  38. data/test/fixtures/test-repo/.hg/store/data/directory two/rspec__mixin.rb.i +0 -0
  39. data/test/fixtures/test-repo/.hg/store/data/directory two/shindo__mixin.rb.i +0 -0
  40. data/test/fixtures/test-repo/.hg/store/data/directory two/shoulda__mixin.rb.i +0 -0
  41. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_gemfile.i +0 -0
  42. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_l_i_c_e_n_s_e.txt.i +0 -0
  43. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_r_e_a_d_m_e.rdoc.i +0 -0
  44. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_rakefile.i +0 -0
  45. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/flunking.rb.i +0 -0
  46. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/helper.rb.i +0 -0
  47. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bundler__setup.erb.i +0 -0
  48. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/features/default.feature.i +0 -0
  49. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/features/support/env.rb.i +0 -0
  50. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/jeweler__tasks.erb.i +0 -0
  51. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/flunking.rb.i +0 -0
  52. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/helper.rb.i +0 -0
  53. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/flunking.rb.i +0 -0
  54. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/helper.rb.i +0 -0
  55. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/other__tasks.erb.i +0 -0
  56. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/flunking.rb.i +0 -0
  57. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/helper.rb.i +0 -0
  58. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/flunking.rb.i +0 -0
  59. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/helper.rb.i +0 -0
  60. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/~2erspec.i +0 -0
  61. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/flunking.rb.i +0 -0
  62. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/helper.rb.i +0 -0
  63. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/flunking.rb.i +0 -0
  64. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/helper.rb.i +0 -0
  65. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/flunking.rb.i +0 -0
  66. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/helper.rb.i +0 -0
  67. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/flunking.rb.i +0 -0
  68. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/helper.rb.i +0 -0
  69. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/~2edocument.i +0 -0
  70. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/~2egitignore.i +0 -0
  71. data/test/fixtures/test-repo/.hg/store/data/directory two/~2e_d_s___store.i +0 -0
  72. data/test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__dot__org__tasks.rb.i +0 -0
  73. data/test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__tasks.rb.i +0 -0
  74. data/test/fixtures/test-repo/.hg/store/data/directory__1/specification.rb.i +0 -0
  75. data/test/fixtures/test-repo/.hg/store/data/directory__1/tasks.rb.i +0 -0
  76. data/test/fixtures/test-repo/.hg/store/data/directory__1/~2e_d_s___store.i +0 -0
  77. data/test/fixtures/test-repo/.hg/store/data/empty-file.i +0 -0
  78. data/test/fixtures/test-repo/.hg/store/data/goose.png.i +0 -0
  79. data/test/fixtures/test-repo/.hg/store/data/goose/pretty-thing.txt.i +0 -0
  80. data/test/fixtures/test-repo/.hg/store/data/new-directory/another-boring-file.i +0 -0
  81. data/test/fixtures/test-repo/.hg/store/data/new-directory/something.csv.i +0 -0
  82. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.d +0 -0
  83. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.i +0 -0
  84. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_file _with _whitespace.pdf.i +0 -0
  85. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/beansprout.png.i +0 -0
  86. data/test/fixtures/test-repo/.hg/store/data/new-file.i +0 -0
  87. data/test/fixtures/test-repo/.hg/store/data/old-directory/minitest__mixin.rb.i +0 -0
  88. data/test/fixtures/test-repo/.hg/store/data/old-directory/options.rb.i +0 -0
  89. data/test/fixtures/test-repo/.hg/store/data/old-directory/rspec__mixin.rb.i +0 -0
  90. data/test/fixtures/test-repo/.hg/store/data/old-directory/shindo__mixin.rb.i +0 -0
  91. data/test/fixtures/test-repo/.hg/store/data/old-directory/testunit__mixin.rb.i +0 -0
  92. data/test/fixtures/test-repo/.hg/store/data/old-directory/yard__mixin.rb.i +0 -0
  93. data/test/fixtures/test-repo/.hg/store/data/riot__mixin.rb.i +0 -0
  94. data/test/fixtures/test-repo/.hg/store/data/riot__mixin__copy.rb.i +0 -0
  95. data/test/fixtures/test-repo/.hg/store/data/style.i +0 -0
  96. data/test/fixtures/test-repo/.hg/store/data/super-cow.i +0 -0
  97. data/test/fixtures/test-repo/.hg/store/data/superman.txt.i +0 -0
  98. data/test/fixtures/test-repo/.hg/store/data/testspec__mixin.rb.i +0 -0
  99. data/test/fixtures/test-repo/.hg/store/data/testspec__mixin__new.rb.i +0 -0
  100. data/test/fixtures/test-repo/.hg/store/data/~2e_dot_file.i +0 -0
  101. data/test/fixtures/test-repo/.hg/store/data/~2ehgignore.i +0 -0
  102. data/test/fixtures/test-repo/.hg/store/data/~2ehgtags.i +0 -0
  103. data/test/fixtures/test-repo/.hg/store/fncache +0 -79
  104. data/test/fixtures/test-repo/.hg/store/undo +0 -0
  105. data/test/fixtures/test-repo/.hg/undo.bookmarks +0 -0
  106. data/test/fixtures/test-repo/.hg/undo.branch +0 -1
  107. data/test/fixtures/test-repo/.hg/undo.desc +0 -2
  108. data/test/fixtures/test-repo/.hg/undo.dirstate +0 -0
  109. data/test/fixtures/test-repo/.hgignore +0 -1
  110. data/test/fixtures/test-repo/.hgtags +0 -1
  111. data/test/fixtures/test-repo/LICENSE3.txt +0 -15
  112. data/test/fixtures/test-repo/LICENSE4.txt +0 -17
  113. data/test/fixtures/test-repo/README.markup +0 -218
  114. data/test/fixtures/test-repo/Rakefile3 +0 -83
  115. data/test/fixtures/test-repo/check // this // out /" now" "b/data/test/fixtures/test-repo/check // this // out / → now +0 -0
  116. data/test/fixtures/test-repo/empty-file +0 -0
  117. data/test/fixtures/test-repo/goose.png +0 -0
  118. data/test/fixtures/test-repo/goose/pretty-thing.txt +0 -0
  119. data/test/fixtures/test-repo/new-directory/another-boring-file +0 -78
  120. data/test/fixtures/test-repo/new-directory/something.csv +0 -1
  121. data/test/fixtures/test-repo/new-directory/subdirectory/EULA5seat_Chin_Sim02.03.04.pdf +0 -0
  122. data/test/fixtures/test-repo/new-directory/subdirectory/File With Whitespace.pdf b/data/test/fixtures/test-repo/new-directory/subdirectory/File With → Whitespace.pdf +0 -0
  123. data/test/fixtures/test-repo/new-directory/subdirectory/beansprout.png +0 -0
  124. data/test/fixtures/test-repo/riot_mixin.rb +0 -45
  125. data/test/fixtures/test-repo/style +0 -4
  126. data/test/fixtures/test-repo/superman.txt +0 -1
  127. data/test/fixtures/test-repo/testspec_mixin_new.rb +0 -44
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -4,7 +4,7 @@
4
4
  #
5
5
  module Mercurial
6
6
 
7
- VERSION = '0.3.0'
7
+ VERSION = '0.4.0'
8
8
 
9
9
  class Error < RuntimeError; end
10
10
 
@@ -55,6 +55,8 @@ require_local 'mercurial-ruby/tag'
55
55
  require_local 'mercurial-ruby/manifest'
56
56
  require_local 'mercurial-ruby/node'
57
57
  require_local 'mercurial-ruby/root_node'
58
+ require_local 'mercurial-ruby/blame'
59
+ require_local 'mercurial-ruby/blame_line'
58
60
  require_local 'mercurial-ruby/file_index'
59
61
 
60
62
  require_local 'mercurial-ruby/factories/hook_factory'
@@ -64,3 +66,4 @@ require_local 'mercurial-ruby/factories/diff_factory'
64
66
  require_local 'mercurial-ruby/factories/branch_factory'
65
67
  require_local 'mercurial-ruby/factories/tag_factory'
66
68
  require_local 'mercurial-ruby/factories/node_factory'
69
+ require_local 'mercurial-ruby/factories/blame_factory'
@@ -0,0 +1,29 @@
1
+ module Mercurial
2
+
3
+ class Blame
4
+
5
+ attr_reader :repository
6
+ attr_reader :contents
7
+
8
+ def initialize(repository, data)
9
+ @repository = repository
10
+ @contents = data
11
+ end
12
+
13
+ def lines
14
+ [].tap do |result|
15
+ contents.each do |line|
16
+ author, revision, linenum, text = line.scan(/^(.+) (\w{12}): *(\d+): (.*)$/).first
17
+ result << BlameLine.new(
18
+ :author => author,
19
+ :revision => revision,
20
+ :num => linenum,
21
+ :contents => text
22
+ )
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,19 @@
1
+ module Mercurial
2
+
3
+ class BlameLine
4
+
5
+ attr_reader :author
6
+ attr_reader :num
7
+ attr_reader :revision
8
+ attr_reader :contents
9
+
10
+ def initialize(attrs={})
11
+ @author = attrs[:author]
12
+ @num = attrs[:num].to_i
13
+ @revision = attrs[:revision]
14
+ @contents = attrs[:contents]
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,28 @@
1
+ module Mercurial
2
+
3
+ class BlameFactory
4
+ include Mercurial::Helper
5
+
6
+ attr_reader :repository
7
+
8
+ def initialize(repository)
9
+ @repository = repository
10
+ end
11
+
12
+ def for_path(path, revision=nil)
13
+ revision ||= 'tip'
14
+ build do
15
+ hg(["blame ? -ucl -r ?", path, revision])
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def build(data=nil, &block)
22
+ data ||= block.call
23
+ Mercurial::Blame.new(repository, data)
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -51,6 +51,10 @@ module Mercurial
51
51
  @_nodes ||= Mercurial::NodeFactory.new(self)
52
52
  end
53
53
 
54
+ def blames
55
+ @_blames ||= Mercurial::BlameFactory.new(self)
56
+ end
57
+
54
58
  def manifest
55
59
  @_manifest ||= Mercurial::Manifest.new(self)
56
60
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mercurial-ruby}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ilya Sabanin"]
12
- s.date = %q{2011-09-03}
12
+ s.date = %q{2011-09-15}
13
13
  s.description = %q{Ruby API for Mercurial DVCS.}
14
14
  s.email = %q{ilya.sabanin@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,8 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "lib/mercurial-ruby.rb",
28
+ "lib/mercurial-ruby/blame.rb",
29
+ "lib/mercurial-ruby/blame_line.rb",
28
30
  "lib/mercurial-ruby/branch.rb",
29
31
  "lib/mercurial-ruby/changed_file.rb",
30
32
  "lib/mercurial-ruby/command.rb",
@@ -32,6 +34,7 @@ Gem::Specification.new do |s|
32
34
  "lib/mercurial-ruby/config_file.rb",
33
35
  "lib/mercurial-ruby/configuration.rb",
34
36
  "lib/mercurial-ruby/diff.rb",
37
+ "lib/mercurial-ruby/factories/blame_factory.rb",
35
38
  "lib/mercurial-ruby/factories/branch_factory.rb",
36
39
  "lib/mercurial-ruby/factories/changed_file_factory.rb",
37
40
  "lib/mercurial-ruby/factories/commit_factory.rb",
@@ -54,122 +57,10 @@ Gem::Specification.new do |s|
54
57
  "lib/styles/file_index.style",
55
58
  "mercurial-ruby.gemspec",
56
59
  "test/fixtures.rb",
57
- "test/fixtures/test-repo/.DotFile",
58
- "test/fixtures/test-repo/.hg/00changelog.i",
59
- "test/fixtures/test-repo/.hg/branch",
60
- "test/fixtures/test-repo/.hg/cache/branchheads",
61
- "test/fixtures/test-repo/.hg/cache/tags",
62
- "test/fixtures/test-repo/.hg/dirstate",
63
- "test/fixtures/test-repo/.hg/hgrc",
64
- "test/fixtures/test-repo/.hg/last-message.txt",
65
- "test/fixtures/test-repo/.hg/requires",
66
- "test/fixtures/test-repo/.hg/store/00changelog.i",
67
- "test/fixtures/test-repo/.hg/store/00manifest.i",
68
- "test/fixtures/test-repo/.hg/store/data/_file _with _whitespace.pdf.i",
69
- "test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e.txt.i",
70
- "test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e2.txt.i",
71
- "test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e3.txt.i",
72
- "test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e4.txt.i",
73
- "test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markdown.i",
74
- "test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markup.i",
75
- "test/fixtures/test-repo/.hg/store/data/_rakefile.i",
76
- "test/fixtures/test-repo/.hg/store/data/_rakefile2.i",
77
- "test/fixtures/test-repo/.hg/store/data/_rakefile3.i",
78
- "test/fixtures/test-repo/.hg/store/data/check ~5c this ~5c out ~22 now.i",
79
- "test/fixtures/test-repo/.hg/store/data/directory two/minitest__mixin.rb.i",
80
- "test/fixtures/test-repo/.hg/store/data/directory two/options.rb.i",
81
- "test/fixtures/test-repo/.hg/store/data/directory two/rdoc__mixin.rb.i",
82
- "test/fixtures/test-repo/.hg/store/data/directory two/rspec__mixin.rb.i",
83
- "test/fixtures/test-repo/.hg/store/data/directory two/shindo__mixin.rb.i",
84
- "test/fixtures/test-repo/.hg/store/data/directory two/shoulda__mixin.rb.i",
85
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/_gemfile.i",
86
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/_l_i_c_e_n_s_e.txt.i",
87
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/_r_e_a_d_m_e.rdoc.i",
88
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/_rakefile.i",
89
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/flunking.rb.i",
90
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/helper.rb.i",
91
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/bundler__setup.erb.i",
92
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/features/default.feature.i",
93
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/features/support/env.rb.i",
94
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/jeweler__tasks.erb.i",
95
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/flunking.rb.i",
96
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/helper.rb.i",
97
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/flunking.rb.i",
98
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/helper.rb.i",
99
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/other__tasks.erb.i",
100
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/flunking.rb.i",
101
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/helper.rb.i",
102
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/flunking.rb.i",
103
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/helper.rb.i",
104
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/~2erspec.i",
105
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/flunking.rb.i",
106
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/helper.rb.i",
107
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/flunking.rb.i",
108
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/helper.rb.i",
109
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/flunking.rb.i",
110
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/helper.rb.i",
111
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/flunking.rb.i",
112
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/helper.rb.i",
113
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/~2edocument.i",
114
- "test/fixtures/test-repo/.hg/store/data/directory two/templates/~2egitignore.i",
115
- "test/fixtures/test-repo/.hg/store/data/directory two/~2e_d_s___store.i",
116
- "test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__dot__org__tasks.rb.i",
117
- "test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__tasks.rb.i",
118
- "test/fixtures/test-repo/.hg/store/data/directory__1/specification.rb.i",
119
- "test/fixtures/test-repo/.hg/store/data/directory__1/tasks.rb.i",
120
- "test/fixtures/test-repo/.hg/store/data/directory__1/~2e_d_s___store.i",
121
- "test/fixtures/test-repo/.hg/store/data/empty-file.i",
122
- "test/fixtures/test-repo/.hg/store/data/goose.png.i",
123
- "test/fixtures/test-repo/.hg/store/data/goose/pretty-thing.txt.i",
124
- "test/fixtures/test-repo/.hg/store/data/new-directory/another-boring-file.i",
125
- "test/fixtures/test-repo/.hg/store/data/new-directory/something.csv.i",
126
- "test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.d",
127
- "test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.i",
128
- "test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_file _with _whitespace.pdf.i",
129
- "test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/beansprout.png.i",
130
- "test/fixtures/test-repo/.hg/store/data/new-file.i",
131
- "test/fixtures/test-repo/.hg/store/data/old-directory/minitest__mixin.rb.i",
132
- "test/fixtures/test-repo/.hg/store/data/old-directory/options.rb.i",
133
- "test/fixtures/test-repo/.hg/store/data/old-directory/rspec__mixin.rb.i",
134
- "test/fixtures/test-repo/.hg/store/data/old-directory/shindo__mixin.rb.i",
135
- "test/fixtures/test-repo/.hg/store/data/old-directory/testunit__mixin.rb.i",
136
- "test/fixtures/test-repo/.hg/store/data/old-directory/yard__mixin.rb.i",
137
- "test/fixtures/test-repo/.hg/store/data/riot__mixin.rb.i",
138
- "test/fixtures/test-repo/.hg/store/data/riot__mixin__copy.rb.i",
139
- "test/fixtures/test-repo/.hg/store/data/style.i",
140
- "test/fixtures/test-repo/.hg/store/data/super-cow.i",
141
- "test/fixtures/test-repo/.hg/store/data/superman.txt.i",
142
- "test/fixtures/test-repo/.hg/store/data/testspec__mixin.rb.i",
143
- "test/fixtures/test-repo/.hg/store/data/testspec__mixin__new.rb.i",
144
- "test/fixtures/test-repo/.hg/store/data/~2e_dot_file.i",
145
- "test/fixtures/test-repo/.hg/store/data/~2ehgignore.i",
146
- "test/fixtures/test-repo/.hg/store/data/~2ehgtags.i",
147
- "test/fixtures/test-repo/.hg/store/fncache",
148
- "test/fixtures/test-repo/.hg/store/undo",
149
- "test/fixtures/test-repo/.hg/undo.bookmarks",
150
- "test/fixtures/test-repo/.hg/undo.branch",
151
- "test/fixtures/test-repo/.hg/undo.desc",
152
- "test/fixtures/test-repo/.hg/undo.dirstate",
153
- "test/fixtures/test-repo/.hgignore",
154
- "test/fixtures/test-repo/.hgtags",
155
- "test/fixtures/test-repo/LICENSE3.txt",
156
- "test/fixtures/test-repo/LICENSE4.txt",
157
- "test/fixtures/test-repo/README.markup",
158
- "test/fixtures/test-repo/Rakefile3",
159
- "test/fixtures/test-repo/check \\ this \\ out \" now",
160
- "test/fixtures/test-repo/empty-file",
161
- "test/fixtures/test-repo/goose.png",
162
- "test/fixtures/test-repo/goose/pretty-thing.txt",
163
- "test/fixtures/test-repo/new-directory/another-boring-file",
164
- "test/fixtures/test-repo/new-directory/something.csv",
165
- "test/fixtures/test-repo/new-directory/subdirectory/EULA5seat_Chin_Sim02.03.04.pdf",
166
- "test/fixtures/test-repo/new-directory/subdirectory/File With Whitespace.pdf",
167
- "test/fixtures/test-repo/new-directory/subdirectory/beansprout.png",
168
- "test/fixtures/test-repo/riot_mixin.rb",
169
- "test/fixtures/test-repo/style",
170
- "test/fixtures/test-repo/superman.txt",
171
- "test/fixtures/test-repo/testspec_mixin_new.rb",
60
+ "test/fixtures/test-repo.zip",
172
61
  "test/helper.rb",
62
+ "test/test_blame.rb",
63
+ "test/test_blame_factory.rb",
173
64
  "test/test_branch_factory.rb",
174
65
  "test/test_changed_file.rb",
175
66
  "test/test_changed_file_factory.rb",
Binary file
data/test/helper.rb CHANGED
@@ -16,10 +16,20 @@ require "minitest/autorun"
16
16
  $LOAD_PATH.unshift(File.dirname(__FILE__))
17
17
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
18
 
19
+ $stderr.reopen('/dev/null')
20
+
19
21
  require 'mercurial-ruby'
20
22
  require 'fixtures'
21
23
 
22
- $stderr.reopen('/dev/null')
24
+ def erase_fixture_repository
25
+ `rm -Rf #{File.join(File.dirname(__FILE__), 'fixtures', 'test-repo')}`
26
+ end
27
+
28
+ def unpack_fixture_repository
29
+ `unzip #{File.join(File.dirname(__FILE__), 'fixtures', 'test-repo.zip')} -d #{File.join(File.dirname(__FILE__), 'fixtures')}`
30
+ end
31
+ erase_fixture_repository
32
+ unpack_fixture_repository
23
33
 
24
34
  class MiniTest::Unit::TestCase
25
35
  include Mocha::API
@@ -38,4 +48,6 @@ private
38
48
 
39
49
  end
40
50
 
51
+ MiniTest::Unit.after_tests { erase_fixture_repository }
52
+
41
53
  MiniTest::Unit.autorun
@@ -0,0 +1,28 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::Blame do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ @factory = @repository.blames
8
+ end
9
+
10
+ it "should compile blames into lines" do
11
+ blame = @factory.for_path('LICENSE4.txt')
12
+ lines = blame.lines
13
+ lines.must_be_kind_of Array
14
+ lines.size.must_equal 17
15
+
16
+ lines[0].must_be_kind_of Mercurial::BlameLine
17
+ lines[0].author.must_equal 'ilya'
18
+ lines[0].revision.must_equal 'bf6386c0a0cc'
19
+ lines[0].num.must_equal 1
20
+ lines[0].contents.must_equal 'Copyright (c) 2008 Josh Nichols'
21
+
22
+ lines[3].author.must_equal 'ilya'
23
+ lines[3].revision.must_equal '825fd6032c3b'
24
+ lines[3].num.must_equal 4
25
+ lines[3].contents.must_equal ''
26
+ end
27
+
28
+ end
@@ -0,0 +1,43 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::BlameFactory do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ @factory = @repository.blames
8
+ end
9
+
10
+ it "should find blame by filename" do
11
+ blame = @factory.for_path('LICENSE4.txt')
12
+ blame.must_be_kind_of(Mercurial::Blame)
13
+ blame.contents.must_equal blame_sample
14
+ end
15
+
16
+ it "should raise exception when file not found" do
17
+ lambda{ @factory.for_path('somecrap') }.must_raise Mercurial::CommandError
18
+ end
19
+
20
+ private
21
+
22
+ def blame_sample
23
+ %Q[ilya bf6386c0a0cc: 1: Copyright (c) 2008 Josh Nichols
24
+ ilya bf6386c0a0cc: 2:
25
+ ilya 825fd6032c3b: 3: Changed!
26
+ ilya 825fd6032c3b: 4:
27
+ ilya bf6386c0a0cc: 3: Permission is hereby granted, free of charge, to any person obtaining
28
+ ilya bf6386c0a0cc: 4: a copy of this software and associated documentation files (the
29
+ ilya bf6386c0a0cc: 5: "Software"), to deal in the Software without restriction, including
30
+ ilya bf6386c0a0cc: 6: without limitation the rights to use, copy, modify, merge, publish,
31
+ ilya bf6386c0a0cc: 7: distribute, sublicense, and/or sell copies of the Software, and to
32
+ ilya bf6386c0a0cc: 8: permit persons to whom the Software is furnished to do so, subject to
33
+ ilya bf6386c0a0cc: 9: the following conditions:
34
+ ilya bf6386c0a0cc:10:
35
+ ilya bf6386c0a0cc:11: The above copyright notice and this permission notice shall be
36
+ ilya bf6386c0a0cc:12: included in all copies or substantial portions of the Software.
37
+ ilya bf6386c0a0cc:13:
38
+ ilya 6157254a4423:14: THE SOFTWARE IS PROVIDED "AS IS", WITHOUROM, OUT OF OR IN CONNECTION
39
+ ilya bf6386c0a0cc:20: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40
+ ]
41
+ end
42
+
43
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercurial-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilya Sabanin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-03 00:00:00 +08:00
18
+ date: 2011-09-15 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -126,6 +126,8 @@ files:
126
126
  - Rakefile
127
127
  - VERSION
128
128
  - lib/mercurial-ruby.rb
129
+ - lib/mercurial-ruby/blame.rb
130
+ - lib/mercurial-ruby/blame_line.rb
129
131
  - lib/mercurial-ruby/branch.rb
130
132
  - lib/mercurial-ruby/changed_file.rb
131
133
  - lib/mercurial-ruby/command.rb
@@ -133,6 +135,7 @@ files:
133
135
  - lib/mercurial-ruby/config_file.rb
134
136
  - lib/mercurial-ruby/configuration.rb
135
137
  - lib/mercurial-ruby/diff.rb
138
+ - lib/mercurial-ruby/factories/blame_factory.rb
136
139
  - lib/mercurial-ruby/factories/branch_factory.rb
137
140
  - lib/mercurial-ruby/factories/changed_file_factory.rb
138
141
  - lib/mercurial-ruby/factories/commit_factory.rb
@@ -155,122 +158,10 @@ files:
155
158
  - lib/styles/file_index.style
156
159
  - mercurial-ruby.gemspec
157
160
  - test/fixtures.rb
158
- - test/fixtures/test-repo/.DotFile
159
- - test/fixtures/test-repo/.hg/00changelog.i
160
- - test/fixtures/test-repo/.hg/branch
161
- - test/fixtures/test-repo/.hg/cache/branchheads
162
- - test/fixtures/test-repo/.hg/cache/tags
163
- - test/fixtures/test-repo/.hg/dirstate
164
- - test/fixtures/test-repo/.hg/hgrc
165
- - test/fixtures/test-repo/.hg/last-message.txt
166
- - test/fixtures/test-repo/.hg/requires
167
- - test/fixtures/test-repo/.hg/store/00changelog.i
168
- - test/fixtures/test-repo/.hg/store/00manifest.i
169
- - test/fixtures/test-repo/.hg/store/data/_file _with _whitespace.pdf.i
170
- - test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e.txt.i
171
- - test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e2.txt.i
172
- - test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e3.txt.i
173
- - test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e4.txt.i
174
- - test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markdown.i
175
- - test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markup.i
176
- - test/fixtures/test-repo/.hg/store/data/_rakefile.i
177
- - test/fixtures/test-repo/.hg/store/data/_rakefile2.i
178
- - test/fixtures/test-repo/.hg/store/data/_rakefile3.i
179
- - test/fixtures/test-repo/.hg/store/data/check ~5c this ~5c out ~22 now.i
180
- - test/fixtures/test-repo/.hg/store/data/directory two/minitest__mixin.rb.i
181
- - test/fixtures/test-repo/.hg/store/data/directory two/options.rb.i
182
- - test/fixtures/test-repo/.hg/store/data/directory two/rdoc__mixin.rb.i
183
- - test/fixtures/test-repo/.hg/store/data/directory two/rspec__mixin.rb.i
184
- - test/fixtures/test-repo/.hg/store/data/directory two/shindo__mixin.rb.i
185
- - test/fixtures/test-repo/.hg/store/data/directory two/shoulda__mixin.rb.i
186
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/_gemfile.i
187
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/_l_i_c_e_n_s_e.txt.i
188
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/_r_e_a_d_m_e.rdoc.i
189
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/_rakefile.i
190
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/flunking.rb.i
191
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/helper.rb.i
192
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/bundler__setup.erb.i
193
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/features/default.feature.i
194
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/features/support/env.rb.i
195
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/jeweler__tasks.erb.i
196
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/flunking.rb.i
197
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/helper.rb.i
198
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/flunking.rb.i
199
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/helper.rb.i
200
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/other__tasks.erb.i
201
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/flunking.rb.i
202
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/helper.rb.i
203
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/flunking.rb.i
204
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/helper.rb.i
205
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/~2erspec.i
206
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/flunking.rb.i
207
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/helper.rb.i
208
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/flunking.rb.i
209
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/helper.rb.i
210
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/flunking.rb.i
211
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/helper.rb.i
212
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/flunking.rb.i
213
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/helper.rb.i
214
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/~2edocument.i
215
- - test/fixtures/test-repo/.hg/store/data/directory two/templates/~2egitignore.i
216
- - test/fixtures/test-repo/.hg/store/data/directory two/~2e_d_s___store.i
217
- - test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__dot__org__tasks.rb.i
218
- - test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__tasks.rb.i
219
- - test/fixtures/test-repo/.hg/store/data/directory__1/specification.rb.i
220
- - test/fixtures/test-repo/.hg/store/data/directory__1/tasks.rb.i
221
- - test/fixtures/test-repo/.hg/store/data/directory__1/~2e_d_s___store.i
222
- - test/fixtures/test-repo/.hg/store/data/empty-file.i
223
- - test/fixtures/test-repo/.hg/store/data/goose.png.i
224
- - test/fixtures/test-repo/.hg/store/data/goose/pretty-thing.txt.i
225
- - test/fixtures/test-repo/.hg/store/data/new-directory/another-boring-file.i
226
- - test/fixtures/test-repo/.hg/store/data/new-directory/something.csv.i
227
- - test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.d
228
- - test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.i
229
- - test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_file _with _whitespace.pdf.i
230
- - test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/beansprout.png.i
231
- - test/fixtures/test-repo/.hg/store/data/new-file.i
232
- - test/fixtures/test-repo/.hg/store/data/old-directory/minitest__mixin.rb.i
233
- - test/fixtures/test-repo/.hg/store/data/old-directory/options.rb.i
234
- - test/fixtures/test-repo/.hg/store/data/old-directory/rspec__mixin.rb.i
235
- - test/fixtures/test-repo/.hg/store/data/old-directory/shindo__mixin.rb.i
236
- - test/fixtures/test-repo/.hg/store/data/old-directory/testunit__mixin.rb.i
237
- - test/fixtures/test-repo/.hg/store/data/old-directory/yard__mixin.rb.i
238
- - test/fixtures/test-repo/.hg/store/data/riot__mixin.rb.i
239
- - test/fixtures/test-repo/.hg/store/data/riot__mixin__copy.rb.i
240
- - test/fixtures/test-repo/.hg/store/data/style.i
241
- - test/fixtures/test-repo/.hg/store/data/super-cow.i
242
- - test/fixtures/test-repo/.hg/store/data/superman.txt.i
243
- - test/fixtures/test-repo/.hg/store/data/testspec__mixin.rb.i
244
- - test/fixtures/test-repo/.hg/store/data/testspec__mixin__new.rb.i
245
- - test/fixtures/test-repo/.hg/store/data/~2e_dot_file.i
246
- - test/fixtures/test-repo/.hg/store/data/~2ehgignore.i
247
- - test/fixtures/test-repo/.hg/store/data/~2ehgtags.i
248
- - test/fixtures/test-repo/.hg/store/fncache
249
- - test/fixtures/test-repo/.hg/store/undo
250
- - test/fixtures/test-repo/.hg/undo.bookmarks
251
- - test/fixtures/test-repo/.hg/undo.branch
252
- - test/fixtures/test-repo/.hg/undo.desc
253
- - test/fixtures/test-repo/.hg/undo.dirstate
254
- - test/fixtures/test-repo/.hgignore
255
- - test/fixtures/test-repo/.hgtags
256
- - test/fixtures/test-repo/LICENSE3.txt
257
- - test/fixtures/test-repo/LICENSE4.txt
258
- - test/fixtures/test-repo/README.markup
259
- - test/fixtures/test-repo/Rakefile3
260
- - test/fixtures/test-repo/check \ this \ out " now
261
- - test/fixtures/test-repo/empty-file
262
- - test/fixtures/test-repo/goose.png
263
- - test/fixtures/test-repo/goose/pretty-thing.txt
264
- - test/fixtures/test-repo/new-directory/another-boring-file
265
- - test/fixtures/test-repo/new-directory/something.csv
266
- - test/fixtures/test-repo/new-directory/subdirectory/EULA5seat_Chin_Sim02.03.04.pdf
267
- - test/fixtures/test-repo/new-directory/subdirectory/File With Whitespace.pdf
268
- - test/fixtures/test-repo/new-directory/subdirectory/beansprout.png
269
- - test/fixtures/test-repo/riot_mixin.rb
270
- - test/fixtures/test-repo/style
271
- - test/fixtures/test-repo/superman.txt
272
- - test/fixtures/test-repo/testspec_mixin_new.rb
161
+ - test/fixtures/test-repo.zip
273
162
  - test/helper.rb
163
+ - test/test_blame.rb
164
+ - test/test_blame_factory.rb
274
165
  - test/test_branch_factory.rb
275
166
  - test/test_changed_file.rb
276
167
  - test/test_changed_file_factory.rb