mercurial-ruby 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mercurial-ruby.rb +1 -1
- data/lib/mercurial-ruby/diff.rb +1 -5
- data/lib/mercurial-ruby/factories/diff_factory.rb +7 -3
- data/mercurial-ruby.gemspec +2 -2
- data/test/fixtures/test-repo.zip +0 -0
- data/test/test_commit_factory.rb +1 -1
- data/test/test_diff_factory.rb +40 -0
- data/test/test_file_index.rb +1 -1
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/mercurial-ruby.rb
CHANGED
data/lib/mercurial-ruby/diff.rb
CHANGED
@@ -9,9 +9,6 @@ module Mercurial
|
|
9
9
|
#
|
10
10
|
class Diff
|
11
11
|
|
12
|
-
# Instance of {Mercurial::Commit Commit}.
|
13
|
-
attr_reader :commit
|
14
|
-
|
15
12
|
# SHA1 hash of version a of the file.
|
16
13
|
attr_reader :hash_a
|
17
14
|
|
@@ -27,8 +24,7 @@ module Mercurial
|
|
27
24
|
# Diff body.
|
28
25
|
attr_reader :body
|
29
26
|
|
30
|
-
def initialize(
|
31
|
-
@commit = commit
|
27
|
+
def initialize(opts={})
|
32
28
|
@hash_a = opts[:hash_a]
|
33
29
|
@hash_b = opts[:hash_b]
|
34
30
|
@file_a = opts[:file_a]
|
@@ -27,15 +27,19 @@ module Mercurial
|
|
27
27
|
unless chunks.nil?
|
28
28
|
chunks.map do |piece|
|
29
29
|
piece = "diff" << piece
|
30
|
-
returning << build(
|
30
|
+
returning << build(piece)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def for_path(path, revision_a, revision_b)
|
37
|
+
build(hg(["diff ? -r ? -r ?", path, revision_a, revision_b]))
|
38
|
+
end
|
39
|
+
|
36
40
|
private
|
37
41
|
|
38
|
-
def build(
|
42
|
+
def build(data)
|
39
43
|
return if data.empty?
|
40
44
|
hash_a, hash_b = *data.scan(/^diff -r (\w+) -r (\w+)/).first
|
41
45
|
|
@@ -48,7 +52,7 @@ module Mercurial
|
|
48
52
|
body = data[data.index("\n")+1..-1]
|
49
53
|
end
|
50
54
|
|
51
|
-
Mercurial::Diff.new(
|
55
|
+
Mercurial::Diff.new(
|
52
56
|
:hash_a => hash_a,
|
53
57
|
:hash_b => hash_b,
|
54
58
|
:file_a => file_a,
|
data/mercurial-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mercurial-ruby}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.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-
|
12
|
+
s.date = %q{2011-09-16}
|
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 = [
|
data/test/fixtures/test-repo.zip
CHANGED
Binary file
|
data/test/test_commit_factory.rb
CHANGED
data/test/test_diff_factory.rb
CHANGED
@@ -35,4 +35,44 @@ describe Mercurial::DiffFactory do
|
|
35
35
|
commit.diffs.size.must_equal 0
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should find diffs for path" do
|
39
|
+
diff = @repository.diffs.for_path('diff-test.rb', '57a6efe309bf', '9f76ea916c51')
|
40
|
+
diff.must_be_kind_of Mercurial::Diff
|
41
|
+
diff.hash_a.must_equal '57a6efe309bf'
|
42
|
+
diff.hash_b.must_equal'9f76ea916c51'
|
43
|
+
diff.file_a.must_equal 'diff-test.rb'
|
44
|
+
diff.file_b.must_equal 'diff-test.rb'
|
45
|
+
diff.body.must_equal diff_sample
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def diff_sample
|
51
|
+
%Q[--- a/diff-test.rb Thu Sep 15 23:43:02 2011 +0800
|
52
|
+
+++ b/diff-test.rb Thu Sep 15 23:43:52 2011 +0800
|
53
|
+
@@ -5,19 +5,17 @@
|
54
|
+
|
55
|
+
before_filter :repository_detected?, :except => :index
|
56
|
+
before_filter :welcome_screen, :only => :index
|
57
|
+
- before_filter :prepare_to_show, :only => [:show, :differences, :message]
|
58
|
+
before_filter :setup_page, :only => [:index, :repository]
|
59
|
+
|
60
|
+
caches_action :message, :differences
|
61
|
+
|
62
|
+
+ helper_method :current_branch
|
63
|
+
helper_method :repository_scope?
|
64
|
+
- helper_method :quick_changeset
|
65
|
+
helper_method :changesets_changes_limit
|
66
|
+
- helper_method :current_branch
|
67
|
+
helper_method :diff_taking_too_much_time_msg
|
68
|
+
|
69
|
+
def repository
|
70
|
+
- if current_repository.import_in_progress?
|
71
|
+
+ unless current_repository.import_in_progress?
|
72
|
+
return render(:template => "changesets/import_in_progress")
|
73
|
+
end
|
74
|
+
@changesets = find_changesets_for_current_scope
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
38
78
|
end
|
data/test/test_file_index.rb
CHANGED
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:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.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-
|
18
|
+
date: 2011-09-16 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|