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
File without changes
|
File without changes
|
Binary file
|
File without changes
|
@@ -0,0 +1,78 @@
|
|
1
|
+
Mercurial Distributed SCM
|
2
|
+
|
3
|
+
list of commands:
|
4
|
+
|
5
|
+
add add the specified files on the next commit
|
6
|
+
addremove add all new files, delete all missing files
|
7
|
+
annotate show changeset information by line for each file
|
8
|
+
archive create an unversioned archive of a repository revision
|
9
|
+
backout reverse effect of earlier changeset
|
10
|
+
bisect subdivision search of changesets
|
11
|
+
bookmarks track a line of development with movable markers
|
12
|
+
branch set or show the current branch name
|
13
|
+
branches list repository named branches
|
14
|
+
bundle create a changegroup file
|
15
|
+
cat output the current or given revision of files
|
16
|
+
clone make a copy of an existing repository
|
17
|
+
commit commit the specified files or all outstanding changes
|
18
|
+
copy mark files as copied for the next commit
|
19
|
+
diff diff repository (or selected files)
|
20
|
+
export dump the header and diffs for one or more changesets
|
21
|
+
forget forget the specified files on the next commit
|
22
|
+
grep search for a pattern in specified files and revisions
|
23
|
+
heads show current repository heads or show branch heads
|
24
|
+
help show help for a given topic or a help overview
|
25
|
+
identify identify the working copy or specified revision
|
26
|
+
import import an ordered set of patches
|
27
|
+
incoming show new changesets found in source
|
28
|
+
init create a new repository in the given directory
|
29
|
+
locate locate files matching specific patterns
|
30
|
+
log show revision history of entire repository or files
|
31
|
+
manifest output the current or given revision of the project manifest
|
32
|
+
merge merge working directory with another revision
|
33
|
+
outgoing show changesets not found in the destination
|
34
|
+
parents show the parents of the working directory or revision
|
35
|
+
paths show aliases for remote repositories
|
36
|
+
pull pull changes from the specified source
|
37
|
+
push push changes to the specified destination
|
38
|
+
recover roll back an interrupted transaction
|
39
|
+
remove remove the specified files on the next commit
|
40
|
+
rename rename files; equivalent of copy + remove
|
41
|
+
resolve redo merges or set/view the merge status of files
|
42
|
+
revert restore files to their checkout state
|
43
|
+
rollback roll back the last transaction (dangerous)
|
44
|
+
root print the root (top) of the current working directory
|
45
|
+
serve start stand-alone webserver
|
46
|
+
showconfig show combined config settings from all hgrc files
|
47
|
+
status show changed files in the working directory
|
48
|
+
summary summarize working directory state
|
49
|
+
tag add one or more tags for the current or given revision
|
50
|
+
tags list repository tags
|
51
|
+
tip show the tip revision
|
52
|
+
unbundle apply one or more changegroup files
|
53
|
+
update update working directory (or switch revisions)
|
54
|
+
verify verify the integrity of the repository
|
55
|
+
version output version and copyright information
|
56
|
+
|
57
|
+
additional help topics:
|
58
|
+
|
59
|
+
config Configuration Files
|
60
|
+
dates Date Formats
|
61
|
+
diffs Diff Formats
|
62
|
+
environment Environment Variables
|
63
|
+
extensions Using additional features
|
64
|
+
filesets Specifying File Sets
|
65
|
+
glossary Glossary
|
66
|
+
hgignore syntax for Mercurial ignore files
|
67
|
+
hgweb Configuring hgweb
|
68
|
+
merge-tools Merge Tools
|
69
|
+
multirevs Specifying Multiple Revisions
|
70
|
+
patterns File Name Patterns
|
71
|
+
revisions Specifying Single Revisions
|
72
|
+
revsets Specifying Revision Sets
|
73
|
+
subrepos Subrepositories
|
74
|
+
templating Template Usage
|
75
|
+
urls URL Paths
|
76
|
+
|
77
|
+
use "hg -v help" to show builtin aliases and global options
|
78
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
Here will be some new kind of CSV.
|
Binary file
|
File without changes
|
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class Generator
|
3
|
+
module RiotMixin
|
4
|
+
def self.extended(generator)
|
5
|
+
# changed
|
6
|
+
generator.development_dependencies << ["riot", ">= 0"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_task
|
10
|
+
'test'
|
11
|
+
end
|
12
|
+
|
13
|
+
def feature_support_require
|
14
|
+
'riot/context'
|
15
|
+
end
|
16
|
+
|
17
|
+
def feature_support_extend
|
18
|
+
'Riot::Context'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_dir
|
22
|
+
'test'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_task
|
26
|
+
'test'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_pattern
|
30
|
+
'test/**/*_test.rb'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_filename
|
34
|
+
"#{require_name}_test.rb"
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_helper_filename
|
38
|
+
"teststrap.rb"
|
39
|
+
end
|
40
|
+
|
41
|
+
def tiny_change
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a superman file.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class Generator
|
3
|
+
module TestspecMixin
|
4
|
+
def self.extended(generator)
|
5
|
+
generator.development_dependencies << ["test-spec", ">= 0"]
|
6
|
+
end
|
7
|
+
|
8
|
+
def default_task
|
9
|
+
'test'
|
10
|
+
end
|
11
|
+
|
12
|
+
def feature_support_require
|
13
|
+
'test/unit/assertions'
|
14
|
+
end
|
15
|
+
|
16
|
+
def feature_support_extend
|
17
|
+
'Test::Unit::Assertions'
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_dir
|
21
|
+
'test'
|
22
|
+
end
|
23
|
+
|
24
|
+
def another_change
|
25
|
+
|
26
|
+
def test_task
|
27
|
+
'test'
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_pattern
|
31
|
+
'test/**/*_test.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_filename
|
35
|
+
"#{require_name}_test.rb"
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_helper_filename
|
39
|
+
"test_helper.rb"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'ruby-debug'
|
4
|
+
|
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
|
+
|
13
|
+
require "mocha"
|
14
|
+
require "minitest/autorun"
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
18
|
+
|
19
|
+
require 'mercurial-ruby'
|
20
|
+
require 'fixtures'
|
21
|
+
|
22
|
+
$stderr.reopen('/dev/null')
|
23
|
+
|
24
|
+
class MiniTest::Unit::TestCase
|
25
|
+
include Mocha::API
|
26
|
+
|
27
|
+
def setup
|
28
|
+
Mocha::Mockery.instance.stubba.unstub_all
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def stub_hgrc(path)
|
34
|
+
File.open(path, 'w') do |f|
|
35
|
+
f << Fixtures.hgrc_sample
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
MiniTest::Unit.autorun
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Mercurial::BranchFactory do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@repository = Mercurial::Repository.open(Fixtures.test_repo)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should find all branches" do
|
10
|
+
branches = @repository.branches.all
|
11
|
+
branches.size.must_equal 5
|
12
|
+
branches.map(&:name).sort.must_equal %w(branch-from-remote another-branch new-branch old-branch default).sort
|
13
|
+
branches.map(&:status).sort.must_equal %w(active active closed active active).sort
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should find active branches" do
|
17
|
+
branches = @repository.branches.active
|
18
|
+
branches.size.must_equal 4
|
19
|
+
branches.map(&:name).sort.must_equal %w(another-branch new-branch default branch-from-remote).sort
|
20
|
+
branches.map(&:status).must_equal %w(active active active active)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should find closed branches" do
|
24
|
+
branches = @repository.branches.closed
|
25
|
+
branches.size.must_equal 1
|
26
|
+
branches.map(&:name).must_equal %w(old-branch)
|
27
|
+
branches.map(&:status).must_equal %w(closed)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should find branch by name" do
|
31
|
+
branch = @repository.branches.by_name('new-branch')
|
32
|
+
branch.must_be_kind_of(Mercurial::Branch)
|
33
|
+
branch.status.must_equal 'active'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not find a branch by inexistent name" do
|
37
|
+
@repository.branches.by_name('bla-branch-f').must_equal nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return branches for commit" do
|
41
|
+
branches = @repository.branches.for_commit('bf6386c0a0cc')
|
42
|
+
branches.size.must_equal 5
|
43
|
+
branches.map(&:name).sort.must_equal %w(old-branch new-branch branch-from-remote another-branch default).sort
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Mercurial::Commit do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@repository = Mercurial::Repository.open(Fixtures.test_repo)
|
7
|
+
@commit = @repository.commits.by_hash_id('54d96f4b1a26')
|
8
|
+
@files = @commit.changed_files
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should indicate modified file" do
|
12
|
+
file = @files[0]
|
13
|
+
file.initial_name.must_equal nil
|
14
|
+
file.name.must_equal 'README.markup'
|
15
|
+
file.mode.must_equal :edit
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should indicate added file" do
|
19
|
+
file = @files[1]
|
20
|
+
file.initial_name.must_equal nil
|
21
|
+
file.name.must_equal 'superman.txt'
|
22
|
+
file.mode.must_equal :add
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should indicate deleted file" do
|
26
|
+
file = @files[2]
|
27
|
+
file.initial_name.must_equal nil
|
28
|
+
file.name.must_equal 'Rakefile2'
|
29
|
+
file.mode.must_equal :delete
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should indicate copied file" do
|
33
|
+
file = @files[3]
|
34
|
+
file.initial_name.must_equal 'LICENSE3.txt'
|
35
|
+
file.name.must_equal 'LICENSE4.txt'
|
36
|
+
file.mode.must_equal :copy
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should indicate moved file" do
|
40
|
+
file = @files[4]
|
41
|
+
file.initial_name.must_equal 'Rakefile'
|
42
|
+
file.name.must_equal 'Rakefile3'
|
43
|
+
file.mode.must_equal :move
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Mercurial::ChangedFileFactory do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@repository = Mercurial::Repository.open(Fixtures.test_repo)
|
7
|
+
@commit = @repository.commits.by_hash_id('b66320fa72aa')
|
8
|
+
@files = @commit.changed_files
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should parse files with dot in their names properly" do
|
12
|
+
@files.size.must_equal 1
|
13
|
+
@files.first.name.must_equal '.DotFile'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Mercurial::Command do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@repository = Mercurial::Repository.open(Fixtures.test_repo)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should execute shell commands" do
|
10
|
+
output = Mercurial::Command.new("cd #{ @repository.path } && hg log").execute
|
11
|
+
(output.size > 100).must_equal true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should translate shell errors to ruby exceptions" do
|
15
|
+
lambda{
|
16
|
+
Mercurial::Command.new("cd #{ @repository.path } && hg shikaka").execute
|
17
|
+
}.must_raise Mercurial::CommandError
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should execute commands with timeout" do
|
21
|
+
Mercurial.configuration.stubs(:shell_timeout).returns(1)
|
22
|
+
lambda{
|
23
|
+
Mercurial::Command.new("sleep 5").execute
|
24
|
+
}.must_raise Timeout::Error
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should generate cache key for every command" do
|
28
|
+
key = Mercurial::Command.new("cd #{ @repository.path } && hg log", :repository => @repository).send(:cache_key)
|
29
|
+
key.must_be_kind_of String
|
30
|
+
(key.size > 10).must_equal true
|
31
|
+
|
32
|
+
key2 = Mercurial::Command.new("cd #{ @repository.path } && hg log", :repository => @repository).send(:cache_key)
|
33
|
+
key.must_equal key2
|
34
|
+
|
35
|
+
key3 = Mercurial::Command.new("cd #{ @repository.path } && hg log -v", :repository => @repository).send(:cache_key)
|
36
|
+
key3.wont_equal key2
|
37
|
+
key3.wont_equal key
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should cache commands if cache store is available and command is called for repository" do
|
41
|
+
command = Mercurial::Command.new("cd #{ @repository.path } && hg log -v", :repository => @repository)
|
42
|
+
cache_store = mock('cache_store')
|
43
|
+
cache_store.expects(:fetch).with(command.send(:cache_key)).returns(true).once
|
44
|
+
Mercurial.configuration.stubs(:cache_store).returns(cache_store)
|
45
|
+
command.execute
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not use cache store if command is executed outside repository" do
|
49
|
+
command = Mercurial::Command.new("ls -l /")
|
50
|
+
cache_store = mock('cache_store')
|
51
|
+
cache_store.expects(:fetch).never
|
52
|
+
command.execute
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not use cache store if it's not available" do
|
56
|
+
command = Mercurial::Command.new("cd #{ @repository.path } && hg log -v", :repository => @repository)
|
57
|
+
cache_store = mock('cache_store')
|
58
|
+
cache_store.expects(:fetch).never
|
59
|
+
command.execute
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/test/test_commit.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Mercurial::Commit do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@repository = Mercurial::Repository.open(Fixtures.test_repo)
|
7
|
+
@commit = @repository.commits.by_hash_id('34f85a44acf1')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should parse date to Ruby format" do
|
11
|
+
@commit.date.must_be_kind_of Time
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should represent branches as Array" do
|
15
|
+
@commit.branches_names.must_be_kind_of Array
|
16
|
+
end
|
17
|
+
|
18
|
+
it "branches array should be empty if there are no branches" do
|
19
|
+
@commit = @repository.commits.by_hash_id('4474d1ddaf65')
|
20
|
+
@commit.branches_names.must_equal []
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should represent tags as Array" do
|
24
|
+
@commit.tags_names.must_be_kind_of Array
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should convert list of changed files to an array of ChangedFile objects" do
|
28
|
+
@commit.changed_files.must_be_kind_of Array
|
29
|
+
@commit.changed_files.first.must_be_kind_of Mercurial::ChangedFile
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have parents_ids array" do
|
33
|
+
@commit.parents_ids.must_be_kind_of Array
|
34
|
+
@commit.parents_ids.first.must_equal '25bb5c51fd61'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be detected as merge if has many parents" do
|
38
|
+
commit = @repository.commits.by_hash_id('cd9fa0c59c7f')
|
39
|
+
commit.merge?.must_equal true
|
40
|
+
commit.parents_ids.sort.must_equal ["4474d1ddaf65", "6157254a4423"].sort
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should create commit objects for parents" do
|
44
|
+
commit = @repository.commits.by_hash_id('cd9fa0c59c7f')
|
45
|
+
commit.parents.each do |parent|
|
46
|
+
parent.must_be_kind_of Mercurial::Commit
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should convert commit to hash" do
|
51
|
+
commit = @repository.commits.by_hash_id('cd9fa0c59c7f')
|
52
|
+
commit.to_hash.must_be_kind_of Hash
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should be considered blank if hash is all zeroes" do
|
56
|
+
commit = @repository.commits.by_hash_id('cd9fa0c59c7f')
|
57
|
+
commit.stubs(:hash_id).returns('0000000000000000000000000000000000000000')
|
58
|
+
commit.blank?.must_equal true
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return an array of branches where it exists" do
|
62
|
+
commit = @repository.commits.by_hash_id('cd9fa0c59c7f')
|
63
|
+
commit.exist_in_branches.map(&:name).sort.must_equal %w(default another-branch).sort
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|