mercurial-ruby 0.3.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 (173) hide show
  1. data/.document +5 -0
  2. data/Gemfile +10 -0
  3. data/Gemfile.lock +32 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +86 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/lib/mercurial-ruby.rb +66 -0
  9. data/lib/mercurial-ruby/branch.rb +45 -0
  10. data/lib/mercurial-ruby/changed_file.rb +51 -0
  11. data/lib/mercurial-ruby/command.rb +77 -0
  12. data/lib/mercurial-ruby/commit.rb +152 -0
  13. data/lib/mercurial-ruby/config_file.rb +119 -0
  14. data/lib/mercurial-ruby/configuration.rb +14 -0
  15. data/lib/mercurial-ruby/diff.rb +50 -0
  16. data/lib/mercurial-ruby/factories/branch_factory.rb +91 -0
  17. data/lib/mercurial-ruby/factories/changed_file_factory.rb +50 -0
  18. data/lib/mercurial-ruby/factories/commit_factory.rb +154 -0
  19. data/lib/mercurial-ruby/factories/diff_factory.rb +63 -0
  20. data/lib/mercurial-ruby/factories/hook_factory.rb +45 -0
  21. data/lib/mercurial-ruby/factories/node_factory.rb +111 -0
  22. data/lib/mercurial-ruby/factories/tag_factory.rb +48 -0
  23. data/lib/mercurial-ruby/file_index.rb +209 -0
  24. data/lib/mercurial-ruby/helper.rb +23 -0
  25. data/lib/mercurial-ruby/hook.rb +23 -0
  26. data/lib/mercurial-ruby/manifest.rb +58 -0
  27. data/lib/mercurial-ruby/node.rb +100 -0
  28. data/lib/mercurial-ruby/repository.rb +94 -0
  29. data/lib/mercurial-ruby/root_node.rb +27 -0
  30. data/lib/mercurial-ruby/shell.rb +64 -0
  31. data/lib/mercurial-ruby/style.rb +23 -0
  32. data/lib/mercurial-ruby/tag.rb +33 -0
  33. data/lib/stdlib_exts/string.rb +12 -0
  34. data/lib/styles/changeset.style +5 -0
  35. data/lib/styles/file_index.style +3 -0
  36. data/mercurial-ruby.gemspec +227 -0
  37. data/test/fixtures.rb +28 -0
  38. data/test/fixtures/test-repo/.DotFile +1 -0
  39. data/test/fixtures/test-repo/.hg/00changelog.i +0 -0
  40. data/test/fixtures/test-repo/.hg/branch +1 -0
  41. data/test/fixtures/test-repo/.hg/cache/branchheads +6 -0
  42. data/test/fixtures/test-repo/.hg/cache/tags +7 -0
  43. data/test/fixtures/test-repo/.hg/dirstate +0 -0
  44. data/test/fixtures/test-repo/.hg/hgrc +3 -0
  45. data/test/fixtures/test-repo/.hg/last-message.txt +1 -0
  46. data/test/fixtures/test-repo/.hg/requires +4 -0
  47. data/test/fixtures/test-repo/.hg/store/00changelog.i +0 -0
  48. data/test/fixtures/test-repo/.hg/store/00manifest.i +0 -0
  49. data/test/fixtures/test-repo/.hg/store/data/_file _with _whitespace.pdf.i +0 -0
  50. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e.txt.i +0 -0
  51. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e2.txt.i +0 -0
  52. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e3.txt.i +0 -0
  53. data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e4.txt.i +0 -0
  54. data/test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markdown.i +0 -0
  55. data/test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markup.i +0 -0
  56. data/test/fixtures/test-repo/.hg/store/data/_rakefile.i +0 -0
  57. data/test/fixtures/test-repo/.hg/store/data/_rakefile2.i +0 -0
  58. data/test/fixtures/test-repo/.hg/store/data/_rakefile3.i +0 -0
  59. data/test/fixtures/test-repo/.hg/store/data/check ~5c this ~5c out ~22 now.i +0 -0
  60. data/test/fixtures/test-repo/.hg/store/data/directory two/minitest__mixin.rb.i +0 -0
  61. data/test/fixtures/test-repo/.hg/store/data/directory two/options.rb.i +0 -0
  62. data/test/fixtures/test-repo/.hg/store/data/directory two/rdoc__mixin.rb.i +0 -0
  63. data/test/fixtures/test-repo/.hg/store/data/directory two/rspec__mixin.rb.i +0 -0
  64. data/test/fixtures/test-repo/.hg/store/data/directory two/shindo__mixin.rb.i +0 -0
  65. data/test/fixtures/test-repo/.hg/store/data/directory two/shoulda__mixin.rb.i +0 -0
  66. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_gemfile.i +0 -0
  67. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_l_i_c_e_n_s_e.txt.i +0 -0
  68. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_r_e_a_d_m_e.rdoc.i +0 -0
  69. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_rakefile.i +0 -0
  70. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/flunking.rb.i +0 -0
  71. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/helper.rb.i +0 -0
  72. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bundler__setup.erb.i +0 -0
  73. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/features/default.feature.i +0 -0
  74. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/features/support/env.rb.i +0 -0
  75. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/jeweler__tasks.erb.i +0 -0
  76. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/flunking.rb.i +0 -0
  77. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/helper.rb.i +0 -0
  78. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/flunking.rb.i +0 -0
  79. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/helper.rb.i +0 -0
  80. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/other__tasks.erb.i +0 -0
  81. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/flunking.rb.i +0 -0
  82. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/helper.rb.i +0 -0
  83. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/flunking.rb.i +0 -0
  84. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/helper.rb.i +0 -0
  85. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/~2erspec.i +0 -0
  86. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/flunking.rb.i +0 -0
  87. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/helper.rb.i +0 -0
  88. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/flunking.rb.i +0 -0
  89. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/helper.rb.i +0 -0
  90. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/flunking.rb.i +0 -0
  91. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/helper.rb.i +0 -0
  92. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/flunking.rb.i +0 -0
  93. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/helper.rb.i +0 -0
  94. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/~2edocument.i +0 -0
  95. data/test/fixtures/test-repo/.hg/store/data/directory two/templates/~2egitignore.i +0 -0
  96. data/test/fixtures/test-repo/.hg/store/data/directory two/~2e_d_s___store.i +0 -0
  97. data/test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__dot__org__tasks.rb.i +0 -0
  98. data/test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__tasks.rb.i +0 -0
  99. data/test/fixtures/test-repo/.hg/store/data/directory__1/specification.rb.i +0 -0
  100. data/test/fixtures/test-repo/.hg/store/data/directory__1/tasks.rb.i +0 -0
  101. data/test/fixtures/test-repo/.hg/store/data/directory__1/~2e_d_s___store.i +0 -0
  102. data/test/fixtures/test-repo/.hg/store/data/empty-file.i +0 -0
  103. data/test/fixtures/test-repo/.hg/store/data/goose.png.i +0 -0
  104. data/test/fixtures/test-repo/.hg/store/data/goose/pretty-thing.txt.i +0 -0
  105. data/test/fixtures/test-repo/.hg/store/data/new-directory/another-boring-file.i +0 -0
  106. data/test/fixtures/test-repo/.hg/store/data/new-directory/something.csv.i +0 -0
  107. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.d +0 -0
  108. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.i +0 -0
  109. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_file _with _whitespace.pdf.i +0 -0
  110. data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/beansprout.png.i +0 -0
  111. data/test/fixtures/test-repo/.hg/store/data/new-file.i +0 -0
  112. data/test/fixtures/test-repo/.hg/store/data/old-directory/minitest__mixin.rb.i +0 -0
  113. data/test/fixtures/test-repo/.hg/store/data/old-directory/options.rb.i +0 -0
  114. data/test/fixtures/test-repo/.hg/store/data/old-directory/rspec__mixin.rb.i +0 -0
  115. data/test/fixtures/test-repo/.hg/store/data/old-directory/shindo__mixin.rb.i +0 -0
  116. data/test/fixtures/test-repo/.hg/store/data/old-directory/testunit__mixin.rb.i +0 -0
  117. data/test/fixtures/test-repo/.hg/store/data/old-directory/yard__mixin.rb.i +0 -0
  118. data/test/fixtures/test-repo/.hg/store/data/riot__mixin.rb.i +0 -0
  119. data/test/fixtures/test-repo/.hg/store/data/riot__mixin__copy.rb.i +0 -0
  120. data/test/fixtures/test-repo/.hg/store/data/style.i +0 -0
  121. data/test/fixtures/test-repo/.hg/store/data/super-cow.i +0 -0
  122. data/test/fixtures/test-repo/.hg/store/data/superman.txt.i +0 -0
  123. data/test/fixtures/test-repo/.hg/store/data/testspec__mixin.rb.i +0 -0
  124. data/test/fixtures/test-repo/.hg/store/data/testspec__mixin__new.rb.i +0 -0
  125. data/test/fixtures/test-repo/.hg/store/data/~2e_dot_file.i +0 -0
  126. data/test/fixtures/test-repo/.hg/store/data/~2ehgignore.i +0 -0
  127. data/test/fixtures/test-repo/.hg/store/data/~2ehgtags.i +0 -0
  128. data/test/fixtures/test-repo/.hg/store/fncache +79 -0
  129. data/test/fixtures/test-repo/.hg/store/undo +0 -0
  130. data/test/fixtures/test-repo/.hg/undo.bookmarks +0 -0
  131. data/test/fixtures/test-repo/.hg/undo.branch +1 -0
  132. data/test/fixtures/test-repo/.hg/undo.desc +2 -0
  133. data/test/fixtures/test-repo/.hg/undo.dirstate +0 -0
  134. data/test/fixtures/test-repo/.hgignore +1 -0
  135. data/test/fixtures/test-repo/.hgtags +1 -0
  136. data/test/fixtures/test-repo/LICENSE3.txt +15 -0
  137. data/test/fixtures/test-repo/LICENSE4.txt +17 -0
  138. data/test/fixtures/test-repo/README.markup +218 -0
  139. data/test/fixtures/test-repo/Rakefile3 +83 -0
  140. data/test/fixtures/test-repo/check // this // out /" now" "b/data/test/fixtures/test-repo/check // this // out / → now +0 -0
  141. data/test/fixtures/test-repo/empty-file +0 -0
  142. data/test/fixtures/test-repo/goose.png +0 -0
  143. data/test/fixtures/test-repo/goose/pretty-thing.txt +0 -0
  144. data/test/fixtures/test-repo/new-directory/another-boring-file +78 -0
  145. data/test/fixtures/test-repo/new-directory/something.csv +1 -0
  146. data/test/fixtures/test-repo/new-directory/subdirectory/EULA5seat_Chin_Sim02.03.04.pdf +0 -0
  147. 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
  148. data/test/fixtures/test-repo/new-directory/subdirectory/beansprout.png +0 -0
  149. data/test/fixtures/test-repo/riot_mixin.rb +45 -0
  150. data/test/fixtures/test-repo/style +4 -0
  151. data/test/fixtures/test-repo/superman.txt +1 -0
  152. data/test/fixtures/test-repo/testspec_mixin_new.rb +44 -0
  153. data/test/helper.rb +41 -0
  154. data/test/test_branch_factory.rb +46 -0
  155. data/test/test_changed_file.rb +46 -0
  156. data/test/test_changed_file_factory.rb +16 -0
  157. data/test/test_command.rb +62 -0
  158. data/test/test_commit.rb +66 -0
  159. data/test/test_commit_factory.rb +101 -0
  160. data/test/test_config_file.rb +105 -0
  161. data/test/test_configuration.rb +26 -0
  162. data/test/test_diff.rb +39 -0
  163. data/test/test_diff_factory.rb +38 -0
  164. data/test/test_file_index.rb +113 -0
  165. data/test/test_hook.rb +39 -0
  166. data/test/test_hook_factory.rb +40 -0
  167. data/test/test_manifest.rb +39 -0
  168. data/test/test_node.rb +34 -0
  169. data/test/test_node_factory.rb +125 -0
  170. data/test/test_repository.rb +58 -0
  171. data/test/test_shell.rb +33 -0
  172. data/test/test_tag_factory.rb +27 -0
  173. metadata +328 -0
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::HookFactory do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.create('/tmp/configfile-test.hg')
7
+ stub_hgrc(@repository.config.path)
8
+ end
9
+
10
+ after do
11
+ @repository.destroy!
12
+ end
13
+
14
+ it "should find all hooks" do
15
+ hooks = @repository.hooks.all
16
+ hooks.size.must_equal 2
17
+ hooks.map(&:name).must_equal ['commit', 'changegroup']
18
+ hooks.map(&:value).must_equal ['/Users/ilya/work/beanstalk/script/mercurial/commit.rb', '/Users/ilya/work/beanstalk/script/mercurial/changegroup.rb']
19
+ hooks.first.must_be_kind_of Mercurial::Hook
20
+ end
21
+
22
+ it "should find hooks by name" do
23
+ hook = @repository.hooks.by_name('changegroup')
24
+ hook.must_be_kind_of Mercurial::Hook
25
+ hook.name.must_equal 'changegroup'
26
+ hook.value.must_equal '/Users/ilya/work/beanstalk/script/mercurial/changegroup.rb'
27
+ end
28
+
29
+ it "should create hooks" do
30
+ hook = @repository.hooks.add('incoming', 'hg update')
31
+ hook.name.must_equal 'incoming'
32
+ hook.value.must_equal 'hg update'
33
+ end
34
+
35
+ it "should destroy hooks" do
36
+ Mercurial::Hook.any_instance.expects(:destroy!).once
37
+ @repository.hooks.remove('commit')
38
+ end
39
+
40
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::Manifest do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ @manifest = @repository.manifest
8
+ end
9
+
10
+ it "should have link to repository" do
11
+ @manifest.repository.must_equal @repository
12
+ end
13
+
14
+ it "should scan for path" do
15
+ paths = @manifest.scan_for_path('new-directory/', 'f2b8b135f3a6')
16
+ paths.map{|p| p[3]}.sort.must_equal %w(new-directory/another-boring-file new-directory/something.csv new-directory/subdirectory/EULA5seat_Chin_Sim02.03.04.pdf new-directory/subdirectory/beansprout.png).sort
17
+ end
18
+
19
+ it "should find exact matches for file names" do
20
+ paths = @manifest.scan_for_path('goose')
21
+ paths.size.must_equal 1
22
+ end
23
+
24
+ it "should return nothing for inexisting path" do
25
+ paths = @manifest.scan_for_path('shikaka-path/')
26
+ paths.must_equal []
27
+ end
28
+
29
+ it "should scan for root" do
30
+ paths = @manifest.scan_for_path('/', 'f2b8b135f3a6')
31
+ paths.size.must_equal 17
32
+ end
33
+
34
+ it "should scan for path with weird characters" do
35
+ paths = @manifest.scan_for_path('check \ this \ out " now', '2d32410d9629')
36
+ paths.size.must_equal 1
37
+ end
38
+
39
+ end
data/test/test_node.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::Node do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ end
8
+
9
+ it "should be considered directory when ends with a slash" do
10
+ node = @repository.nodes.find('new-directory/subdirectory/', 'a8b39838302f')
11
+ node.file?.must_equal false
12
+ node.directory?.must_equal true
13
+ end
14
+
15
+ it "should be considered file when doesn't end with a slash" do
16
+ node = @repository.nodes.find('new-directory/something.csv', 'a8b39838302f')
17
+ node.file?.must_equal true
18
+ node.directory?.must_equal false
19
+ end
20
+
21
+ it "should show node contents" do
22
+ node = @repository.nodes.find('new-directory/something.csv', 'a8b39838302f')
23
+ node.contents.strip.must_equal 'Here will be CSV.'
24
+
25
+ node = @repository.nodes.find('new-directory/something.csv', '291a498f04e9')
26
+ node.contents.strip.must_equal 'Here will be some new kind of CSV.'
27
+ end
28
+
29
+ it "should fetch contents of a node with whitespace in it's name" do
30
+ node = @repository.nodes.find('File With Whitespace.pdf', '8ddac5f6380e')
31
+ node.contents.must_equal ''
32
+ end
33
+
34
+ end
@@ -0,0 +1,125 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::NodeFactory do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ end
8
+
9
+ it "should raise exception when find used with exclamation point and node missing" do
10
+ lambda { @repository.nodes.find!('jahdfer') }.must_raise Mercurial::NodeMissing
11
+ end
12
+
13
+ it "should return nil for file that doesn't exist" do
14
+ node = @repository.nodes.find('shikakablala4', 'a8b39838302f')
15
+ node.must_equal nil
16
+ end
17
+
18
+ it "should find a directory in the repo" do
19
+ node = @repository.nodes.find('new-directory/', 'a8b39838302f')
20
+ node.name.must_equal 'new-directory/'
21
+ node.path.must_equal 'new-directory/'
22
+ node.directory?.must_equal true
23
+ node.fmode.must_equal nil
24
+ node.executable.must_equal false
25
+ node.revision.must_equal 'a8b39838302f'
26
+ node.nodeid.must_equal nil
27
+ node.must_be_kind_of Mercurial::Node
28
+ end
29
+
30
+ it "should find a directory even if I specified it without trailing slash" do
31
+ node = @repository.nodes.find('new-directory/subdirectory', 'a8b39838302f')
32
+ node.name.must_equal 'subdirectory/'
33
+ node.directory?.must_equal true
34
+ end
35
+
36
+ it "should find file" do
37
+ node = @repository.nodes.find('new-directory/something.csv', 'a8b39838302f')
38
+ node.name.must_equal 'something.csv'
39
+ node.path.must_equal 'new-directory/something.csv'
40
+ node.directory?.must_equal false
41
+ node.file?.must_equal true
42
+ node.fmode.must_equal '644'
43
+ node.executable.must_equal false
44
+ node.revision.must_equal 'a8b39838302f'
45
+ node.nodeid.must_equal '74dea67fb438acdb2cc103b3d289d4a8856718cc'
46
+ node.must_be_kind_of Mercurial::Node
47
+ end
48
+
49
+ it "should find deleted file" do
50
+ node = @repository.nodes.find('old-directory/options.rb', 'a07263ded072')
51
+ node.name.must_equal 'options.rb'
52
+ node.path.must_equal 'old-directory/options.rb'
53
+ node.directory?.must_equal false
54
+ node.file?.must_equal true
55
+ node.fmode.must_equal '644'
56
+ node.executable.must_equal false
57
+ node.revision.must_equal 'a07263ded072'
58
+ node.nodeid.must_equal '75fe47582b041b66d5ab1606cf3cff140038d7bd'
59
+ node.must_be_kind_of Mercurial::Node
60
+ end
61
+
62
+ it "should find entries for node" do
63
+ node = @repository.nodes.find('new-directory/', 'a8b39838302f')
64
+ entries = node.entries
65
+ entries.size.must_equal 3
66
+ entries.each {|e| e.must_be_kind_of Mercurial::Node }
67
+ entries.map(&:name).sort.must_equal %w(another-boring-file something.csv subdirectory/).sort
68
+ entries.map(&:parent).uniq.must_equal [node]
69
+
70
+ entries[0].directory?.must_equal true
71
+ entries[0].file?.must_equal false
72
+
73
+ entries[1].file?.must_equal true
74
+ entries[1].directory?.must_equal false
75
+
76
+ entries[2].file?.must_equal true
77
+ entries[2].directory?.must_equal false
78
+ end
79
+
80
+ it "should find entries for tip revision" do
81
+ node = @repository.nodes.find('new-directory/subdirectory')
82
+ entries = node.entries
83
+ entries.size.must_equal 3
84
+ entries.map{|e| e.file?}.must_equal [true, true, true]
85
+ end
86
+
87
+ it "should find entries for node without trailing slash" do
88
+ node = @repository.nodes.find('new-directory', 'a8b39838302f')
89
+ entries = node.entries
90
+ entries.size.must_equal 3
91
+ entries.map(&:name).sort.must_equal %w(another-boring-file something.csv subdirectory/).sort
92
+ end
93
+
94
+ it "should find root node" do
95
+ node = @repository.nodes.find('/')
96
+ node.must_be_kind_of Mercurial::RootNode
97
+ end
98
+
99
+ it "should find entries for root node" do
100
+ node = @repository.nodes.find('/', 'f2b8b135f3a6')
101
+ node.must_be_kind_of Mercurial::RootNode
102
+ entries = node.entries
103
+ entries.size.must_equal 14
104
+ entries.map(&:name).sort.must_equal %w(.DotFile .hgignore .hgtags LICENSE3.txt LICENSE4.txt README.markup Rakefile3 empty-file goose.png new-directory/ riot_mixin.rb style superman.txt testspec_mixin_new.rb).sort
105
+ end
106
+
107
+ it "should work fine with files with whitespace in their name" do
108
+ node = @repository.nodes.find('File With Whitespace.pdf', '8ddac5f6380e')
109
+ node.name.must_equal 'File With Whitespace.pdf'
110
+
111
+ root = @repository.nodes.find('/', '8ddac5f6380e')
112
+ node2 = root.entries.find{|f| f.name == 'File With Whitespace.pdf'}
113
+ node2.must_be_kind_of Mercurial::Node
114
+
115
+ node3 = @repository.nodes.find('new-directory/subdirectory/File With Whitespace.pdf', 'bb9cc2a2c920')
116
+ node3.name.must_equal 'File With Whitespace.pdf'
117
+ end
118
+
119
+ it "should find file with weird characters in it's name" do
120
+ node = @repository.nodes.find('check \ this \ out " now', '2d32410d9629')
121
+ node.name.must_equal 'check \ this \ out " now'
122
+ node.file?.must_equal true
123
+ end
124
+
125
+ end
@@ -0,0 +1,58 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::Repository do
4
+
5
+ it "should raise an error when trying to open a repository that doesn't exist on disk" do
6
+ lambda{ Mercurial::Repository.open('/shikaka/bambucha') }.must_raise Mercurial::RepositoryNotFound
7
+ end
8
+
9
+ describe "creating" do
10
+ before do
11
+ @repository = Mercurial::Repository.create('/tmp/test-hg-repo')
12
+ end
13
+
14
+ after do
15
+ @repository.destroy!
16
+ end
17
+
18
+ it "should have valid path" do
19
+ @repository.path.must_equal '/tmp/test-hg-repo'
20
+ end
21
+
22
+ it "should create a Mercurial repo on disk" do
23
+ File.exists?(File.join(@repository.path, '.hg')).must_equal true
24
+ end
25
+
26
+ it "should respond to hooks" do
27
+ @repository.must_respond_to :hooks
28
+ end
29
+
30
+ it "should respond to commits" do
31
+ @repository.must_respond_to :commits
32
+ end
33
+
34
+ it "should respond to branches" do
35
+ @repository.must_respond_to :branches
36
+ end
37
+
38
+ it "should respond to tags" do
39
+ @repository.must_respond_to :tags
40
+ end
41
+
42
+ it "should respond to diffs" do
43
+ @repository.must_respond_to :diffs
44
+ end
45
+ end
46
+
47
+ describe "destroying" do
48
+ before do
49
+ @repository = Mercurial::Repository.create('/tmp/test-hg-repo')
50
+ @repository.destroy!
51
+ end
52
+
53
+ it "should remove Mercurial repo from disk" do
54
+ File.exists?(@repository.path).must_equal false
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,33 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::Shell do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ @shell = @repository.shell
8
+ end
9
+
10
+ it "should compile commands" do
11
+ command_mock = mock('command', :execute => true)
12
+ Mercurial::Command.expects(:new).with("cd #{ @repository.path } && /usr/local/bin/hg log", :repository => @repository, :cache => true).returns(command_mock).once
13
+ @shell.hg('log')
14
+ end
15
+
16
+ it "should sanitize command arguments" do
17
+ command_mock = mock('command', :execute => true)
18
+ Mercurial::Command.expects(:new).with(%Q[ls 'file with nasty '\\''quote'], :repository => nil, :cache => true).returns(command_mock).once
19
+ @shell.run(["ls ?", "file with nasty 'quote"])
20
+ end
21
+
22
+ it "should work with string and array commands" do
23
+ @shell.hg('tip')
24
+ @shell.hg(['tip ?', '-g'])
25
+ end
26
+
27
+ it "should execute commands without cache" do
28
+ command_mock = mock('command', :execute => true)
29
+ Mercurial::Command.expects(:new).with('ls -l /', :repository => nil, :cache => false).returns(command_mock).once
30
+ Mercurial::Shell.run('ls -l /', :cache => false)
31
+ end
32
+
33
+ end
@@ -0,0 +1,27 @@
1
+ require 'helper'
2
+
3
+ describe Mercurial::TagFactory do
4
+
5
+ before do
6
+ @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
+ end
8
+
9
+ it "should find all tags" do
10
+ tags = @repository.tags.all
11
+ tags.size.must_equal 2
12
+ tags.map(&:name).sort.must_equal %w(new-tag new-branch-tag).sort
13
+ tags.map(&:hash_id).sort.must_equal %w(63f70b2314ed bf6386c0a0cc).sort
14
+ end
15
+
16
+ it "should find tag by name" do
17
+ tag = @repository.tags.by_name('new-tag')
18
+ tag.must_be_kind_of(Mercurial::Tag)
19
+ tag.name.must_equal 'new-tag'
20
+ tag.hash_id.must_equal 'bf6386c0a0cc'
21
+ end
22
+
23
+ it "should not find inexistent tag by name" do
24
+ @repository.tags.by_name('new-tag-shikakabob').must_equal nil
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,328 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mercurial-ruby
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
+ platform: ruby
12
+ authors:
13
+ - Ilya Sabanin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-03 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ prerelease: false
24
+ name: minitest
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ prerelease: false
38
+ name: bundler
39
+ version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 1
47
+ - 0
48
+ - 0
49
+ version: 1.0.0
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ prerelease: false
54
+ name: jeweler
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 7
61
+ segments:
62
+ - 1
63
+ - 6
64
+ - 4
65
+ version: 1.6.4
66
+ requirement: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ prerelease: false
70
+ name: rcov
71
+ version_requirements: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirement: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ type: :development
83
+ prerelease: false
84
+ name: mocha
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 25
91
+ segments:
92
+ - 0
93
+ - 9
94
+ version: "0.9"
95
+ requirement: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ type: :development
98
+ prerelease: false
99
+ name: ruby-debug
100
+ version_requirements: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 31
106
+ segments:
107
+ - 0
108
+ - 10
109
+ version: "0.10"
110
+ requirement: *id006
111
+ description: Ruby API for Mercurial DVCS.
112
+ email: ilya.sabanin@gmail.com
113
+ executables: []
114
+
115
+ extensions: []
116
+
117
+ extra_rdoc_files:
118
+ - LICENSE.txt
119
+ - README.rdoc
120
+ files:
121
+ - .document
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.rdoc
126
+ - Rakefile
127
+ - VERSION
128
+ - lib/mercurial-ruby.rb
129
+ - lib/mercurial-ruby/branch.rb
130
+ - lib/mercurial-ruby/changed_file.rb
131
+ - lib/mercurial-ruby/command.rb
132
+ - lib/mercurial-ruby/commit.rb
133
+ - lib/mercurial-ruby/config_file.rb
134
+ - lib/mercurial-ruby/configuration.rb
135
+ - lib/mercurial-ruby/diff.rb
136
+ - lib/mercurial-ruby/factories/branch_factory.rb
137
+ - lib/mercurial-ruby/factories/changed_file_factory.rb
138
+ - lib/mercurial-ruby/factories/commit_factory.rb
139
+ - lib/mercurial-ruby/factories/diff_factory.rb
140
+ - lib/mercurial-ruby/factories/hook_factory.rb
141
+ - lib/mercurial-ruby/factories/node_factory.rb
142
+ - lib/mercurial-ruby/factories/tag_factory.rb
143
+ - lib/mercurial-ruby/file_index.rb
144
+ - lib/mercurial-ruby/helper.rb
145
+ - lib/mercurial-ruby/hook.rb
146
+ - lib/mercurial-ruby/manifest.rb
147
+ - lib/mercurial-ruby/node.rb
148
+ - lib/mercurial-ruby/repository.rb
149
+ - lib/mercurial-ruby/root_node.rb
150
+ - lib/mercurial-ruby/shell.rb
151
+ - lib/mercurial-ruby/style.rb
152
+ - lib/mercurial-ruby/tag.rb
153
+ - lib/stdlib_exts/string.rb
154
+ - lib/styles/changeset.style
155
+ - lib/styles/file_index.style
156
+ - mercurial-ruby.gemspec
157
+ - 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
273
+ - test/helper.rb
274
+ - test/test_branch_factory.rb
275
+ - test/test_changed_file.rb
276
+ - test/test_changed_file_factory.rb
277
+ - test/test_command.rb
278
+ - test/test_commit.rb
279
+ - test/test_commit_factory.rb
280
+ - test/test_config_file.rb
281
+ - test/test_configuration.rb
282
+ - test/test_diff.rb
283
+ - test/test_diff_factory.rb
284
+ - test/test_file_index.rb
285
+ - test/test_hook.rb
286
+ - test/test_hook_factory.rb
287
+ - test/test_manifest.rb
288
+ - test/test_node.rb
289
+ - test/test_node_factory.rb
290
+ - test/test_repository.rb
291
+ - test/test_shell.rb
292
+ - test/test_tag_factory.rb
293
+ has_rdoc: true
294
+ homepage: http://github.com/iSabanin/mercurial-ruby
295
+ licenses:
296
+ - MIT
297
+ post_install_message:
298
+ rdoc_options: []
299
+
300
+ require_paths:
301
+ - lib
302
+ required_ruby_version: !ruby/object:Gem::Requirement
303
+ none: false
304
+ requirements:
305
+ - - ">="
306
+ - !ruby/object:Gem::Version
307
+ hash: 3
308
+ segments:
309
+ - 0
310
+ version: "0"
311
+ required_rubygems_version: !ruby/object:Gem::Requirement
312
+ none: false
313
+ requirements:
314
+ - - ">="
315
+ - !ruby/object:Gem::Version
316
+ hash: 3
317
+ segments:
318
+ - 0
319
+ version: "0"
320
+ requirements: []
321
+
322
+ rubyforge_project:
323
+ rubygems_version: 1.3.7
324
+ signing_key:
325
+ specification_version: 3
326
+ summary: Ruby API for Mercurial DVCS.
327
+ test_files: []
328
+