mercurial-ruby 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +86 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/mercurial-ruby.rb +66 -0
- data/lib/mercurial-ruby/branch.rb +45 -0
- data/lib/mercurial-ruby/changed_file.rb +51 -0
- data/lib/mercurial-ruby/command.rb +77 -0
- data/lib/mercurial-ruby/commit.rb +152 -0
- data/lib/mercurial-ruby/config_file.rb +119 -0
- data/lib/mercurial-ruby/configuration.rb +14 -0
- data/lib/mercurial-ruby/diff.rb +50 -0
- data/lib/mercurial-ruby/factories/branch_factory.rb +91 -0
- data/lib/mercurial-ruby/factories/changed_file_factory.rb +50 -0
- data/lib/mercurial-ruby/factories/commit_factory.rb +154 -0
- data/lib/mercurial-ruby/factories/diff_factory.rb +63 -0
- data/lib/mercurial-ruby/factories/hook_factory.rb +45 -0
- data/lib/mercurial-ruby/factories/node_factory.rb +111 -0
- data/lib/mercurial-ruby/factories/tag_factory.rb +48 -0
- data/lib/mercurial-ruby/file_index.rb +209 -0
- data/lib/mercurial-ruby/helper.rb +23 -0
- data/lib/mercurial-ruby/hook.rb +23 -0
- data/lib/mercurial-ruby/manifest.rb +58 -0
- data/lib/mercurial-ruby/node.rb +100 -0
- data/lib/mercurial-ruby/repository.rb +94 -0
- data/lib/mercurial-ruby/root_node.rb +27 -0
- data/lib/mercurial-ruby/shell.rb +64 -0
- data/lib/mercurial-ruby/style.rb +23 -0
- data/lib/mercurial-ruby/tag.rb +33 -0
- data/lib/stdlib_exts/string.rb +12 -0
- data/lib/styles/changeset.style +5 -0
- data/lib/styles/file_index.style +3 -0
- data/mercurial-ruby.gemspec +227 -0
- data/test/fixtures.rb +28 -0
- data/test/fixtures/test-repo/.DotFile +1 -0
- data/test/fixtures/test-repo/.hg/00changelog.i +0 -0
- data/test/fixtures/test-repo/.hg/branch +1 -0
- data/test/fixtures/test-repo/.hg/cache/branchheads +6 -0
- data/test/fixtures/test-repo/.hg/cache/tags +7 -0
- data/test/fixtures/test-repo/.hg/dirstate +0 -0
- data/test/fixtures/test-repo/.hg/hgrc +3 -0
- data/test/fixtures/test-repo/.hg/last-message.txt +1 -0
- data/test/fixtures/test-repo/.hg/requires +4 -0
- data/test/fixtures/test-repo/.hg/store/00changelog.i +0 -0
- data/test/fixtures/test-repo/.hg/store/00manifest.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_file _with _whitespace.pdf.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e2.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e3.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_l_i_c_e_n_s_e4.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markdown.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_r_e_a_d_m_e.markup.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_rakefile.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_rakefile2.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/_rakefile3.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/check ~5c this ~5c out ~22 now.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/minitest__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/options.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/rdoc__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/rspec__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/shindo__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/shoulda__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_gemfile.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_l_i_c_e_n_s_e.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_r_e_a_d_m_e.rdoc.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/_rakefile.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bacon/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/bundler__setup.erb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/features/default.feature.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/features/support/env.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/jeweler__tasks.erb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/micronaut/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/minitest/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/other__tasks.erb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/riot/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/rspec/~2erspec.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shindo/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/shoulda/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testspec/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/flunking.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/testunit/helper.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/~2edocument.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/templates/~2egitignore.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory two/~2e_d_s___store.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__dot__org__tasks.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory__1/rubygems__tasks.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory__1/specification.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory__1/tasks.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/directory__1/~2e_d_s___store.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/empty-file.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/goose.png.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/goose/pretty-thing.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-directory/another-boring-file.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-directory/something.csv.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.d +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_e_u_l_a5seat___chin___sim02.03.04.pdf.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/_file _with _whitespace.pdf.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-directory/subdirectory/beansprout.png.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/new-file.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/old-directory/minitest__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/old-directory/options.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/old-directory/rspec__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/old-directory/shindo__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/old-directory/testunit__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/old-directory/yard__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/riot__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/riot__mixin__copy.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/style.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/super-cow.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/superman.txt.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/testspec__mixin.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/testspec__mixin__new.rb.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/~2e_dot_file.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/~2ehgignore.i +0 -0
- data/test/fixtures/test-repo/.hg/store/data/~2ehgtags.i +0 -0
- data/test/fixtures/test-repo/.hg/store/fncache +79 -0
- data/test/fixtures/test-repo/.hg/store/undo +0 -0
- data/test/fixtures/test-repo/.hg/undo.bookmarks +0 -0
- data/test/fixtures/test-repo/.hg/undo.branch +1 -0
- data/test/fixtures/test-repo/.hg/undo.desc +2 -0
- data/test/fixtures/test-repo/.hg/undo.dirstate +0 -0
- data/test/fixtures/test-repo/.hgignore +1 -0
- data/test/fixtures/test-repo/.hgtags +1 -0
- data/test/fixtures/test-repo/LICENSE3.txt +15 -0
- data/test/fixtures/test-repo/LICENSE4.txt +17 -0
- data/test/fixtures/test-repo/README.markup +218 -0
- data/test/fixtures/test-repo/Rakefile3 +83 -0
- data/test/fixtures/test-repo/check // this // out /" now" "b/data/test/fixtures/test-repo/check // this // out / → now +0 -0
- data/test/fixtures/test-repo/empty-file +0 -0
- data/test/fixtures/test-repo/goose.png +0 -0
- data/test/fixtures/test-repo/goose/pretty-thing.txt +0 -0
- data/test/fixtures/test-repo/new-directory/another-boring-file +78 -0
- data/test/fixtures/test-repo/new-directory/something.csv +1 -0
- data/test/fixtures/test-repo/new-directory/subdirectory/EULA5seat_Chin_Sim02.03.04.pdf +0 -0
- 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
- data/test/fixtures/test-repo/new-directory/subdirectory/beansprout.png +0 -0
- data/test/fixtures/test-repo/riot_mixin.rb +45 -0
- data/test/fixtures/test-repo/style +4 -0
- data/test/fixtures/test-repo/superman.txt +1 -0
- data/test/fixtures/test-repo/testspec_mixin_new.rb +44 -0
- data/test/helper.rb +41 -0
- data/test/test_branch_factory.rb +46 -0
- data/test/test_changed_file.rb +46 -0
- data/test/test_changed_file_factory.rb +16 -0
- data/test/test_command.rb +62 -0
- data/test/test_commit.rb +66 -0
- data/test/test_commit_factory.rb +101 -0
- data/test/test_config_file.rb +105 -0
- data/test/test_configuration.rb +26 -0
- data/test/test_diff.rb +39 -0
- data/test/test_diff_factory.rb +38 -0
- data/test/test_file_index.rb +113 -0
- data/test/test_hook.rb +39 -0
- data/test/test_hook_factory.rb +40 -0
- data/test/test_manifest.rb +39 -0
- data/test/test_node.rb +34 -0
- data/test/test_node_factory.rb +125 -0
- data/test/test_repository.rb +58 -0
- data/test/test_shell.rb +33 -0
- data/test/test_tag_factory.rb +27 -0
- metadata +328 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
columnize (0.3.4)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.6.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
linecache (0.46)
|
11
|
+
rbx-require-relative (> 0.0.4)
|
12
|
+
minitest (2.3.1)
|
13
|
+
mocha (0.9.12)
|
14
|
+
rake (0.9.2)
|
15
|
+
rbx-require-relative (0.0.5)
|
16
|
+
rcov (0.9.9)
|
17
|
+
ruby-debug (0.10.4)
|
18
|
+
columnize (>= 0.1)
|
19
|
+
ruby-debug-base (~> 0.10.4.0)
|
20
|
+
ruby-debug-base (0.10.4)
|
21
|
+
linecache (>= 0.3)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
bundler (~> 1.0.0)
|
28
|
+
jeweler (~> 1.6.4)
|
29
|
+
minitest
|
30
|
+
mocha (~> 0.9)
|
31
|
+
rcov
|
32
|
+
ruby-debug (~> 0.10)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Ilya Sabanin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= mercurial-ruby
|
2
|
+
|
3
|
+
Ruby API for Mercurial DVCS. Uses command line interface to communicate with Mercurial repositories.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install mercurial-ruby
|
8
|
+
|
9
|
+
== Compatibility
|
10
|
+
|
11
|
+
Tested with Mercurial 1.9 and 1.9.1 and Ruby 1.8.7.
|
12
|
+
|
13
|
+
== Configuration
|
14
|
+
|
15
|
+
There are several settings you can configure. Do it like this:
|
16
|
+
|
17
|
+
Mercurial.configure do |conf|
|
18
|
+
conf.hg_binary_path = "/usr/bin/hg"
|
19
|
+
end
|
20
|
+
|
21
|
+
See {Mercurial::Configuration Configuration} class for details.
|
22
|
+
|
23
|
+
== Usage
|
24
|
+
|
25
|
+
All actions are performed through {Mercurial::Repository Repository} object.
|
26
|
+
So before you can start doing anything you need to initialize one. Either by creating a new repository:
|
27
|
+
|
28
|
+
repository = Mercurial::Repository.create("/path/to/new_repository")
|
29
|
+
|
30
|
+
or opening an existing one:
|
31
|
+
|
32
|
+
repository = Mercurial::Repository.open("/path/to/existing_repository")
|
33
|
+
|
34
|
+
Now feel free to invoke various methods to get changesets, branches, nodes, etc:
|
35
|
+
|
36
|
+
repository.commits.by_hash_ids('291a498f04e9', '63f70b2314ed')
|
37
|
+
repository.branches.all
|
38
|
+
repository.hooks.by_name('commit')
|
39
|
+
...
|
40
|
+
|
41
|
+
See Features section below for a full list of entities and their methods.
|
42
|
+
|
43
|
+
== Features
|
44
|
+
|
45
|
+
=== Mercurial Entities
|
46
|
+
|
47
|
+
* {Mercurial::Commit Commits}
|
48
|
+
* {Mercurial::Node Nodes} — files and directories
|
49
|
+
* {Mercurial::Branch Branches}
|
50
|
+
* {Mercurial::Tag Tags}
|
51
|
+
* {Mercurial::Diff Diffs}
|
52
|
+
* {Mercurial::Manifest Manifest}
|
53
|
+
* {Mercurial::FileIndex File Index}
|
54
|
+
* {Mercurial::ConfigFile Repository config} — hooks and various settings
|
55
|
+
|
56
|
+
=== Built-in Caching
|
57
|
+
|
58
|
+
There's a simple caching mechanism built into the gem. If you pass Rails CacheStore compatible
|
59
|
+
caching store to the Configuration block, mercurial-ruby will cache output of all hg commands
|
60
|
+
it's executing. Then if you execute same method again and it will run the same command,
|
61
|
+
the gem will return the output from cache.
|
62
|
+
|
63
|
+
Here's how you configure it:
|
64
|
+
|
65
|
+
Mercurial.configure do |conf|
|
66
|
+
conf.cache_store = Rails.cache
|
67
|
+
end
|
68
|
+
|
69
|
+
The gem is using a single method of the CacheStore called +fetch+.
|
70
|
+
Cache expires automatically when repository's mtime changes, and it's your job to update it.
|
71
|
+
|
72
|
+
== Contributing to mercurial-ruby
|
73
|
+
|
74
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
75
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
76
|
+
* Fork the project
|
77
|
+
* Start a feature/bugfix branch
|
78
|
+
* Commit and push until you are happy with your contribution
|
79
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
80
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
81
|
+
|
82
|
+
== Copyright
|
83
|
+
|
84
|
+
Copyright (c) 2011 Ilya Sabanin. See LICENSE.txt for
|
85
|
+
further details.
|
86
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "mercurial-ruby"
|
18
|
+
gem.homepage = "http://github.com/iSabanin/mercurial-ruby"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ruby API for Mercurial DVCS.}
|
21
|
+
gem.description = %Q{Ruby API for Mercurial DVCS.}
|
22
|
+
gem.email = "ilya.sabanin@gmail.com"
|
23
|
+
gem.authors = ["Ilya Sabanin"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "mercurial-ruby #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# Wrapper module. Nothing interesting here except that you can
|
3
|
+
# specify global configs with the +configure+ method.
|
4
|
+
#
|
5
|
+
module Mercurial
|
6
|
+
|
7
|
+
VERSION = '0.3.0'
|
8
|
+
|
9
|
+
class Error < RuntimeError; end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :configuration
|
13
|
+
|
14
|
+
# Access instance of Mercurial::Configuration.
|
15
|
+
#
|
16
|
+
# config = Mercurial.configuration
|
17
|
+
# config.hg_binary_path # => "/usr/local/bin/hg"
|
18
|
+
#
|
19
|
+
def configuration
|
20
|
+
@_configuration ||= Mercurial::Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
# Change gem's global settings.
|
24
|
+
#
|
25
|
+
# Mercurial.configure do |conf|
|
26
|
+
# conf.hg_binary_path = "/usr/bin/hg"
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
def configure
|
30
|
+
yield(configuration)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def require_local(suffix)
|
37
|
+
require(File.expand_path(File.join(File.dirname(__FILE__), suffix)))
|
38
|
+
end
|
39
|
+
|
40
|
+
require_local 'stdlib_exts/string'
|
41
|
+
|
42
|
+
require_local 'mercurial-ruby/configuration'
|
43
|
+
require_local 'mercurial-ruby/shell'
|
44
|
+
require_local 'mercurial-ruby/command'
|
45
|
+
require_local 'mercurial-ruby/helper'
|
46
|
+
require_local 'mercurial-ruby/style'
|
47
|
+
require_local 'mercurial-ruby/repository'
|
48
|
+
require_local 'mercurial-ruby/config_file'
|
49
|
+
require_local 'mercurial-ruby/hook'
|
50
|
+
require_local 'mercurial-ruby/commit'
|
51
|
+
require_local 'mercurial-ruby/changed_file'
|
52
|
+
require_local 'mercurial-ruby/diff'
|
53
|
+
require_local 'mercurial-ruby/branch'
|
54
|
+
require_local 'mercurial-ruby/tag'
|
55
|
+
require_local 'mercurial-ruby/manifest'
|
56
|
+
require_local 'mercurial-ruby/node'
|
57
|
+
require_local 'mercurial-ruby/root_node'
|
58
|
+
require_local 'mercurial-ruby/file_index'
|
59
|
+
|
60
|
+
require_local 'mercurial-ruby/factories/hook_factory'
|
61
|
+
require_local 'mercurial-ruby/factories/commit_factory'
|
62
|
+
require_local 'mercurial-ruby/factories/changed_file_factory'
|
63
|
+
require_local 'mercurial-ruby/factories/diff_factory'
|
64
|
+
require_local 'mercurial-ruby/factories/branch_factory'
|
65
|
+
require_local 'mercurial-ruby/factories/tag_factory'
|
66
|
+
require_local 'mercurial-ruby/factories/node_factory'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Mercurial
|
2
|
+
|
3
|
+
#
|
4
|
+
# The class represents Mercurial branch. Obtained by running an +hg branches+ command.
|
5
|
+
#
|
6
|
+
# The class represents Branch object itself, {Mercurial::BranchFactory BranchFactory} is responsible
|
7
|
+
# for assembling instances of Branch. For the list of all possible branch-related operations please
|
8
|
+
# look documentation for {Mercurial::BranchFactory BranchFactory}.
|
9
|
+
#
|
10
|
+
# Read more about Mercurial branches:
|
11
|
+
#
|
12
|
+
# http://mercurial.selenic.com/wiki/Branch
|
13
|
+
#
|
14
|
+
class Branch
|
15
|
+
|
16
|
+
# Instance of {Mercurial::Repository Repository}.
|
17
|
+
attr_reader :repository
|
18
|
+
|
19
|
+
# Name of the branch.
|
20
|
+
attr_reader :name
|
21
|
+
|
22
|
+
# State of the branch: closed or active.
|
23
|
+
attr_reader :status
|
24
|
+
|
25
|
+
# Mercurial changeset ID of the latest commit in the branch. 40-chars long SHA1 hash.
|
26
|
+
attr_reader :latest_commit
|
27
|
+
|
28
|
+
def initialize(repository, name, options={})
|
29
|
+
@repository = repository
|
30
|
+
@name = name
|
31
|
+
@status = options[:status] == 'closed' ? 'closed' : 'active'
|
32
|
+
@latest_commit = options[:commit]
|
33
|
+
end
|
34
|
+
|
35
|
+
def active?
|
36
|
+
status == 'active'
|
37
|
+
end
|
38
|
+
|
39
|
+
def closed?
|
40
|
+
status == 'closed'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Mercurial
|
2
|
+
|
3
|
+
class ChangedFile
|
4
|
+
|
5
|
+
attr_reader :name, :initial_name
|
6
|
+
attr_accessor :mode_letter
|
7
|
+
|
8
|
+
def initialize(opts={})
|
9
|
+
@initial_name = opts[:initial_name]
|
10
|
+
@name = opts[:name]
|
11
|
+
@mode_letter = opts[:mode]
|
12
|
+
end
|
13
|
+
|
14
|
+
def moved?
|
15
|
+
mode == :move
|
16
|
+
end
|
17
|
+
|
18
|
+
def copied?
|
19
|
+
mode == :copy
|
20
|
+
end
|
21
|
+
|
22
|
+
def deleted?
|
23
|
+
mode == :delete
|
24
|
+
end
|
25
|
+
|
26
|
+
def added?
|
27
|
+
mode == :add
|
28
|
+
end
|
29
|
+
|
30
|
+
def modified?
|
31
|
+
mode == :edit
|
32
|
+
end
|
33
|
+
|
34
|
+
def mode
|
35
|
+
case mode_letter
|
36
|
+
when 'A'
|
37
|
+
:add
|
38
|
+
when 'D'
|
39
|
+
:delete
|
40
|
+
when 'C'
|
41
|
+
:copy
|
42
|
+
when 'R'
|
43
|
+
:move
|
44
|
+
else
|
45
|
+
:edit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
require 'digest/md5'
|
3
|
+
|
4
|
+
module Mercurial
|
5
|
+
class CommandError < Error; end
|
6
|
+
|
7
|
+
class Command
|
8
|
+
attr_accessor :command, :repository, :use_cache
|
9
|
+
|
10
|
+
def initialize(cmd, options={})
|
11
|
+
@command = cmd
|
12
|
+
@repository = options[:repository]
|
13
|
+
@use_cache = options[:cache]
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
if cache_commands?
|
18
|
+
execute_with_caching
|
19
|
+
else
|
20
|
+
execute_without_caching
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def cache_commands?
|
27
|
+
repository && use_cache && cache_store
|
28
|
+
end
|
29
|
+
|
30
|
+
def cache_store
|
31
|
+
Mercurial.configuration.cache_store
|
32
|
+
end
|
33
|
+
|
34
|
+
def execution_timeout
|
35
|
+
Mercurial.configuration.shell_timeout
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute_with_caching
|
39
|
+
cache_store.fetch(cache_key, &execution_proc)
|
40
|
+
end
|
41
|
+
|
42
|
+
def execute_without_caching
|
43
|
+
execution_proc.call
|
44
|
+
end
|
45
|
+
|
46
|
+
def execution_proc
|
47
|
+
Proc.new do
|
48
|
+
result, error = '', ''
|
49
|
+
Open3.popen3(command) do |_, stdout, stderr|
|
50
|
+
Timeout.timeout(execution_timeout) do
|
51
|
+
while tmp = stdout.read(102400)
|
52
|
+
result += tmp
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
while tmp = stderr.read(1024)
|
57
|
+
error += tmp
|
58
|
+
end
|
59
|
+
end
|
60
|
+
raise_error_if_needed(error)
|
61
|
+
result
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def raise_error_if_needed(error)
|
66
|
+
if error && error != ''
|
67
|
+
raise CommandError, error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def cache_key
|
72
|
+
"hg.#{ repository.mtime }." + Digest::MD5.hexdigest(command)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|